diff options
Diffstat (limited to 'tests/widgets/qwebenginehistory/tst_qwebenginehistory.cpp')
-rw-r--r-- | tests/widgets/qwebenginehistory/tst_qwebenginehistory.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/widgets/qwebenginehistory/tst_qwebenginehistory.cpp b/tests/widgets/qwebenginehistory/tst_qwebenginehistory.cpp index 60742288b..536df75e3 100644 --- a/tests/widgets/qwebenginehistory/tst_qwebenginehistory.cpp +++ b/tests/widgets/qwebenginehistory/tst_qwebenginehistory.cpp @@ -106,7 +106,11 @@ void tst_QWebEngineHistory::cleanup() */ void tst_QWebEngineHistory::title() { +#if !defined(QWEBENGINEHISTORY) + QSKIP("QWEBENGINEHISTORY"); +#else QCOMPARE(hist->currentItem().title(), QString("page5")); +#endif } /** @@ -114,7 +118,11 @@ void tst_QWebEngineHistory::title() */ void tst_QWebEngineHistory::count() { +#if !defined(QWEBENGINEHISTORY) + QSKIP("QWEBENGINEHISTORY"); +#else QCOMPARE(hist->count(), histsize); +#endif } /** @@ -122,6 +130,9 @@ void tst_QWebEngineHistory::count() */ void tst_QWebEngineHistory::back() { +#if !defined(QWEBENGINEPAGE_TOPLAINTEXT) + QSKIP("QWEBENGINEPAGE_TOPLAINTEXT"); +#else for (int i = histsize;i > 1;i--) { QCOMPARE(page->toPlainText(), QString("page") + QString::number(i)); hist->back(); @@ -130,6 +141,7 @@ void tst_QWebEngineHistory::back() //try one more time (too many). crash test hist->back(); QCOMPARE(page->toPlainText(), QString("page1")); +#endif } /** @@ -137,6 +149,9 @@ void tst_QWebEngineHistory::back() */ void tst_QWebEngineHistory::forward() { +#if !defined(QWEBENGINEPAGE_TOPLAINTEXT) + QSKIP("QWEBENGINEPAGE_TOPLAINTEXT"); +#else //rewind history :-) while (hist->canGoBack()) { hist->back(); @@ -151,6 +166,7 @@ void tst_QWebEngineHistory::forward() //try one more time (too many). crash test hist->forward(); QCOMPARE(page->toPlainText(), QString("page") + QString::number(histsize)); +#endif } /** @@ -158,6 +174,9 @@ void tst_QWebEngineHistory::forward() */ void tst_QWebEngineHistory::itemAt() { +#if !defined(QWEBENGINEHISTORY) + QSKIP("QWEBENGINEHISTORY"); +#else for (int i = 1;i < histsize;i++) { QCOMPARE(hist->itemAt(i - 1).title(), QString("page") + QString::number(i)); QVERIFY(hist->itemAt(i - 1).isValid()); @@ -165,6 +184,7 @@ void tst_QWebEngineHistory::itemAt() //check out of range values QVERIFY(!hist->itemAt(-1).isValid()); QVERIFY(!hist->itemAt(histsize).isValid()); +#endif } /** @@ -172,6 +192,9 @@ void tst_QWebEngineHistory::itemAt() */ void tst_QWebEngineHistory::goToItem() { +#if !defined(QWEBENGINEHISTORY) + QSKIP("QWEBENGINEHISTORY"); +#else QWebEngineHistoryItem current = hist->currentItem(); hist->back(); loadFinishedBarrier->ensureSignalEmitted(); @@ -181,6 +204,7 @@ void tst_QWebEngineHistory::goToItem() hist->goToItem(current); loadFinishedBarrier->ensureSignalEmitted(); QCOMPARE(hist->currentItem().title(), current.title()); +#endif } /** @@ -188,6 +212,9 @@ void tst_QWebEngineHistory::goToItem() */ void tst_QWebEngineHistory::items() { +#if !defined(QWEBENGINEHISTORY) + QSKIP("QWEBENGINEHISTORY"); +#else QList<QWebEngineHistoryItem> items = hist->items(); //check count QCOMPARE(histsize, items.count()); @@ -196,6 +223,7 @@ void tst_QWebEngineHistory::items() for (int i = 1;i <= histsize;i++) { QCOMPARE(items.at(i - 1).title(), QString("page") + QString::number(i)); } +#endif } /** @@ -204,6 +232,9 @@ void tst_QWebEngineHistory::items() */ void tst_QWebEngineHistory::serialize_1() { +#if !defined(QWEBENGINEHISTORY) + QSKIP("QWEBENGINEHISTORY"); +#else QByteArray tmp; //buffer QDataStream save(&tmp, QIODevice::WriteOnly); //here data will be saved QDataStream load(&tmp, QIODevice::ReadOnly); //from here data will be loaded @@ -225,6 +256,7 @@ void tst_QWebEngineHistory::serialize_1() for (int i = 1;i <= histsize;i++) { QCOMPARE(items.at(i - 1).title(), QString("page") + QString::number(i)); } +#endif } /** @@ -233,6 +265,9 @@ void tst_QWebEngineHistory::serialize_1() */ void tst_QWebEngineHistory::serialize_2() { +#if !defined(QWEBENGINEHISTORY) + QSKIP("QWEBENGINEHISTORY"); +#else QByteArray tmp; //buffer QDataStream save(&tmp, QIODevice::WriteOnly); //here data will be saved QDataStream load(&tmp, QIODevice::ReadOnly); //from here data will be loaded @@ -268,6 +303,7 @@ void tst_QWebEngineHistory::serialize_2() hist->forward(); loadFinishedBarrier->ensureSignalEmitted(); QCOMPARE(hist->currentItemIndex(), initialCurrentIndex); +#endif } /** @@ -276,6 +312,9 @@ void tst_QWebEngineHistory::serialize_2() */ void tst_QWebEngineHistory::serialize_3() { +#if !defined(QWEBENGINEHISTORY) + QSKIP("QWEBENGINEHISTORY"); +#else QByteArray tmp; //buffer QDataStream save(&tmp, QIODevice::WriteOnly); //here data will be saved QDataStream load(&tmp, QIODevice::ReadOnly); //from here data will be loaded @@ -309,8 +348,10 @@ void tst_QWebEngineHistory::serialize_3() //Check if all data was read QVERIFY(load.atEnd()); +#endif } +#if defined(QWEBENGINEHISTORY) static void saveHistory(QWebEngineHistory* history, QByteArray* in) { in->clear(); @@ -323,19 +364,27 @@ static void restoreHistory(QWebEngineHistory* history, QByteArray* out) QDataStream load(out, QIODevice::ReadOnly); load >> *history; } +#endif void tst_QWebEngineHistory::saveAndRestore_crash_1() { +#if !defined(QWEBENGINEHISTORY) + QSKIP("QWEBENGINEHISTORY"); +#else QByteArray buffer; saveHistory(hist, &buffer); for (unsigned i = 0; i < 5; i++) { restoreHistory(hist, &buffer); saveHistory(hist, &buffer); } +#endif } void tst_QWebEngineHistory::saveAndRestore_crash_2() { +#if !defined(QWEBENGINEHISTORY) + QSKIP("QWEBENGINEHISTORY"); +#else QByteArray buffer; saveHistory(hist, &buffer); QWebEnginePage* page2 = new QWebEnginePage(this); @@ -345,10 +394,14 @@ void tst_QWebEngineHistory::saveAndRestore_crash_2() saveHistory(hist2, &buffer); } delete page2; +#endif } void tst_QWebEngineHistory::saveAndRestore_crash_3() { +#if !defined(QWEBENGINEHISTORY) + QSKIP("QWEBENGINEHISTORY"); +#else QByteArray buffer; saveHistory(hist, &buffer); QWebEnginePage* page2 = new QWebEnginePage(this); @@ -364,10 +417,14 @@ void tst_QWebEngineHistory::saveAndRestore_crash_3() hist2->clear(); } delete page2; +#endif } void tst_QWebEngineHistory::saveAndRestore_crash_4() { +#if !defined(QWEBENGINEHISTORY) + QSKIP("QWEBENGINEHISTORY"); +#else QByteArray buffer; saveHistory(hist, &buffer); @@ -385,6 +442,7 @@ void tst_QWebEngineHistory::saveAndRestore_crash_4() delete page2; // Give some time for the PageCache cleanup 0-timer to fire. QTest::qWait(50); +#endif } void tst_QWebEngineHistory::popPushState_data() @@ -400,15 +458,22 @@ void tst_QWebEngineHistory::popPushState_data() /** Crash test, WebKit bug 38840 (https://bugs.webengine.org/show_bug.cgi?id=38840) */ void tst_QWebEngineHistory::popPushState() { +#if !defined(QWEBENGINEPAGE_EVALUATEJAVASCRIPT) + QSKIP("QWEBENGINEPAGE_EVALUATEJAVASCRIPT"); +#else QFETCH(QString, script); QWebEnginePage page; page.setHtml("<html><body>long live Qt!</body></html>"); page.evaluateJavaScript(script); +#endif } /** ::clear */ void tst_QWebEngineHistory::clear() { +#if !defined(QWEBENGINEHISTORY) + QSKIP("QWEBENGINEHISTORY"); +#else QByteArray buffer; QAction* actionBack = page->action(QWebEnginePage::Back); @@ -425,6 +490,7 @@ void tst_QWebEngineHistory::clear() hist2->clear(); QVERIFY(hist2->count() == 0); // Do not change anything. delete page2; +#endif } // static void dumpCurrentVersion(QWebEngineHistory* history) @@ -442,6 +508,9 @@ void tst_QWebEngineHistory::clear() void tst_QWebEngineHistory::restoreIncompatibleVersion1() { +#if !defined(QWEBENGINEHISTORY) + QSKIP("QWEBENGINEHISTORY"); +#else // Uncomment this code to generate a dump similar to the one below with the current stream version. // dumpCurrentVersion(hist); static const unsigned char version1Dump[] = { @@ -519,6 +588,7 @@ void tst_QWebEngineHistory::restoreIncompatibleVersion1() QVERIFY(!hist->canGoBack()); QVERIFY(!hist->canGoForward()); QVERIFY(stream.status() == QDataStream::ReadCorruptData); +#endif } QTEST_MAIN(tst_QWebEngineHistory) |