mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
Fix failing tests after removing loadfinished hack
This commit is contained in:
parent
c8953b63d8
commit
f064713296
@ -41,21 +41,17 @@ void SiteSettingsTest::webAttributeTest()
|
|||||||
SiteSettingsManager *siteSettings = mApp->siteSettingsManager();
|
SiteSettingsManager *siteSettings = mApp->siteSettingsManager();
|
||||||
siteSettings->setOption(QWebEngineSettings::AutoLoadImages, QUrl(QSL("https://www.falkon.org/")), SiteSettingsManager::Deny);
|
siteSettings->setOption(QWebEngineSettings::AutoLoadImages, QUrl(QSL("https://www.falkon.org/")), SiteSettingsManager::Deny);
|
||||||
siteSettings->setOption(QWebEngineSettings::JavascriptEnabled, QUrl(QSL("https://kde.org/")), SiteSettingsManager::Deny);
|
siteSettings->setOption(QWebEngineSettings::JavascriptEnabled, QUrl(QSL("https://kde.org/")), SiteSettingsManager::Deny);
|
||||||
siteSettings->setOption(QWebEngineSettings::LocalStorageEnabled, QUrl(QSL("https://store.falkon.org/")), SiteSettingsManager::Deny);
|
|
||||||
siteSettings->setOption(QWebEngineSettings::PlaybackRequiresUserGesture, QUrl(QSL("https://planet.kde.org/")), SiteSettingsManager::Allow);
|
siteSettings->setOption(QWebEngineSettings::PlaybackRequiresUserGesture, QUrl(QSL("https://planet.kde.org/")), SiteSettingsManager::Allow);
|
||||||
|
|
||||||
|
|
||||||
WebTab tab;
|
checkInternalPage(QUrl(QSL("falkon:start")));
|
||||||
|
|
||||||
checkInternalPage(&tab, QUrl(QSL("falkon:start")));
|
checkExternalPage(QUrl(QSL("https://www.falkon.org/")));
|
||||||
|
checkExternalPage(QUrl(QSL("https://kde.org/")));
|
||||||
|
|
||||||
checkExternalPage(&tab, QUrl(QSL("https://www.falkon.org/")));
|
checkInternalPage(QUrl(QSL("falkon:about")));
|
||||||
checkExternalPage(&tab, QUrl(QSL("https://kde.org/")));
|
|
||||||
checkExternalPage(&tab, QUrl(QSL("https://store.falkon.org/")));
|
|
||||||
|
|
||||||
checkInternalPage(&tab, QUrl(QSL("falkon:about")));
|
checkExternalPage(QUrl(QSL("https://planet.kde.org/")));
|
||||||
|
|
||||||
checkExternalPage(&tab, QUrl(QSL("https://planet.kde.org/")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SiteSettingsTest::checkWebAttributes(WebPage *page, QHash<QWebEngineSettings::WebAttribute, bool> webAttributes)
|
bool SiteSettingsTest::checkWebAttributes(WebPage *page, QHash<QWebEngineSettings::WebAttribute, bool> webAttributes)
|
||||||
@ -69,8 +65,9 @@ bool SiteSettingsTest::checkWebAttributes(WebPage *page, QHash<QWebEngineSetting
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SiteSettingsTest::checkInternalPage(WebTab *tab, QUrl url)
|
void SiteSettingsTest::checkInternalPage(QUrl url)
|
||||||
{
|
{
|
||||||
|
WebTab tab;
|
||||||
QMap<QWebEngineSettings::WebAttribute, bool> internalWebAttributes = {
|
QMap<QWebEngineSettings::WebAttribute, bool> internalWebAttributes = {
|
||||||
{QWebEngineSettings::AutoLoadImages, true}
|
{QWebEngineSettings::AutoLoadImages, true}
|
||||||
,{QWebEngineSettings::JavascriptEnabled, true}
|
,{QWebEngineSettings::JavascriptEnabled, true}
|
||||||
@ -86,25 +83,26 @@ void SiteSettingsTest::checkInternalPage(WebTab *tab, QUrl url)
|
|||||||
,{QWebEngineSettings::WebRTCPublicInterfacesOnly, false}
|
,{QWebEngineSettings::WebRTCPublicInterfacesOnly, false}
|
||||||
};
|
};
|
||||||
|
|
||||||
QSignalSpy spy(tab, SIGNAL(loadingChanged(bool)));
|
QSignalSpy spy(tab.webView(), &WebView::loadFinished);
|
||||||
tab->load(url);
|
tab.load(url);
|
||||||
QTRY_COMPARE(spy.count(), 3);
|
QTRY_COMPARE(spy.count(), 1);
|
||||||
|
|
||||||
auto *page = tab->webView()->page();
|
auto *page = tab.webView()->page();
|
||||||
for (auto it = internalWebAttributes.begin(); it != internalWebAttributes.end(); ++it) {
|
for (auto it = internalWebAttributes.begin(); it != internalWebAttributes.end(); ++it) {
|
||||||
QCOMPARE(page->settings()->testAttribute(it.key()), it.value());
|
QCOMPARE(page->settings()->testAttribute(it.key()), it.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SiteSettingsTest::checkExternalPage(WebTab *tab, QUrl url)
|
void SiteSettingsTest::checkExternalPage(QUrl url)
|
||||||
{
|
{
|
||||||
|
WebTab tab;
|
||||||
SiteSettingsManager *siteSettings = mApp->siteSettingsManager();
|
SiteSettingsManager *siteSettings = mApp->siteSettingsManager();
|
||||||
|
|
||||||
QSignalSpy spy(tab, SIGNAL(loadingChanged(bool)));
|
QSignalSpy spy(tab.webView(), &WebView::loadFinished);
|
||||||
tab->load(url);
|
tab.load(url);
|
||||||
QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 3, 20000);
|
QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 20000);
|
||||||
|
|
||||||
auto *page = tab->webView()->page();
|
auto *page = tab.webView()->page();
|
||||||
QCOMPARE(checkWebAttributes(page, siteSettings->getWebAttributes(url)), true);
|
QCOMPARE(checkWebAttributes(page, siteSettings->getWebAttributes(url)), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@ private Q_SLOTS:
|
|||||||
private:
|
private:
|
||||||
bool checkWebAttributes(WebPage *page, QHash<QWebEngineSettings::WebAttribute, bool> webAttributes);
|
bool checkWebAttributes(WebPage *page, QHash<QWebEngineSettings::WebAttribute, bool> webAttributes);
|
||||||
|
|
||||||
void checkInternalPage(WebTab *tab, QUrl url);
|
void checkInternalPage(QUrl url);
|
||||||
void checkExternalPage(WebTab *tab, QUrl url);
|
void checkExternalPage(QUrl url);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SITESETTINGSTEST_H
|
#endif // SITESETTINGSTEST_H
|
||||||
|
@ -81,10 +81,7 @@ void WebViewTest::loadSignalsChangePageTest()
|
|||||||
auto *page2 = new WebPage;
|
auto *page2 = new WebPage;
|
||||||
view.setPage(page2);
|
view.setPage(page2);
|
||||||
|
|
||||||
// WebPage: Workaround for broken load started/finished signals in QtWebEngine 5.10
|
QTRY_COMPARE(loadFinishedSpy.count(), 1);
|
||||||
const int loadFinishedEmitCount = qstrncmp(qVersion(), "5.11.", 5) == 0 ? 1 : 2;
|
|
||||||
|
|
||||||
QTRY_COMPARE(loadFinishedSpy.count(), loadFinishedEmitCount);
|
|
||||||
QCOMPARE(loadStartedSpy.count(), 0);
|
QCOMPARE(loadStartedSpy.count(), 0);
|
||||||
loadFinishedSpy.clear();
|
loadFinishedSpy.clear();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user