Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4995)

Unified Diff: chrome/browser/errorpage_uitest.cc

Issue 174179: Mock the LinkDoctor for tests. Should greatly decrease ErrorPage test flakiness. (Closed)
Patch Set: sync with trunk Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/google_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/errorpage_uitest.cc
diff --git a/chrome/browser/errorpage_uitest.cc b/chrome/browser/errorpage_uitest.cc
index 668bc1d894ae04fd93a8f09aeaa4d3824d99da69..1bd784613a73c7b10c74503b05087820e489b33f 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();
« no previous file with comments | « no previous file | chrome/browser/google_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698