summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp30
-rw-r--r--tests/auto/widgets/qwebenginehistoryinterface/tst_qwebenginehistoryinterface.cpp106
-rw-r--r--tests/auto/widgets/qwebengineshutdown/qwebengineshutdown.pro (renamed from tests/auto/widgets/qwebenginehistoryinterface/qwebenginehistoryinterface.pro)0
-rw-r--r--tests/auto/widgets/qwebengineshutdown/tst_qwebengineshutdown.cpp95
-rw-r--r--tests/auto/widgets/qwebengineview/BLACKLIST6
-rw-r--r--tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp90
-rw-r--r--tests/auto/widgets/widgets.pro2
7 files changed, 208 insertions, 121 deletions
diff --git a/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp b/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp
index 7c8497fef..3c8025672 100644
--- a/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp
+++ b/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp
@@ -40,6 +40,7 @@ protected :
loadFinishedSpy->clear();
page->load(QUrl("qrc:/resources/page" + QString::number(nr) + ".html"));
QTRY_COMPARE(loadFinishedSpy->count(), 1);
+ loadFinishedSpy->clear();
}
public Q_SLOTS:
@@ -161,7 +162,7 @@ void tst_QWebEngineHistory::forward()
while (hist->canGoBack()) {
hist->back();
histBackCount++;
- QTRY_COMPARE(loadFinishedSpy->count(), histBackCount+1);
+ QTRY_COMPARE(loadFinishedSpy->count(), histBackCount);
}
QSignalSpy titleChangedSpy(page, SIGNAL(titleChanged(const QString&)));
@@ -198,15 +199,15 @@ void tst_QWebEngineHistory::goToItem()
QWebEngineHistoryItem current = hist->currentItem();
hist->back();
- QTRY_COMPARE(loadFinishedSpy->count(), 2);
+ QTRY_COMPARE(loadFinishedSpy->count(), 1);
hist->back();
- QTRY_COMPARE(loadFinishedSpy->count(), 3);
+ QTRY_COMPARE(loadFinishedSpy->count(), 2);
QVERIFY(hist->currentItem().title() != current.title());
hist->goToItem(current);
- QTRY_COMPARE(loadFinishedSpy->count(), 3);
+ QTRY_COMPARE(loadFinishedSpy->count(), 2);
QTRY_COMPARE(hist->currentItem().title(), current.title());
}
@@ -229,10 +230,10 @@ void tst_QWebEngineHistory::items()
void tst_QWebEngineHistory::backForwardItems()
{
hist->back();
- QTRY_COMPARE(loadFinishedSpy->count(), 2);
+ QTRY_COMPARE(loadFinishedSpy->count(), 1);
hist->back();
- QTRY_COMPARE(loadFinishedSpy->count(), 3);
+ QTRY_COMPARE(loadFinishedSpy->count(), 2);
QTRY_COMPARE(hist->items().size(), 5);
QTRY_COMPARE(hist->backItems(100).size(), 2);
@@ -282,16 +283,17 @@ void tst_QWebEngineHistory::serialize_2()
// Force a "same document" navigation.
page->load(page->url().toString() + QLatin1String("#dummyAnchor"));
- QTRY_COMPARE(loadFinishedSpy->count(), 1);
+ // "same document" navigation doesn't trigger loadFinished signal.
+ QTRY_COMPARE(evaluateJavaScriptSync(page, "location.hash").toString(), QStringLiteral("#dummyAnchor"));
int initialCurrentIndex = hist->currentItemIndex();
hist->back();
- QTRY_COMPARE(loadFinishedSpy->count(), 2);
+ QTRY_VERIFY(evaluateJavaScriptSync(page, "location.hash").toString().isEmpty());
hist->back();
- QTRY_COMPARE(loadFinishedSpy->count(), 3);
+ QTRY_COMPARE(loadFinishedSpy->count(), 1);
hist->back();
- QTRY_COMPARE(loadFinishedSpy->count(), 4);
+ QTRY_COMPARE(loadFinishedSpy->count(), 2);
//check if current index was changed (make sure that it is not last item)
QVERIFY(hist->currentItemIndex() != initialCurrentIndex);
//save current index
@@ -302,17 +304,17 @@ void tst_QWebEngineHistory::serialize_2()
load >> *hist;
QVERIFY(load.status() == QDataStream::Ok);
// Restoring the history will trigger a load.
- QTRY_COMPARE(loadFinishedSpy->count(), 5);
+ QTRY_COMPARE(loadFinishedSpy->count(), 3);
//check current index
QTRY_COMPARE(hist->currentItemIndex(), oldCurrentIndex);
hist->forward();
- QTRY_COMPARE(loadFinishedSpy->count(), 6);
+ QTRY_COMPARE(loadFinishedSpy->count(), 4);
hist->forward();
- QTRY_COMPARE(loadFinishedSpy->count(), 7);
+ QTRY_COMPARE(loadFinishedSpy->count(), 5);
hist->forward();
- QTRY_COMPARE(loadFinishedSpy->count(), 8);
+ QTRY_COMPARE(loadFinishedSpy->count(), 6);
QTRY_COMPARE(hist->currentItemIndex(), initialCurrentIndex);
}
diff --git a/tests/auto/widgets/qwebenginehistoryinterface/tst_qwebenginehistoryinterface.cpp b/tests/auto/widgets/qwebenginehistoryinterface/tst_qwebenginehistoryinterface.cpp
deleted file mode 100644
index 4666d1ba4..000000000
--- a/tests/auto/widgets/qwebenginehistoryinterface/tst_qwebenginehistoryinterface.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- Copyright (C) 2008 Holger Hans Peter Freyther
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-
-#include <QtTest/QtTest>
-
-#include <qwebenginepage.h>
-#include <qwebengineview.h>
-#if defined(QWEBENGINEHISTORYINTERFACE)
-#include <qwebenginehistoryinterface.h>
-#endif
-#include <QDebug>
-
-class tst_QWebEngineHistoryInterface : public QObject
-{
- Q_OBJECT
-
-public:
- tst_QWebEngineHistoryInterface();
- virtual ~tst_QWebEngineHistoryInterface();
-
-public Q_SLOTS:
- void initTestCase();
- void init();
- void cleanup();
-
-private Q_SLOTS:
- void visitedLinks();
-
-private:
-
-
-private:
- QWebEngineView* m_view;
- QWebEnginePage* m_page;
-};
-
-tst_QWebEngineHistoryInterface::tst_QWebEngineHistoryInterface()
-{
-}
-
-tst_QWebEngineHistoryInterface::~tst_QWebEngineHistoryInterface()
-{
-}
-
-void tst_QWebEngineHistoryInterface::initTestCase()
-{
-}
-
-void tst_QWebEngineHistoryInterface::init()
-{
- m_view = new QWebEngineView();
- m_page = m_view->page();
-}
-
-void tst_QWebEngineHistoryInterface::cleanup()
-{
- delete m_view;
-}
-
-#if defined(QWEBENGINEHISTORYINTERFACE)
-class FakeHistoryImplementation : public QWebEngineHistoryInterface {
-public:
- void addHistoryEntry(const QString&) {}
- bool historyContains(const QString& url) const {
- return url == QLatin1String("http://www.trolltech.com/");
- }
-};
-#endif
-
-/*
- * Test that visited links are properly colored. http://www.trolltech.com is marked
- * as visited, so the below website should have exactly one element in the a:visited
- * state.
- */
-void tst_QWebEngineHistoryInterface::visitedLinks()
-{
-#if !defined(QWEBENGINEELEMENT)
- QSKIP("QWEBENGINEELEMENT");
-#else
- QWebEngineHistoryInterface::setDefaultInterface(new FakeHistoryImplementation);
- m_view->setHtml("<html><style>:link{color:green}:visited{color:red}</style><body><a href='http://www.trolltech.com' id='vlink'>Trolltech</a></body></html>");
- QWebEngineElement anchor = m_view->page()->mainFrame()->findFirstElement("a[id=vlink]");
- QString linkColor = anchor.styleProperty("color", QWebEngineElement::ComputedStyle);
- QCOMPARE(linkColor, QString::fromLatin1("rgb(255, 0, 0)"));
-#endif
-}
-
-QTEST_MAIN(tst_QWebEngineHistoryInterface)
-#include "tst_qwebenginehistoryinterface.moc"
diff --git a/tests/auto/widgets/qwebenginehistoryinterface/qwebenginehistoryinterface.pro b/tests/auto/widgets/qwebengineshutdown/qwebengineshutdown.pro
index e99c7f493..e99c7f493 100644
--- a/tests/auto/widgets/qwebenginehistoryinterface/qwebenginehistoryinterface.pro
+++ b/tests/auto/widgets/qwebengineshutdown/qwebengineshutdown.pro
diff --git a/tests/auto/widgets/qwebengineshutdown/tst_qwebengineshutdown.cpp b/tests/auto/widgets/qwebengineshutdown/tst_qwebengineshutdown.cpp
new file mode 100644
index 000000000..d757e0d60
--- /dev/null
+++ b/tests/auto/widgets/qwebengineshutdown/tst_qwebengineshutdown.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <qwebenginepage.h>
+#include <qwebengineview.h>
+#include <QDebug>
+
+class tst_QWebEngineShutdown : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QWebEngineShutdown();
+ virtual ~tst_QWebEngineShutdown();
+
+public Q_SLOTS:
+ void init();
+ void cleanup();
+
+private Q_SLOTS:
+ void dummyTest();
+
+private:
+
+
+private:
+ QWebEngineView* m_view;
+ QWebEnginePage* m_page;
+};
+
+tst_QWebEngineShutdown::tst_QWebEngineShutdown()
+{
+}
+
+tst_QWebEngineShutdown::~tst_QWebEngineShutdown()
+{
+}
+
+void tst_QWebEngineShutdown::init()
+{
+ m_view = new QWebEngineView();
+ m_page = m_view->page();
+}
+
+void tst_QWebEngineShutdown::cleanup()
+{
+ delete m_view;
+}
+
+void tst_QWebEngineShutdown::dummyTest()
+{
+ QVERIFY(m_view);
+}
+
+QTEST_MAIN(tst_QWebEngineShutdown)
+#include "tst_qwebengineshutdown.moc"
diff --git a/tests/auto/widgets/qwebengineview/BLACKLIST b/tests/auto/widgets/qwebengineview/BLACKLIST
index 0a909d0f6..0da1000a8 100644
--- a/tests/auto/widgets/qwebengineview/BLACKLIST
+++ b/tests/auto/widgets/qwebengineview/BLACKLIST
@@ -1,2 +1,8 @@
[doNotSendMouseKeyboardEventsWhenDisabled]
windows
+
+[mouseLeave]
+*
+
+[textSelectionOutOfInputField]
+windows
diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
index 48b12e18b..38ec2af70 100644
--- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
+++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
@@ -182,6 +182,8 @@ private Q_SLOTS:
void noContextMenu();
void contextMenu_data();
void contextMenu();
+ void webUIURLs_data();
+ void webUIURLs();
};
// This will be called before the first test function is executed.
@@ -2478,5 +2480,93 @@ void tst_QWebEngineView::mouseLeave()
QTRY_COMPARE(innerText(), QStringLiteral("Mouse OUT"));
}
+void tst_QWebEngineView::webUIURLs_data()
+{
+ QTest::addColumn<QUrl>("url");
+ QTest::addColumn<bool>("supported");
+ QTest::newRow("about") << QUrl("chrome://about") << false;
+ QTest::newRow("accessibility") << QUrl("chrome://accessibility") << false;
+ QTest::newRow("appcache-internals") << QUrl("chrome://appcache-internals") << true;
+ QTest::newRow("apps") << QUrl("chrome://apps") << false;
+ QTest::newRow("blob-internals") << QUrl("chrome://blob-internals") << true;
+ QTest::newRow("bluetooth-internals") << QUrl("chrome://bluetooth-internals") << false;
+ QTest::newRow("bookmarks") << QUrl("chrome://bookmarks") << false;
+ QTest::newRow("cache") << QUrl("chrome://cache") << false;
+ QTest::newRow("chrome") << QUrl("chrome://chrome") << false;
+ QTest::newRow("chrome-urls") << QUrl("chrome://chrome-urls") << false;
+ QTest::newRow("components") << QUrl("chrome://components") << false;
+ QTest::newRow("crashes") << QUrl("chrome://crashes") << false;
+ QTest::newRow("credits") << QUrl("chrome://credits") << false;
+ QTest::newRow("device-log") << QUrl("chrome://device-log") << false;
+ QTest::newRow("devices") << QUrl("chrome://devices") << false;
+ QTest::newRow("dino") << QUrl("chrome://dino") << false; // It works but this is an error page
+ QTest::newRow("dns") << QUrl("chrome://dns") << false;
+ QTest::newRow("downloads") << QUrl("chrome://downloads") << false;
+ QTest::newRow("extensions") << QUrl("chrome://extensions") << false;
+ QTest::newRow("flags") << QUrl("chrome://flags") << false;
+ QTest::newRow("flash") << QUrl("chrome://flash") << false;
+ QTest::newRow("gcm-internals") << QUrl("chrome://gcm-internals") << false;
+ QTest::newRow("gpu") << QUrl("chrome://gpu") << true;
+ QTest::newRow("help") << QUrl("chrome://help") << false;
+ QTest::newRow("histograms") << QUrl("chrome://histograms") << true;
+ QTest::newRow("indexeddb-internals") << QUrl("chrome://indexeddb-internals") << true;
+ QTest::newRow("inspect") << QUrl("chrome://inspect") << false;
+ QTest::newRow("invalidations") << QUrl("chrome://invalidations") << false;
+ QTest::newRow("linux-proxy-config") << QUrl("chrome://linux-proxy-config") << false;
+ QTest::newRow("local-state") << QUrl("chrome://local-state") << false;
+ QTest::newRow("media-internals") << QUrl("chrome://media-internals") << true;
+ QTest::newRow("net-export") << QUrl("chrome://net-export") << false;
+ QTest::newRow("net-internals") << QUrl("chrome://net-internals") << false;
+ QTest::newRow("network-error") << QUrl("chrome://network-error") << false;
+ QTest::newRow("network-errors") << QUrl("chrome://network-errors") << true;
+ QTest::newRow("newtab") << QUrl("chrome://newtab") << false;
+ QTest::newRow("ntp-tiles-internals") << QUrl("chrome://ntp-tiles-internals") << false;
+ QTest::newRow("omnibox") << QUrl("chrome://omnibox") << false;
+ QTest::newRow("password-manager-internals") << QUrl("chrome://password-manager-internals") << false;
+ QTest::newRow("policy") << QUrl("chrome://policy") << false;
+ QTest::newRow("predictors") << QUrl("chrome://predictors") << false;
+ QTest::newRow("print") << QUrl("chrome://print") << false;
+ QTest::newRow("profiler") << QUrl("chrome://profiler") << false;
+ QTest::newRow("quota-internals") << QUrl("chrome://quota-internals") << true;
+ QTest::newRow("safe-browsing") << QUrl("chrome://safe-browsing") << false;
+#ifdef Q_OS_LINUX
+ QTest::newRow("sandbox") << QUrl("chrome://sandbox") << true;
+#else
+ QTest::newRow("sandbox") << QUrl("chrome://sandbox") << false;
+#endif
+ QTest::newRow("serviceworker-internals") << QUrl("chrome://serviceworker-internals") << true;
+ QTest::newRow("settings") << QUrl("chrome://settings") << false;
+ QTest::newRow("signin-internals") << QUrl("chrome://signin-internals") << false;
+ QTest::newRow("site-engagement") << QUrl("chrome://site-engagement") << false;
+ QTest::newRow("suggestions") << QUrl("chrome://suggestions") << false;
+ QTest::newRow("supervised-user-internals") << QUrl("chrome://supervised-user-internals") << false;
+ QTest::newRow("sync-internals") << QUrl("chrome://sync-internals") << false;
+ QTest::newRow("system") << QUrl("chrome://system") << false;
+ QTest::newRow("taskscheduler-internals") << QUrl("chrome://taskscheduler-internals") << true;
+ QTest::newRow("terms") << QUrl("chrome://terms") << false;
+ QTest::newRow("thumbnails") << QUrl("chrome://thumbnails") << false;
+ QTest::newRow("tracing") << QUrl("chrome://tracing") << false;
+ QTest::newRow("translate-internals") << QUrl("chrome://translate-internals") << false;
+ QTest::newRow("usb-internals") << QUrl("chrome://usb-internals") << false;
+ QTest::newRow("user-actions") << QUrl("chrome://user-actions") << false;
+ QTest::newRow("version") << QUrl("chrome://version") << false;
+ QTest::newRow("view-http-cache") << QUrl("chrome://view-http-cache") << true;
+ QTest::newRow("webrtc-internals") << QUrl("chrome://webrtc-internals") << true;
+ QTest::newRow("webrtc-logs") << QUrl("chrome://webrtc-logs") << false;
+}
+
+void tst_QWebEngineView::webUIURLs()
+{
+ QFETCH(QUrl, url);
+ QFETCH(bool, supported);
+
+ QWebEngineView view;
+ view.settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false);
+ QSignalSpy loadFinishedSpy(&view, SIGNAL(loadFinished(bool)));
+ view.load(url);
+ QVERIFY(loadFinishedSpy.wait());
+ QCOMPARE(loadFinishedSpy.takeFirst().at(0).toBool(), supported);
+}
+
QTEST_MAIN(tst_QWebEngineView)
#include "tst_qwebengineview.moc"
diff --git a/tests/auto/widgets/widgets.pro b/tests/auto/widgets/widgets.pro
index 28f8f56c1..ba1b254f4 100644
--- a/tests/auto/widgets/widgets.pro
+++ b/tests/auto/widgets/widgets.pro
@@ -8,12 +8,12 @@ SUBDIRS += \
qwebenginefaviconmanager \
qwebenginepage \
qwebenginehistory \
- qwebenginehistoryinterface \
qwebengineinspector \
qwebengineprofile \
qwebengineschemes \
qwebenginescript \
qwebenginesettings \
+ qwebengineshutdown \
qwebengineview
qtConfig(accessibility) {