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

Unified Diff: chrome/browser/push_messaging/push_messaging_browsertest.cc

Issue 1409163006: Migrating tests to use EmbeddedTestServer (/chrome/browser misc) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix rebase bug. 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/browser/push_messaging/push_messaging_browsertest.cc
diff --git a/chrome/browser/push_messaging/push_messaging_browsertest.cc b/chrome/browser/push_messaging/push_messaging_browsertest.cc
index 313e28fd3051ba31def1f701b1510ac349e88f10..03291177fb4b8e27da8cf75b393f67286b702b9f 100644
--- a/chrome/browser/push_messaging/push_messaging_browsertest.cc
+++ b/chrome/browser/push_messaging/push_messaging_browsertest.cc
@@ -40,6 +40,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
+#include "net/test/embedded_test_server/embedded_test_server.h"
#include "ui/base/window_open_disposition.h"
#if defined(ENABLE_BACKGROUND)
@@ -88,11 +89,9 @@ class PushMessagingBrowserTest : public InProcessBrowserTest {
// InProcessBrowserTest:
void SetUp() override {
- https_server_.reset(new net::SpawnedTestServer(
- net::SpawnedTestServer::TYPE_HTTPS,
- net::BaseTestServer::SSLOptions(
- net::BaseTestServer::SSLOptions::CERT_OK),
- base::FilePath(FILE_PATH_LITERAL("chrome/test/data/"))));
+ https_server_.reset(
+ new net::EmbeddedTestServer(net::EmbeddedTestServer::TYPE_HTTPS));
+ https_server_->ServeFilesFromSourceDirectory("chrome/test/data");
ASSERT_TRUE(https_server_->Start());
#if defined(ENABLE_NOTIFICATIONS)
@@ -185,7 +184,7 @@ class PushMessagingBrowserTest : public InProcessBrowserTest {
const PushMessagingAppIdentifier& app_identifier,
const gcm::IncomingMessage& message);
- net::SpawnedTestServer* https_server() const { return https_server_.get(); }
+ net::EmbeddedTestServer* https_server() const { return https_server_.get(); }
gcm::FakeGCMProfileService* gcm_service() const { return gcm_service_; }
@@ -214,14 +213,12 @@ class PushMessagingBrowserTest : public InProcessBrowserTest {
PushMessagingServiceImpl* push_service() const { return push_service_; }
protected:
- virtual std::string GetTestURL() {
- return "files/push_messaging/test.html";
- }
+ virtual std::string GetTestURL() { return "/push_messaging/test.html"; }
virtual Browser* GetBrowser() const { return browser(); }
private:
- scoped_ptr<net::SpawnedTestServer> https_server_;
+ scoped_ptr<net::EmbeddedTestServer> https_server_;
gcm::FakeGCMProfileService* gcm_service_;
PushMessagingServiceImpl* push_service_;
@@ -235,7 +232,7 @@ class PushMessagingBrowserTest : public InProcessBrowserTest {
class PushMessagingBrowserTestEmptySubscriptionOptions
: public PushMessagingBrowserTest {
std::string GetTestURL() override {
- return "files/push_messaging/test_no_subscription_options.html";
+ return "/push_messaging/test_no_subscription_options.html";
}
};
@@ -272,7 +269,7 @@ void PushMessagingBrowserTest::TryToSubscribeSuccessfully(
PushMessagingAppIdentifier
PushMessagingBrowserTest::GetAppIdentifierForServiceWorkerRegistration(
int64 service_worker_registration_id) {
- GURL origin = https_server()->GetURL(std::string()).GetOrigin();
+ GURL origin = https_server()->GetURL("/").GetOrigin();
PushMessagingAppIdentifier app_identifier =
PushMessagingAppIdentifier::FindByServiceWorker(
GetBrowser()->profile(), origin, service_worker_registration_id);
@@ -376,24 +373,24 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribePersisted) {
GetAppIdentifierForServiceWorkerRegistration(0LL);
EXPECT_EQ(sw0_identifier.app_id(), gcm_service()->last_registered_app_id());
- LoadTestPage("files/push_messaging/subscope1/test.html");
+ LoadTestPage("/push_messaging/subscope1/test.html");
ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
ASSERT_EQ("ok - service worker registered", script_result);
- LoadTestPage("files/push_messaging/subscope2/test.html");
+ LoadTestPage("/push_messaging/subscope2/test.html");
ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
ASSERT_EQ("ok - service worker registered", script_result);
// Note that we need to reload the page after registering, otherwise
// navigator.serviceWorker.ready is going to be resolved with the parent
// Service Worker which still controls the page.
- LoadTestPage("files/push_messaging/subscope2/test.html");
+ LoadTestPage("/push_messaging/subscope2/test.html");
TryToSubscribeSuccessfully("1-1" /* expected_push_subscription_id */);
PushMessagingAppIdentifier sw2_identifier =
GetAppIdentifierForServiceWorkerRegistration(2LL);
EXPECT_EQ(sw2_identifier.app_id(), gcm_service()->last_registered_app_id());
- LoadTestPage("files/push_messaging/subscope1/test.html");
+ LoadTestPage("/push_messaging/subscope1/test.html");
TryToSubscribeSuccessfully("1-2" /* expected_push_subscription_id */);
PushMessagingAppIdentifier sw1_identifier =
GetAppIdentifierForServiceWorkerRegistration(1LL);
@@ -407,11 +404,11 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribePersisted) {
// test server uses random port numbers for each test (even PRE_Foo and Foo),
// so we wouldn't be able to load the test pages with the same origin.
- LoadTestPage("files/push_messaging/subscope1/test.html");
+ LoadTestPage("/push_messaging/subscope1/test.html");
TryToSubscribeSuccessfully("1-2" /* expected_push_subscription_id */);
EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id());
- LoadTestPage("files/push_messaging/subscope2/test.html");
+ LoadTestPage("/push_messaging/subscope2/test.html");
TryToSubscribeSuccessfully("1-1" /* expected_push_subscription_id */);
EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id());
@@ -850,7 +847,7 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
push_service()->SetContentSettingChangedCallbackForTesting(
message_loop_runner->QuitClosure());
- GURL origin = https_server()->GetURL(std::string()).GetOrigin();
+ GURL origin = https_server()->GetURL("/").GetOrigin();
HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile())
->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin),
ContentSettingsPattern::FromURLNoWildcard(origin),
@@ -884,7 +881,7 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
push_service()->SetContentSettingChangedCallbackForTesting(
message_loop_runner->QuitClosure());
- GURL origin = https_server()->GetURL(std::string()).GetOrigin();
+ GURL origin = https_server()->GetURL("/").GetOrigin();
HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile())
->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin),
ContentSettingsPattern::FromURLNoWildcard(origin),
@@ -947,7 +944,7 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
push_service()->SetContentSettingChangedCallbackForTesting(
message_loop_runner->QuitClosure());
- GURL origin = https_server()->GetURL(std::string()).GetOrigin();
+ GURL origin = https_server()->GetURL("/").GetOrigin();
HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile())
->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin),
ContentSettingsPattern::Wildcard(),
@@ -981,7 +978,7 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
push_service()->SetContentSettingChangedCallbackForTesting(
message_loop_runner->QuitClosure());
- GURL origin = https_server()->GetURL(std::string()).GetOrigin();
+ GURL origin = https_server()->GetURL("/").GetOrigin();
HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile())
->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin),
ContentSettingsPattern::Wildcard(),
@@ -1015,7 +1012,7 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
push_service()->SetContentSettingChangedCallbackForTesting(
base::BarrierClosure(2, message_loop_runner->QuitClosure()));
- GURL origin = https_server()->GetURL(std::string()).GetOrigin();
+ GURL origin = https_server()->GetURL("/").GetOrigin();
HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile())
->SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(origin),
ContentSettingsPattern::Wildcard(),
@@ -1059,7 +1056,7 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
push_service()->SetContentSettingChangedCallbackForTesting(
base::BarrierClosure(4, message_loop_runner->QuitClosure()));
- GURL origin = https_server()->GetURL(std::string()).GetOrigin();
+ GURL origin = https_server()->GetURL("/").GetOrigin();
HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile())
->SetContentSetting(ContentSettingsPattern::Wildcard(),
ContentSettingsPattern::Wildcard(),

Powered by Google App Engine
This is Rietveld 408576698