Changeset 91669 in webkit
- Timestamp:
- Jul 25, 2011 8:51:16 AM (13 years ago)
- Location:
- trunk/Source/WebKit/qt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/qt/ChangeLog
r91335 r91669 1 2011-07-25 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> 2 3 [Qt] Add more tests to cover the behavior of loadFinished() signal 4 https://bugs.webkit.org/show_bug.cgi?id=63490 5 6 Reviewed by Benjamin Poulain. 7 8 * tests/qwebframe/tst_qwebframe.cpp: 9 (FakeReply::FakeReply): 10 (FakeNetworkManager::createRequest): Add a fake reply that gives 404 error code. 11 12 (tst_QWebFrame::loadFinishedAfterNotFoundError): Verify that we get loadFinished(false) 13 after a 404 error without contents. 14 15 * tests/qwebpage/tst_qwebpage.cpp: 16 (tst_QWebPage::errorPageExtensionLoadFinished): Verify if the argument of loadFinished() 17 is true when we use error page extension to produce our own error pages. 18 1 19 2011-07-19 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> 2 20 -
trunk/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
r90403 r91669 660 660 void setUrlThenLoads_data(); 661 661 void setUrlThenLoads(); 662 void loadFinishedAfterNotFoundError(); 662 663 663 664 private: … … 2303 2304 2304 2305 public: 2306 static const QUrl urlFor404ErrorWithoutContents; 2307 2305 2308 FakeReply(const QNetworkRequest& request, QObject* parent = 0) 2306 2309 : QNetworkReply(parent) … … 2322 2325 setError(QNetworkReply::HostNotFoundError, tr("Invalid URL")); 2323 2326 QTimer::singleShot(0, this, SLOT(continueError())); 2327 } else if (request.url() == FakeReply::urlFor404ErrorWithoutContents) { 2328 setError(QNetworkReply::ContentNotFoundError, "Not found"); 2329 setAttribute(QNetworkRequest::HttpStatusCodeAttribute, 404); 2330 QTimer::singleShot(0, this, SLOT(continueError())); 2324 2331 } 2325 2332 … … 2353 2360 }; 2354 2361 2362 const QUrl FakeReply::urlFor404ErrorWithoutContents = QUrl("http://this.will/return-http-404-error-without-contents.html"); 2363 2355 2364 class FakeNetworkManager : public QNetworkAccessManager { 2356 2365 Q_OBJECT … … 2364 2373 QString url = request.url().toString(); 2365 2374 if (op == QNetworkAccessManager::GetOperation) { 2366 if (url == "qrc:/test1.html" || url == "http://abcdef.abcdef/")2367 return new FakeReply(request, this);2368 2375 #ifndef QT_NO_OPENSSL 2369 elseif (url == "qrc:/fake-ssl-error.html") {2376 if (url == "qrc:/fake-ssl-error.html") { 2370 2377 FakeReply* reply = new FakeReply(request, this); 2371 2378 QList<QSslError> errors; … … 2374 2381 } 2375 2382 #endif 2376 } 2383 if (url == "qrc:/test1.html" || url == "http://abcdef.abcdef/" || request.url() == FakeReply::urlFor404ErrorWithoutContents) 2384 return new FakeReply(request, this); 2385 } 2377 2386 2378 2387 return QNetworkAccessManager::createRequest(op, request, outgoingData); … … 3680 3689 } 3681 3690 3691 void tst_QWebFrame::loadFinishedAfterNotFoundError() 3692 { 3693 QWebPage page; 3694 QWebFrame* frame = page.mainFrame(); 3695 3696 QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); 3697 FakeNetworkManager* networkManager = new FakeNetworkManager(&page); 3698 page.setNetworkAccessManager(networkManager); 3699 3700 frame->setUrl(FakeReply::urlFor404ErrorWithoutContents); 3701 QTRY_COMPARE(spy.count(), 1); 3702 const bool wasLoadOk = spy.at(0).at(0).toBool(); 3703 QVERIFY(!wasLoadOk); 3704 } 3705 3682 3706 QTEST_MAIN(tst_QWebFrame) 3683 3707 #include "tst_qwebframe.moc" -
trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
r91302 r91669 135 135 void errorPageExtensionInIFrames(); 136 136 void errorPageExtensionInFrameset(); 137 void errorPageExtensionLoadFinished(); 137 138 void userAgentApplicationName(); 138 139 … … 2577 2578 } 2578 2579 2580 void tst_QWebPage::errorPageExtensionLoadFinished() 2581 { 2582 ErrorPage page; 2583 m_view->setPage(&page); 2584 2585 QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool))); 2586 QSignalSpy spyFrameLoadFinished(m_view->page()->mainFrame(), SIGNAL(loadFinished(bool))); 2587 2588 m_view->setUrl(QUrl("data:text/html,foo")); 2589 QTRY_COMPARE(spyLoadFinished.count(), 1); 2590 QTRY_COMPARE(spyFrameLoadFinished.count(), 1); 2591 2592 const bool loadSucceded = spyLoadFinished.at(0).at(0).toBool(); 2593 QVERIFY(loadSucceded); 2594 const bool frameLoadSucceded = spyFrameLoadFinished.at(0).at(0).toBool(); 2595 QVERIFY(frameLoadSucceded); 2596 2597 m_view->page()->mainFrame()->setUrl(QUrl("http://non.existent/url")); 2598 QTRY_COMPARE(spyLoadFinished.count(), 2); 2599 QTRY_COMPARE(spyFrameLoadFinished.count(), 2); 2600 2601 const bool nonExistantLoadSucceded = spyLoadFinished.at(1).at(0).toBool(); 2602 QVERIFY(nonExistantLoadSucceded); 2603 const bool nonExistantFrameLoadSucceded = spyFrameLoadFinished.at(1).at(0).toBool(); 2604 QVERIFY(nonExistantFrameLoadSucceded); 2605 2606 m_view->setPage(0); 2607 } 2608 2579 2609 class FriendlyWebPage : public QWebPage 2580 2610 {
Note: See TracChangeset
for help on using the changeset viewer.