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

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

Issue 1431653003: Migrating tests to use EmbeddedTestServer (misc) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing comments. 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
Index: chrome/renderer/safe_browsing/phishing_dom_feature_extractor_browsertest.cc
diff --git a/chrome/renderer/safe_browsing/phishing_dom_feature_extractor_browsertest.cc b/chrome/renderer/safe_browsing/phishing_dom_feature_extractor_browsertest.cc
index e8e1b18e7d15c8bbeff35e881b6d35a1179403bc..2422d5bdabb8398aae3ece17ddca02bc7354c674 100644
--- a/chrome/renderer/safe_browsing/phishing_dom_feature_extractor_browsertest.cc
+++ b/chrome/renderer/safe_browsing/phishing_dom_feature_extractor_browsertest.cc
@@ -134,11 +134,11 @@ class PhishingDOMFeatureExtractorTest : public InProcessBrowserTest {
bool StartTestServer() {
CHECK(!embedded_test_server_);
- embedded_test_server_.reset(new net::test_server::EmbeddedTestServer());
+ embedded_test_server_.reset(new net::EmbeddedTestServer());
embedded_test_server_->RegisterRequestHandler(
base::Bind(&PhishingDOMFeatureExtractorTest::HandleRequest,
base::Unretained(this)));
- return embedded_test_server_->InitializeAndWaitUntilReady();
+ return embedded_test_server_->Start();
mmenke 2015/11/05 18:21:03 Per comment in other file, can also switch this to
svaldez 2015/11/05 18:34:51 Done.
}
scoped_ptr<net::test_server::HttpResponse> HandleRequest(
@@ -184,7 +184,7 @@ class PhishingDOMFeatureExtractorTest : public InProcessBrowserTest {
// Any urls not in this map are served a 404 error.
std::map<std::string, std::string> responses_;
- scoped_ptr<net::test_server::EmbeddedTestServer> embedded_test_server_;
+ scoped_ptr<net::EmbeddedTestServer> embedded_test_server_;
MockFeatureExtractorClock clock_;
scoped_ptr<PhishingDOMFeatureExtractor> extractor_;
bool success_; // holds the success value from ExtractFeatures
@@ -281,18 +281,16 @@ IN_PROC_BROWSER_TEST_F(PhishingDOMFeatureExtractorTest, LinkFeatures) {
expected_features.AddBooleanFeature(features::kPageLinkDomain +
std::string("chromium.org"));
- 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());
// The PhishingDOMFeatureExtractor depends on URLs being domains and not IPs,
// so use a domain.
- std::string url_str = "https://host.com:";
- url_str += base::UintToString(https_server.host_port_pair().port());
- url_str += "/files/safe_browsing/secure_link_features.html";
- ui_test_utils::NavigateToURL(browser(), GURL(url_str));
+ GURL url = https_server.GetURL("/safe_browsing/secure_link_features.html");
+ GURL::Replacements replace_host;
+ replace_host.SetHostStr("host.com");
+ ui_test_utils::NavigateToURL(browser(), url.ReplaceComponents(replace_host));
// Click through the certificate error interstitial.
content::InterstitialPage* interstitial_page =
@@ -332,17 +330,15 @@ IN_PROC_BROWSER_TEST_F(PhishingDOMFeatureExtractorTest,
expected_features.AddRealFeature(features::kPageImgOtherDomainFreq, 0.5);
features.Clear();
- 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());
// The PhishingDOMFeatureExtractor depends on URLs being domains and not IPs,
// so use a domain.
std::string url_str = "https://host.com:";
url_str += base::UintToString(https_server.host_port_pair().port());
mmenke 2015/11/05 18:21:03 Again, use GURL::Replacements.
svaldez 2015/11/05 18:34:51 Done.
- url_str += "/files/safe_browsing/secure_script_and_image.html";
+ url_str += "/safe_browsing/secure_script_and_image.html";
ui_test_utils::NavigateToURL(browser(), GURL(url_str));
// Click through the certificate error interstitial.

Powered by Google App Engine
This is Rietveld 408576698