From b26f697dbed3c2d12db0254a67cdf23396b91c23 Mon Sep 17 00:00:00 2001
From: Szabolcs David <davidsz@inf.u-szeged.hu>
Date: Tue, 17 Feb 2015 05:56:56 -0800
Subject: [PATCH] Fix tst_qwebengineaccessibility API test

Implement a custom QTEST_MAIN preprocessor macro in order to
support hardcoded Chromium content switches in the API tests.

Force renderer accessibility to be on instead of enabling it on
demand when a screen reader is detected.

Change-Id: I9600ac4b26f4656104ce27ff19accbed4ea817c6
Reviewed-by: Pierre Rossi <pierre.rossi@theqtcompany.com>
---
 .../tst_qwebengineaccessibility.cpp             |  5 ++++-
 tests/auto/widgets/util.h                       | 17 +++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/tests/auto/widgets/qwebengineaccessibility/tst_qwebengineaccessibility.cpp b/tests/auto/widgets/qwebengineaccessibility/tst_qwebengineaccessibility.cpp
index 96795cf64..016c4f98c 100644
--- a/tests/auto/widgets/qwebengineaccessibility/tst_qwebengineaccessibility.cpp
+++ b/tests/auto/widgets/qwebengineaccessibility/tst_qwebengineaccessibility.cpp
@@ -245,5 +245,8 @@ void tst_QWebEngineView::value()
     QCOMPARE(progressBarValueInterface->maximumValue().toInt(), 99);
 }
 
-QTEST_MAIN(tst_QWebEngineView)
+static QByteArrayList params = QByteArrayList()
+    << "--force-renderer-accessibility";
+
+W_QTEST_MAIN(tst_QWebEngineView, params)
 #include "tst_qwebengineaccessibility.moc"
diff --git a/tests/auto/widgets/util.h b/tests/auto/widgets/util.h
index 035578358..83067fe8d 100644
--- a/tests/auto/widgets/util.h
+++ b/tests/auto/widgets/util.h
@@ -164,3 +164,20 @@ static inline QUrl baseUrlSync(QWebEnginePage *page)
 }
 
 #define W_QSKIP(a, b) QSKIP(a)
+
+#define W_QTEST_MAIN(TestObject, params) \
+int main(int argc, char *argv[]) \
+{ \
+    QVector<const char *> w_argv(argc); \
+    for (int i = 0; i < argc; ++i) \
+        w_argv[i] = argv[i]; \
+    for (int i = 0; i < params.size(); ++i) \
+        w_argv.append(params[i].data()); \
+    int w_argc = w_argv.size(); \
+    \
+    QApplication app(w_argc, const_cast<char **>(w_argv.data())); \
+    app.setAttribute(Qt::AA_Use96Dpi, true); \
+    QTEST_DISABLE_KEYPAD_NAVIGATION \
+    TestObject tc; \
+    return QTest::qExec(&tc, argc, argv); \
+}
-- 
GitLab