diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-27 15:20:52 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-27 15:20:52 +0000 |
commit | 07eb0c01b2d522bb12104a1a079ce352b034f6ec (patch) | |
tree | 3e96c8c8e1381a605fa44533c5edc27b056b08e5 /chrome/browser/errorpage_uitest.cc | |
parent | 65e3abbad1e5d111675658f1df562c40389bbda5 (diff) | |
download | chromium_src-07eb0c01b2d522bb12104a1a079ce352b034f6ec.zip chromium_src-07eb0c01b2d522bb12104a1a079ce352b034f6ec.tar.gz chromium_src-07eb0c01b2d522bb12104a1a079ce352b034f6ec.tar.bz2 |
Mock the LinkDoctor for tests. Should greatly decrease ErrorPage test flakiness.
Not getting rid of WaitForTitleMatching because I have to add few more calls to the automation framework (http://crbug.com/19395) to wait properly after navigating back and forward.
TEST=Covered by ui_tests and browser_tests.
http://crbug.com/18365, http://crbug.com/19361
Review URL: http://codereview.chromium.org/174179
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24606 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/errorpage_uitest.cc')
-rw-r--r-- | chrome/browser/errorpage_uitest.cc | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/chrome/browser/errorpage_uitest.cc b/chrome/browser/errorpage_uitest.cc index 3e34822..c8b54fa 100644 --- a/chrome/browser/errorpage_uitest.cc +++ b/chrome/browser/errorpage_uitest.cc @@ -19,15 +19,6 @@ class ErrorPageTest : public UITest { } return false; } - bool WaitForTitleContaining(const std::string& title_substring) { - for (int i = 0; i < 100; ++i) { - std::wstring title = GetActiveTabTitle(); - if (title.find(UTF8ToWide(title_substring)) != std::wstring::npos) - return true; - PlatformThread::Sleep(sleep_timeout_ms() / 10); - } - return false; - } }; TEST_F(ErrorPageTest, DNSError_Basic) { @@ -37,7 +28,7 @@ TEST_F(ErrorPageTest, DNSError_Basic) { // page. NavigateToURLBlockUntilNavigationsComplete(test_url, 2); - EXPECT_TRUE(WaitForTitleContaining(test_url.host())); + EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor")); } TEST_F(ErrorPageTest, DNSError_GoBack1) { @@ -47,7 +38,7 @@ TEST_F(ErrorPageTest, DNSError_GoBack1) { NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html")); NavigateToURL(test_url); - EXPECT_TRUE(WaitForTitleContaining(test_url.host())); + EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor")); GetActiveTab()->GoBack(); @@ -61,13 +52,13 @@ TEST_F(ErrorPageTest, DNSError_GoBack2) { NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html")); NavigateToURL(test_url); - EXPECT_TRUE(WaitForTitleContaining(test_url.host())); + EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor")); NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title3.html")); // The first navigation should fail, and the second one should be the error // page. GetActiveTab()->GoBackBlockUntilNavigationsComplete(2); - EXPECT_TRUE(WaitForTitleContaining(test_url.host())); + EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor")); GetActiveTab()->GoBack(); EXPECT_TRUE(WaitForTitleMatching(L"Title Of Awesomeness")); @@ -81,19 +72,19 @@ TEST_F(ErrorPageTest, DNSError_GoBack2AndForward) { NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html")); NavigateToURL(test_url); - EXPECT_TRUE(WaitForTitleContaining(test_url.host())); + EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor")); NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title3.html")); // The first navigation should fail, and the second one should be the error // page. GetActiveTab()->GoBackBlockUntilNavigationsComplete(2); - EXPECT_TRUE(WaitForTitleContaining(test_url.host())); + EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor")); GetActiveTab()->GoBack(); // The first navigation should fail, and the second one should be the error // page. GetActiveTab()->GoForwardBlockUntilNavigationsComplete(2); - EXPECT_TRUE(WaitForTitleContaining(test_url.host())); + EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor")); } TEST_F(ErrorPageTest, DNSError_GoBack2Forward2) { @@ -104,18 +95,18 @@ TEST_F(ErrorPageTest, DNSError_GoBack2Forward2) { NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title3.html")); NavigateToURL(test_url); - EXPECT_TRUE(WaitForTitleContaining(test_url.host())); + EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor")); NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html")); // The first navigation should fail, and the second one should be the error // page. GetActiveTab()->GoBackBlockUntilNavigationsComplete(2); - EXPECT_TRUE(WaitForTitleContaining(test_url.host())); + EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor")); GetActiveTab()->GoBack(); // The first navigation should fail, and the second one should be the error // page. GetActiveTab()->GoForwardBlockUntilNavigationsComplete(2); - EXPECT_TRUE(WaitForTitleContaining(test_url.host())); + EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor")); GetActiveTab()->GoForward(); EXPECT_TRUE(WaitForTitleMatching(L"Title Of Awesomeness")); @@ -175,13 +166,13 @@ TEST_F(ErrorPageTest, Page404) { NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html")); NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"page404.html")); - EXPECT_TRUE(WaitForTitleContaining("page404.html")); + EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor")); } TEST_F(ErrorPageTest, Page404_GoBack) { NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html")); NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"page404.html")); - EXPECT_TRUE(WaitForTitleContaining("page404.html")); + EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor")); GetActiveTab()->GoBack(); |