summaryrefslogtreecommitdiff
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-02-10 10:19:28 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2016-02-10 10:19:28 +0100
commitd1f4409a2b1e0143be0d4fd734f3dd83255ea35c (patch)
tree52daa990c1da2c2ce9656fe4065b73a848a57a5a /tests/auto/widgets
parent8e5ac243ac774209b77bec42eda2ec43f9c9b04a (diff)
parent776442f2117c4b2d6dac75ab56b42bd82e2ce6d0 (diff)
downloadqtwebengine-d1f4409a2b1e0143be0d4fd734f3dd83255ea35c.tar.gz
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp tests/auto/widgets/widgets.pro Change-Id: Id9444359ed2e35d469331db96a355c9ea2d095d5
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/qwebenginedefaultsurfaceformat/qwebenginedefaultsurfaceformat.pro1
-rw-r--r--tests/auto/widgets/qwebenginedefaultsurfaceformat/resources/index.html6
-rw-r--r--tests/auto/widgets/qwebenginedefaultsurfaceformat/tst_qwebenginedefaultsurfaceformat.cpp77
-rw-r--r--tests/auto/widgets/qwebenginedefaultsurfaceformat/tst_qwebenginedefaultsurfaceformat.qrc5
-rw-r--r--tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp50
-rw-r--r--tests/auto/widgets/widgets.pro1
6 files changed, 120 insertions, 20 deletions
diff --git a/tests/auto/widgets/qwebenginedefaultsurfaceformat/qwebenginedefaultsurfaceformat.pro b/tests/auto/widgets/qwebenginedefaultsurfaceformat/qwebenginedefaultsurfaceformat.pro
new file mode 100644
index 000000000..e99c7f493
--- /dev/null
+++ b/tests/auto/widgets/qwebenginedefaultsurfaceformat/qwebenginedefaultsurfaceformat.pro
@@ -0,0 +1 @@
+include(../tests.pri)
diff --git a/tests/auto/widgets/qwebenginedefaultsurfaceformat/resources/index.html b/tests/auto/widgets/qwebenginedefaultsurfaceformat/resources/index.html
new file mode 100644
index 000000000..53726e4a6
--- /dev/null
+++ b/tests/auto/widgets/qwebenginedefaultsurfaceformat/resources/index.html
@@ -0,0 +1,6 @@
+<html>
+<head>
+<title> Basic Page </title>
+</head>
+<h1>Basic page</h1>
+</html>
diff --git a/tests/auto/widgets/qwebenginedefaultsurfaceformat/tst_qwebenginedefaultsurfaceformat.cpp b/tests/auto/widgets/qwebenginedefaultsurfaceformat/tst_qwebenginedefaultsurfaceformat.cpp
new file mode 100644
index 000000000..e42a8a75e
--- /dev/null
+++ b/tests/auto/widgets/qwebenginedefaultsurfaceformat/tst_qwebenginedefaultsurfaceformat.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include "../util.h"
+
+#include <QSurfaceFormat>
+#include <QTimer>
+#include <qwebengineview.h>
+
+class tst_QWebEngineDefaultSurfaceFormat : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void customDefaultSurfaceFormat();
+};
+
+void tst_QWebEngineDefaultSurfaceFormat::customDefaultSurfaceFormat()
+{
+ // Setting a new default QSurfaceFormat with a core OpenGL profile before
+ // app instantiation should succeed, without abort() being called.
+ int argc = 1;
+ char *argv[] = { const_cast<char*>("tst_QWebEngineDefaultSurfaceFormat") };
+
+ QSurfaceFormat format;
+ format.setVersion( 3, 3 );
+ format.setProfile( QSurfaceFormat::CoreProfile );
+ QSurfaceFormat::setDefaultFormat( format );
+
+ QApplication app(argc, argv);
+
+ QWebEngineView view;
+ view.load(QUrl("qrc:///resources/index.html"));
+ view.show();
+ QObject::connect(&view, &QWebEngineView::loadFinished, []() {
+ QTimer::singleShot(100, qApp, &QCoreApplication::quit);
+ });
+
+ QCOMPARE(app.exec(), 0);
+}
+
+QTEST_APPLESS_MAIN(tst_QWebEngineDefaultSurfaceFormat)
+#include "tst_qwebenginedefaultsurfaceformat.moc"
diff --git a/tests/auto/widgets/qwebenginedefaultsurfaceformat/tst_qwebenginedefaultsurfaceformat.qrc b/tests/auto/widgets/qwebenginedefaultsurfaceformat/tst_qwebenginedefaultsurfaceformat.qrc
new file mode 100644
index 000000000..3d5f1b3b2
--- /dev/null
+++ b/tests/auto/widgets/qwebenginedefaultsurfaceformat/tst_qwebenginedefaultsurfaceformat.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>resources/index.html</file>
+</qresource>
+</RCC>
diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
index 8c23af7ee..26980df7b 100644
--- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
+++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
@@ -31,9 +31,10 @@
#include <QtTest/QtTest>
#include <QtWebEngineCore/qwebengineurlrequestjob.h>
#include <QtWebEngineCore/qwebengineurlschemehandler.h>
+#include <QtWebEngineWidgets/qwebengineprofile.h>
+#include <QtWebEngineWidgets/qwebenginepage.h>
+#include <QtWebEngineWidgets/qwebenginesettings.h>
#include <QtWebEngineWidgets/qwebengineview.h>
-#include <qwebengineprofile.h>
-#include <qwebenginepage.h>
class tst_QWebEngineProfile : public QObject
{
@@ -171,52 +172,61 @@ public:
}
};
+static bool loadSync(QWebEngineView *view, const QUrl &url, int timeout = 5000)
+{
+ // Ripped off QTRY_VERIFY.
+ QSignalSpy loadFinishedSpy(view, SIGNAL(loadFinished(bool)));
+ view->load(url);
+ if (loadFinishedSpy.isEmpty())
+ QTest::qWait(0);
+ for (int i = 0; i < timeout; i += 50) {
+ if (!loadFinishedSpy.isEmpty())
+ return true;
+ QTest::qWait(50);
+ }
+ return false;
+}
+
void tst_QWebEngineProfile::urlSchemeHandlers()
{
- RedirectingUrlSchemeHandler mailtoHandler;
+ RedirectingUrlSchemeHandler lettertoHandler;
QWebEngineProfile profile(QStringLiteral("urlSchemeHandlers"));
- profile.installUrlSchemeHandler("mailto", &mailtoHandler);
+ profile.installUrlSchemeHandler("letterto", &lettertoHandler);
QWebEngineView view;
- QSignalSpy loadFinishedSpy(&view, SIGNAL(loadFinished(bool)));
view.setPage(new QWebEnginePage(&profile, &view));
+ view.settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false);
QString emailAddress = QStringLiteral("egon@olsen-banden.dk");
- view.load(QUrl(QStringLiteral("mailto:") + emailAddress));
- QVERIFY(loadFinishedSpy.wait());
+ QVERIFY(loadSync(&view, QUrl(QStringLiteral("letterto:") + emailAddress)));
QCOMPARE(toPlainTextSync(view.page()), emailAddress);
// Install a gopher handler after the view has been fully initialized.
ReplyingUrlSchemeHandler gopherHandler;
profile.installUrlSchemeHandler("gopher", &gopherHandler);
QUrl url = QUrl(QStringLiteral("gopher://olsen-banden.dk/benny"));
- view.load(url);
- QVERIFY(loadFinishedSpy.wait());
+ QVERIFY(loadSync(&view, url));
QCOMPARE(toPlainTextSync(view.page()), url.toString());
- // Remove the mailto scheme, and check whether it is not handled anymore.
- profile.removeUrlScheme("mailto");
+ // Remove the letterto scheme, and check whether it is not handled anymore.
+ profile.removeUrlScheme("letterto");
emailAddress = QStringLiteral("kjeld@olsen-banden.dk");
- view.load(QUrl(QStringLiteral("mailto:") + emailAddress));
- QVERIFY(loadFinishedSpy.wait());
+ QVERIFY(loadSync(&view, QUrl(QStringLiteral("letterto:") + emailAddress)));
QVERIFY(toPlainTextSync(view.page()) != emailAddress);
- // Check if gopher is still working after removing mailto.
+ // Check if gopher is still working after removing letterto.
url = QUrl(QStringLiteral("gopher://olsen-banden.dk/yvonne"));
- view.load(url);
- QVERIFY(loadFinishedSpy.wait());
+ QVERIFY(loadSync(&view, url));
QCOMPARE(toPlainTextSync(view.page()), url.toString());
// Does removeAll work?
profile.removeAllUrlSchemeHandlers();
url = QUrl(QStringLiteral("gopher://olsen-banden.dk/harry"));
- view.load(url);
- QVERIFY(loadFinishedSpy.wait());
+ QVERIFY(loadSync(&view, url));
QVERIFY(toPlainTextSync(view.page()) != url.toString());
// Install a handler that is owned by the view. Make sure this doesn't crash on shutdown.
profile.installUrlSchemeHandler("aviancarrier", new ReplyingUrlSchemeHandler(&view));
url = QUrl(QStringLiteral("aviancarrier:inspector.mortensen@politistyrke.dk"));
- view.load(url);
- QVERIFY(loadFinishedSpy.wait());
+ QVERIFY(loadSync(&view, url));
QCOMPARE(toPlainTextSync(view.page()), url.toString());
}
diff --git a/tests/auto/widgets/widgets.pro b/tests/auto/widgets/widgets.pro
index c65d7dd6c..6c516b38f 100644
--- a/tests/auto/widgets/widgets.pro
+++ b/tests/auto/widgets/widgets.pro
@@ -2,6 +2,7 @@ TEMPLATE = subdirs
SUBDIRS += \
qwebengineaccessibility \
+ qwebenginedefaultsurfaceformat \
qwebenginefaviconmanager \
qwebenginepage \
qwebenginehistory \