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

Unified Diff: chrome/renderer/safe_browsing/phishing_classifier_browsertest.cc

Issue 1431653003: Migrating tests to use EmbeddedTestServer (misc) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing tests. Created 5 years, 1 month 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/renderer/safe_browsing/phishing_classifier_delegate_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/safe_browsing/phishing_classifier_browsertest.cc
diff --git a/chrome/renderer/safe_browsing/phishing_classifier_browsertest.cc b/chrome/renderer/safe_browsing/phishing_classifier_browsertest.cc
index 837321315e8e262a396a126e363b8d211191269b..786e5d67e762127e434b8bd6c871c1575034fffd 100644
--- a/chrome/renderer/safe_browsing/phishing_classifier_browsertest.cc
+++ b/chrome/renderer/safe_browsing/phishing_classifier_browsertest.cc
@@ -103,6 +103,11 @@ class PhishingClassifierTest : public InProcessBrowserTest {
content::RenderFrame* render_frame = content::RenderFrame::FromRoutingID(
web_contents->GetMainFrame()->GetRoutingID());
classifier_.reset(new PhishingClassifier(render_frame, clock_));
+
+ embedded_test_server()->RegisterRequestHandler(
+ base::Bind(&PhishingClassifierTest::HandleRequest,
+ base::Unretained(this)));
+ ASSERT_TRUE(embedded_test_server()->Start());
}
void TearDownOnMainThread() override {
@@ -154,19 +159,6 @@ class PhishingClassifierTest : public InProcessBrowserTest {
run_loop->Quit();
}
- scoped_ptr<net::test_server::EmbeddedTestServer> embedded_test_server_;
- net::test_server::EmbeddedTestServer* embedded_test_server() {
- // TODO(ajwong): Merge this into BrowserTestBase.
- if (!embedded_test_server_) {
- embedded_test_server_.reset(new net::test_server::EmbeddedTestServer());
- embedded_test_server_->RegisterRequestHandler(
- base::Bind(&PhishingClassifierTest::HandleRequest,
- base::Unretained(this)));
- CHECK(embedded_test_server_->InitializeAndWaitUntilReady());
- }
- return embedded_test_server_.get();
- }
-
void LoadHtml(const std::string& host, const std::string& content) {
GURL::Replacements replace_host;
replace_host.SetHostStr(host);
@@ -263,14 +255,12 @@ IN_PROC_BROWSER_TEST_F(PhishingClassifierTest, MAYBE_TestClassification) {
EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score);
// Extraction should also fail for this case because the URL is not http.
- net::SpawnedTestServer https_server(
- net::SpawnedTestServer::TYPE_HTTPS,
- net::SpawnedTestServer::kLocalhost,
- base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
+ net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
+ https_server.ServeFilesFromSourceDirectory("chrome/test/data");
ASSERT_TRUE(https_server.Start());
GURL::Replacements replace_host;
replace_host.SetHostStr("host.net");
- GURL test_url = https_server.GetURL("/files/title1.html");
+ GURL test_url = https_server.GetURL("/title1.html");
ui_test_utils::NavigateToURL(browser(),
test_url.ReplaceComponents(replace_host));
EXPECT_FALSE(RunPhishingClassifier(&page_text, &phishy_score, &features));
« no previous file with comments | « no previous file | chrome/renderer/safe_browsing/phishing_classifier_delegate_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698