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

Unified Diff: chrome/browser/net/dns_probe_browsertest.cc

Issue 137623011: Switch to using the new Link Doctor API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Simulate click on more button Created 6 years, 10 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
Index: chrome/browser/net/dns_probe_browsertest.cc
===================================================================
--- chrome/browser/net/dns_probe_browsertest.cc (revision 248295)
+++ chrome/browser/net/dns_probe_browsertest.cc (working copy)
@@ -110,7 +110,7 @@
FilePath GetMockLinkDoctorFilePath() {
FilePath root_http;
PathService::Get(chrome::DIR_TEST_DATA, &root_http);
- return root_http.AppendASCII("mock-link-doctor.html");
+ return root_http.AppendASCII("mock-link-doctor.json");
}
// A request that can be delayed until Resume() is called. Can also run a
@@ -461,6 +461,16 @@
std::string Title();
bool PageContains(const std::string& expected);
+ // Checks that the local error page is being displayed, without Link Doctor
+ // suggestions, and with the specified status text. The status text should be
+ // either a network error or DNS probe status.
+ void ExpectDisplayingLocalErrorPage(const std::string& status_text);
+
+ // Checks that an error page with suggestions retrieved from the mock Link
+ // Doctor result is being displayed, with the specified status text.
+ // The status text should be either a network error or DNS probe status.
+ void ExpectDisplayingLinkDoctor(const std::string& status_text);
+
private:
void OnDnsProbeStatusSent(DnsProbeStatus dns_probe_status);
@@ -638,6 +648,20 @@
return text_content.find(expected) != std::string::npos;
}
+void DnsProbeBrowserTest::ExpectDisplayingLocalErrorPage(
+ const std::string& status_text) {
+ EXPECT_FALSE(PageContains("http://correction1/"));
+ EXPECT_FALSE(PageContains("http://correction2/"));
+ EXPECT_TRUE(PageContains(status_text));
+}
+
+void DnsProbeBrowserTest::ExpectDisplayingLinkDoctor(
+ const std::string& status_text) {
+ EXPECT_TRUE(PageContains("http://correction1/"));
+ EXPECT_TRUE(PageContains("http://correction2/"));
+ EXPECT_TRUE(PageContains(status_text));
+}
+
void DnsProbeBrowserTest::OnDnsProbeStatusSent(
DnsProbeStatus dns_probe_status) {
dns_probe_status_queue_.push_back(dns_probe_status);
@@ -650,7 +674,7 @@
SetLinkDoctorBroken(false);
NavigateToOtherError(2);
- EXPECT_EQ("Mock Link Doctor", Title());
+ ExpectDisplayingLinkDoctor("ERR_CONNECTION_REFUSED");
}
// Make sure probes don't break non-DNS error pages when Link Doctor doesn't
@@ -659,31 +683,31 @@
SetLinkDoctorBroken(true);
NavigateToOtherError(2);
- EXPECT_TRUE(PageContains("CONNECTION_REFUSED"));
+ ExpectDisplayingLocalErrorPage("ERR_CONNECTION_REFUSED");
}
-// Make sure probes don't break DNS error pages when Link doctor loads.
+// Make sure probes don't break DNS error pages when Link Doctor loads.
IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest,
NxdomainProbeResultWithWorkingLinkDoctor) {
SetLinkDoctorBroken(false);
SetMockDnsClientRules(MockDnsClientRule::OK, MockDnsClientRule::OK);
NavigateToDnsError(2);
- EXPECT_EQ("Mock Link Doctor", Title());
+ ExpectDisplayingLinkDoctor("ERR_NAME_NOT_RESOLVED");
// One status for committing a blank page before the Link Doctor, and one for
// when the Link Doctor is committed.
EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus());
EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus());
EXPECT_EQ(0, pending_status_count());
- EXPECT_EQ("Mock Link Doctor", Title());
+ ExpectDisplayingLinkDoctor("ERR_NAME_NOT_RESOLVED");
StartDelayedProbes(1);
EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN,
WaitForSentStatus());
EXPECT_EQ(0, pending_status_count());
- EXPECT_EQ("Mock Link Doctor", Title());
+ ExpectDisplayingLinkDoctor("ERR_NAME_NOT_RESOLVED");
}
// Make sure probes don't break Link Doctor when probes complete before the
@@ -716,13 +740,13 @@
SetLinkDoctorDelayRequests(false);
// Wait for it to commit.
observer.Wait();
- EXPECT_EQ("Mock Link Doctor", Title());
+ ExpectDisplayingLinkDoctor("ERR_NAME_NOT_RESOLVED");
// Committing the Link Doctor page should trigger sending the probe result
// again.
EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN,
WaitForSentStatus());
- EXPECT_EQ("Mock Link Doctor", Title());
+ ExpectDisplayingLinkDoctor("ERR_NAME_NOT_RESOLVED");
}
// Make sure probes update DNS error page properly when they're supposed to.
@@ -737,9 +761,9 @@
EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus());
EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus());
- // PageContains runs the RunLoop, so make sure nothing hairy happens.
+ // Checking the page runs the RunLoop, so make sure nothing hairy happens.
EXPECT_EQ(0, pending_status_count());
- EXPECT_TRUE(PageContains("DNS_PROBE_STARTED"));
+ ExpectDisplayingLocalErrorPage("DNS_PROBE_STARTED");
EXPECT_EQ(0, pending_status_count());
StartDelayedProbes(1);
@@ -747,9 +771,9 @@
EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_NO_INTERNET,
WaitForSentStatus());
- // PageContains runs the RunLoop, so make sure nothing hairy happens.
+ // Checking the page runs the RunLoop, so make sure nothing hairy happens.
EXPECT_EQ(0, pending_status_count());
- EXPECT_TRUE(PageContains("DNS_PROBE_FINISHED_NO_INTERNET"));
+ ExpectDisplayingLocalErrorPage("DNS_PROBE_FINISHED_NO_INTERNET");
}
// Make sure probes don't break Link Doctor when probes complete before the
@@ -788,7 +812,7 @@
WaitForSentStatus());
EXPECT_EQ(0, pending_status_count());
- EXPECT_TRUE(PageContains("DNS_PROBE_FINISHED_NO_INTERNET"));
+ ExpectDisplayingLocalErrorPage("DNS_PROBE_FINISHED_NO_INTERNET");
}
// Double-check to make sure sync failures don't explode.
@@ -801,9 +825,9 @@
EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus());
EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus());
- // PageContains runs the RunLoop, so make sure nothing hairy happens.
+ // Checking the page runs the RunLoop, so make sure nothing hairy happens.
EXPECT_EQ(0, pending_status_count());
- EXPECT_TRUE(PageContains("DNS_PROBE_STARTED"));
+ ExpectDisplayingLocalErrorPage("DNS_PROBE_STARTED");
EXPECT_EQ(0, pending_status_count());
StartDelayedProbes(1);
@@ -811,9 +835,9 @@
EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_INCONCLUSIVE,
WaitForSentStatus());
- // PageContains runs the RunLoop, so make sure nothing hairy happens.
+ // Checking the page runs the RunLoop, so make sure nothing hairy happens.
EXPECT_EQ(0, pending_status_count());
- EXPECT_TRUE(PageContains("NAME_NOT_RESOLVED"));
+ ExpectDisplayingLocalErrorPage("ERR_NAME_NOT_RESOLVED");
EXPECT_EQ(0, pending_status_count());
}
@@ -903,9 +927,9 @@
EXPECT_EQ(chrome_common_net::DNS_PROBE_NOT_RUN, WaitForSentStatus());
- // PageContains runs the RunLoop, so make sure nothing hairy happens.
+ // Checking the page runs the RunLoop, so make sure nothing hairy happens.
EXPECT_EQ(0, pending_status_count());
- EXPECT_TRUE(PageContains("NAME_NOT_RESOLVED"));
+ ExpectDisplayingLocalErrorPage("ERR_NAME_NOT_RESOLVED");
}
// Test the case that Link Doctor is disabled, but DNS probes are enabled. This
@@ -928,9 +952,9 @@
NavigateToDnsError(1);
EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus());
- // PageContains runs the RunLoop, so make sure nothing hairy happens.
+ // Checking the page runs the RunLoop, so make sure nothing hairy happens.
EXPECT_EQ(0, pending_status_count());
- EXPECT_TRUE(PageContains("DNS_PROBE_STARTED"));
+ ExpectDisplayingLocalErrorPage("DNS_PROBE_STARTED");
EXPECT_EQ(0, pending_status_count());
StartDelayedProbes(1);
@@ -938,7 +962,7 @@
EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_INCONCLUSIVE,
WaitForSentStatus());
EXPECT_EQ(0, pending_status_count());
- EXPECT_TRUE(PageContains("NAME_NOT_RESOLVED"));
+ ExpectDisplayingLocalErrorPage("ERR_NAME_NOT_RESOLVED");
}
// Test incognito mode. Link Doctor should be disabled, but DNS probes are
@@ -957,9 +981,9 @@
NavigateToDnsError(1);
EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus());
- // PageContains runs the RunLoop, so make sure nothing hairy happens.
+ // Checking the page runs the RunLoop, so make sure nothing hairy happens.
EXPECT_EQ(0, pending_status_count());
- EXPECT_TRUE(PageContains("DNS_PROBE_STARTED"));
+ ExpectDisplayingLocalErrorPage("DNS_PROBE_STARTED");
EXPECT_EQ(0, pending_status_count());
StartDelayedProbes(1);
@@ -967,7 +991,7 @@
EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_INCONCLUSIVE,
WaitForSentStatus());
EXPECT_EQ(0, pending_status_count());
- EXPECT_TRUE(PageContains("NAME_NOT_RESOLVED"));
+ ExpectDisplayingLocalErrorPage("ERR_NAME_NOT_RESOLVED");
}
} // namespace

Powered by Google App Engine
This is Rietveld 408576698