mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-19 10:16:34 +01:00
WebTabTest: Add loadNotRestoredTabTest
This commit is contained in:
parent
c67a32a845
commit
1ef1455957
@ -30,3 +30,19 @@
|
||||
Test test; \
|
||||
return QTest::qExec(&test, argc, argv); \
|
||||
}
|
||||
|
||||
bool waitForLoadfinished(QObject *object)
|
||||
{
|
||||
if (qstrcmp(object->metaObject()->className(), "WebTab") == 0) {
|
||||
QSignalSpy spy(object, SIGNAL(loadingChanged(bool)));
|
||||
while (spy.wait()) {
|
||||
if (spy.count() > 0 && spy.at(0).at(0).toBool()) {
|
||||
return true;
|
||||
}
|
||||
spy.clear();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
qDebug() << "Unsupported object" << object;
|
||||
return false;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/autotests">
|
||||
<file>data/basic_page.html</file>
|
||||
<file>data/basic_page2.html</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
8
autotests/data/basic_page2.html
Normal file
8
autotests/data/basic_page2.html
Normal file
@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title> Basic Page 2 </title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello World 2</h1>
|
||||
</body>
|
||||
</html>
|
@ -19,9 +19,12 @@
|
||||
#include "autotests.h"
|
||||
#include "webtab.h"
|
||||
#include "tabwidget.h"
|
||||
#include "tabbedwebview.h"
|
||||
#include "mainapplication.h"
|
||||
#include "browserwindow.h"
|
||||
|
||||
#include <QWebEngineHistory>
|
||||
|
||||
void WebTabTest::initTestCase()
|
||||
{
|
||||
}
|
||||
@ -246,6 +249,28 @@ void WebTabTest::moveTabTest()
|
||||
tab4->moveTab(5);
|
||||
tab4->moveTab(6);
|
||||
QCOMPARE(movedSpy.count(), 0);
|
||||
|
||||
delete w;
|
||||
}
|
||||
|
||||
void WebTabTest::loadNotRestoredTabTest()
|
||||
{
|
||||
WebTab tab;
|
||||
|
||||
tab.load(QUrl("qrc:autotests/data/basic_page.html"));
|
||||
QVERIFY(waitForLoadfinished(&tab));
|
||||
QTRY_COMPARE(tab.webView()->history()->count(), 1);
|
||||
|
||||
tab.unload();
|
||||
QVERIFY(!tab.isRestored());
|
||||
|
||||
tab.load(QUrl("qrc:autotests/data/basic_page2.html"));
|
||||
QVERIFY(waitForLoadfinished(&tab));
|
||||
QTRY_COMPARE(tab.webView()->history()->count(), 2);
|
||||
|
||||
QCOMPARE(tab.url(), QUrl("qrc:autotests/data/basic_page2.html"));
|
||||
QCOMPARE(tab.webView()->history()->currentItem().url(), QUrl("qrc:autotests/data/basic_page2.html"));
|
||||
QCOMPARE(tab.webView()->history()->backItem().url(), QUrl("qrc:autotests/data/basic_page.html"));
|
||||
}
|
||||
|
||||
FALKONTEST_MAIN(WebTabTest)
|
||||
|
@ -31,4 +31,5 @@ private slots:
|
||||
void parentChildTabsTest();
|
||||
void prependChildTabsTest();
|
||||
void moveTabTest();
|
||||
void loadNotRestoredTabTest();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user