summaryrefslogtreecommitdiffstats
path: root/chrome/browser/errorpage_uitest.cc
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-21 23:07:15 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-21 23:07:15 +0000
commita33457b842b5b8e70622d7c73f266bb94dec6a49 (patch)
tree6861fd3d684ea96588adfd2c9df03787344e85d0 /chrome/browser/errorpage_uitest.cc
parent66547160c1f2646c9d3f1ec363d41ae56e62f29f (diff)
downloadchromium_src-a33457b842b5b8e70622d7c73f266bb94dec6a49.zip
chromium_src-a33457b842b5b8e70622d7c73f266bb94dec6a49.tar.gz
chromium_src-a33457b842b5b8e70622d7c73f266bb94dec6a49.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@26761 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/errorpage_uitest.cc')
-rw-r--r--chrome/browser/errorpage_uitest.cc35
1 files changed, 12 insertions, 23 deletions
diff --git a/chrome/browser/errorpage_uitest.cc b/chrome/browser/errorpage_uitest.cc
index 668bc1d..1bd7846 100644
--- a/chrome/browser/errorpage_uitest.cc
+++ b/chrome/browser/errorpage_uitest.cc
@@ -20,17 +20,6 @@ class ErrorPageTest : public UITest {
EXPECT_EQ(title, GetActiveTabTitle());
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);
- }
- LOG(ERROR) << "Could not find " << title_substring << " in "
- << GetActiveTabTitle();
- return false;
- }
};
TEST_F(ErrorPageTest, DNSError_Basic) {
@@ -40,7 +29,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) {
@@ -52,7 +41,7 @@ TEST_F(ErrorPageTest, DNSError_GoBack1) {
// The first navigation should fail, and the second one should be the error
// page.
NavigateToURLBlockUntilNavigationsComplete(test_url, 2);
- EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
+ EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor"));
GetActiveTab()->GoBack();
@@ -68,13 +57,13 @@ TEST_F(ErrorPageTest, DNSError_GoBack2) {
// The first navigation should fail, and the second one should be the error
// page.
NavigateToURLBlockUntilNavigationsComplete(test_url, 2);
- 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"));
@@ -90,19 +79,19 @@ TEST_F(ErrorPageTest, DNSError_GoBack2AndForward) {
// The first navigation should fail, and the second one should be the error
// page.
NavigateToURLBlockUntilNavigationsComplete(test_url, 2);
- 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) {
@@ -115,18 +104,18 @@ TEST_F(ErrorPageTest, DNSError_GoBack2Forward2) {
// The first navigation should fail, and the second one should be the error
// page.
NavigateToURLBlockUntilNavigationsComplete(test_url, 2);
- 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"));
@@ -183,7 +172,7 @@ TEST_F(ErrorPageTest, Page404) {
NavigateToURLBlockUntilNavigationsComplete(
URLRequestMockHTTPJob::GetMockUrl(L"page404.html"), 2);
- EXPECT_TRUE(WaitForTitleContaining("page404.html"));
+ EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor"));
}
TEST_F(ErrorPageTest, Page404_GoBack) {
@@ -192,7 +181,7 @@ TEST_F(ErrorPageTest, Page404_GoBack) {
// page.
NavigateToURLBlockUntilNavigationsComplete(
URLRequestMockHTTPJob::GetMockUrl(L"page404.html"), 2);
- EXPECT_TRUE(WaitForTitleContaining("page404.html"));
+ EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor"));
GetActiveTab()->GoBack();