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

Unified Diff: content/browser/service_worker/service_worker_job_unittest.cc

Issue 2968123002: Introduce ServiceWorkerRegistrationOptions struct for service worker options (Closed)
Patch Set: address more comments Created 3 years, 5 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: content/browser/service_worker/service_worker_job_unittest.cc
diff --git a/content/browser/service_worker/service_worker_job_unittest.cc b/content/browser/service_worker/service_worker_job_unittest.cc
index 5938ee6512dd697ba26e800dece652090df6533b..38a73cf0aa3efc258ac8f8dc318661bb5e8ad79c 100644
--- a/content/browser/service_worker/service_worker_job_unittest.cc
+++ b/content/browser/service_worker/service_worker_job_unittest.cc
@@ -183,7 +183,7 @@ scoped_refptr<ServiceWorkerRegistration> ServiceWorkerJobTest::RunRegisterJob(
scoped_refptr<ServiceWorkerRegistration> registration;
bool called;
job_coordinator()->Register(
- pattern, script_url, NULL,
+ script_url, ServiceWorkerRegistrationOptions(pattern), nullptr,
SaveRegistration(expected_status, &called, &registration));
EXPECT_FALSE(called);
base::RunLoop().RunUntilIdle();
@@ -253,7 +253,7 @@ TEST_F(ServiceWorkerJobTest, SameMatchSameRegistration) {
scoped_refptr<ServiceWorkerRegistration> original_registration =
RunRegisterJob(GURL("http://www.example.com/"),
GURL("http://www.example.com/service_worker.js"));
- ASSERT_NE(static_cast<ServiceWorkerRegistration*>(NULL),
+ ASSERT_NE(static_cast<ServiceWorkerRegistration*>(nullptr),
original_registration.get());
scoped_refptr<ServiceWorkerRegistration> registration1;
@@ -277,17 +277,17 @@ TEST_F(ServiceWorkerJobTest, DifferentMatchDifferentRegistration) {
bool called1;
scoped_refptr<ServiceWorkerRegistration> original_registration1;
job_coordinator()->Register(
- GURL("http://www.example.com/one/"),
GURL("http://www.example.com/service_worker.js"),
- NULL,
+ ServiceWorkerRegistrationOptions(GURL("http://www.example.com/one/")),
+ nullptr,
SaveRegistration(SERVICE_WORKER_OK, &called1, &original_registration1));
bool called2;
scoped_refptr<ServiceWorkerRegistration> original_registration2;
job_coordinator()->Register(
- GURL("http://www.example.com/two/"),
GURL("http://www.example.com/service_worker.js"),
- NULL,
+ ServiceWorkerRegistrationOptions(GURL("http://www.example.com/two/")),
+ nullptr,
SaveRegistration(SERVICE_WORKER_OK, &called2, &original_registration2));
EXPECT_FALSE(called1);
@@ -335,7 +335,7 @@ TEST_F(ServiceWorkerJobTest, Register) {
RunRegisterJob(GURL("http://www.example.com/"),
GURL("http://www.example.com/service_worker.js"));
- ASSERT_NE(scoped_refptr<ServiceWorkerRegistration>(NULL), registration);
+ ASSERT_NE(scoped_refptr<ServiceWorkerRegistration>(nullptr), registration);
EXPECT_EQ(EmbeddedWorkerTestHelper::Event::Install,
helper_->dispatched_events()->at(0));
EXPECT_EQ(EmbeddedWorkerTestHelper::Event::Activate,
@@ -367,7 +367,7 @@ TEST_F(ServiceWorkerJobTest, Unregister) {
registration = FindRegistrationForPattern(pattern,
SERVICE_WORKER_ERROR_NOT_FOUND);
- ASSERT_EQ(scoped_refptr<ServiceWorkerRegistration>(NULL), registration);
+ ASSERT_EQ(scoped_refptr<ServiceWorkerRegistration>(nullptr), registration);
}
TEST_F(ServiceWorkerJobTest, Unregister_NothingRegistered) {
@@ -388,7 +388,7 @@ TEST_F(ServiceWorkerJobTest, RegisterNewScript) {
FindRegistrationForPattern(pattern);
ASSERT_EQ(old_registration, old_registration_by_pattern);
- old_registration_by_pattern = NULL;
+ old_registration_by_pattern = nullptr;
scoped_refptr<ServiceWorkerRegistration> new_registration =
RunRegisterJob(pattern,
@@ -456,7 +456,7 @@ TEST_F(ServiceWorkerJobTest, Register_FailToStartWorker) {
GURL("http://www.example.com/service_worker.js"),
SERVICE_WORKER_ERROR_START_WORKER_FAILED);
- ASSERT_EQ(scoped_refptr<ServiceWorkerRegistration>(NULL), registration);
+ ASSERT_EQ(scoped_refptr<ServiceWorkerRegistration>(nullptr), registration);
}
// Register and then unregister the pattern, in parallel. Job coordinator should
@@ -468,9 +468,7 @@ TEST_F(ServiceWorkerJobTest, ParallelRegUnreg) {
bool registration_called = false;
scoped_refptr<ServiceWorkerRegistration> registration;
job_coordinator()->Register(
- pattern,
- script_url,
- NULL,
+ script_url, ServiceWorkerRegistrationOptions(pattern), nullptr,
SaveRegistration(SERVICE_WORKER_OK, &registration_called, &registration));
bool unregistration_called = false;
@@ -500,21 +498,17 @@ TEST_F(ServiceWorkerJobTest, ParallelRegNewScript) {
bool registration1_called = false;
scoped_refptr<ServiceWorkerRegistration> registration1;
job_coordinator()->Register(
- pattern,
- script_url1,
- NULL,
- SaveRegistration(
- SERVICE_WORKER_OK, &registration1_called, &registration1));
+ script_url1, ServiceWorkerRegistrationOptions(pattern), nullptr,
+ SaveRegistration(SERVICE_WORKER_OK, &registration1_called,
+ &registration1));
GURL script_url2("http://www.example.com/service_worker2.js");
bool registration2_called = false;
scoped_refptr<ServiceWorkerRegistration> registration2;
job_coordinator()->Register(
- pattern,
- script_url2,
- NULL,
- SaveRegistration(
- SERVICE_WORKER_OK, &registration2_called, &registration2));
+ script_url2, ServiceWorkerRegistrationOptions(pattern), nullptr,
+ SaveRegistration(SERVICE_WORKER_OK, &registration2_called,
+ &registration2));
ASSERT_FALSE(registration1_called);
ASSERT_FALSE(registration2_called);
@@ -538,20 +532,16 @@ TEST_F(ServiceWorkerJobTest, ParallelRegSameScript) {
bool registration1_called = false;
scoped_refptr<ServiceWorkerRegistration> registration1;
job_coordinator()->Register(
- pattern,
- script_url,
- NULL,
- SaveRegistration(
- SERVICE_WORKER_OK, &registration1_called, &registration1));
+ script_url, ServiceWorkerRegistrationOptions(pattern), nullptr,
+ SaveRegistration(SERVICE_WORKER_OK, &registration1_called,
+ &registration1));
bool registration2_called = false;
scoped_refptr<ServiceWorkerRegistration> registration2;
job_coordinator()->Register(
- pattern,
- script_url,
- NULL,
- SaveRegistration(
- SERVICE_WORKER_OK, &registration2_called, &registration2));
+ script_url, ServiceWorkerRegistrationOptions(pattern), nullptr,
+ SaveRegistration(SERVICE_WORKER_OK, &registration2_called,
+ &registration2));
ASSERT_FALSE(registration1_called);
ASSERT_FALSE(registration2_called);
@@ -608,20 +598,16 @@ TEST_F(ServiceWorkerJobTest, AbortAll_Register) {
bool registration_called1 = false;
scoped_refptr<ServiceWorkerRegistration> registration1;
job_coordinator()->Register(
- pattern1,
- script_url1,
- NULL,
- SaveRegistration(SERVICE_WORKER_ERROR_ABORT,
- &registration_called1, &registration1));
+ script_url1, ServiceWorkerRegistrationOptions(pattern1), nullptr,
+ SaveRegistration(SERVICE_WORKER_ERROR_ABORT, &registration_called1,
+ &registration1));
bool registration_called2 = false;
scoped_refptr<ServiceWorkerRegistration> registration2;
job_coordinator()->Register(
- pattern2,
- script_url2,
- NULL,
- SaveRegistration(SERVICE_WORKER_ERROR_ABORT,
- &registration_called2, &registration2));
+ script_url2, ServiceWorkerRegistrationOptions(pattern2), nullptr,
+ SaveRegistration(SERVICE_WORKER_ERROR_ABORT, &registration_called2,
+ &registration2));
ASSERT_FALSE(registration_called1);
ASSERT_FALSE(registration_called2);
@@ -683,11 +669,9 @@ TEST_F(ServiceWorkerJobTest, AbortAll_RegUnreg) {
bool registration_called = false;
scoped_refptr<ServiceWorkerRegistration> registration;
job_coordinator()->Register(
- pattern,
- script_url,
- NULL,
- SaveRegistration(SERVICE_WORKER_ERROR_ABORT,
- &registration_called, &registration));
+ script_url, ServiceWorkerRegistrationOptions(pattern), nullptr,
+ SaveRegistration(SERVICE_WORKER_ERROR_ABORT, &registration_called,
+ &registration));
bool unregistration_called = false;
job_coordinator()->Unregister(
@@ -882,9 +866,8 @@ class UpdateJobTestHelper
scoped_refptr<ServiceWorkerRegistration> registration;
bool called = false;
job_coordinator()->Register(
- test_origin.Resolve(kScope),
test_origin.Resolve(kScript),
- NULL,
+ ServiceWorkerRegistrationOptions(test_origin.Resolve(kScope)), nullptr,
SaveRegistration(SERVICE_WORKER_OK, &called, &registration));
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(called);
@@ -1307,8 +1290,8 @@ TEST_F(ServiceWorkerJobTest, Update_UninstallingRegistration) {
// Verify the registration was not modified by the Update.
EXPECT_TRUE(registration->is_uninstalling());
EXPECT_EQ(active_version, registration->active_version());
- EXPECT_EQ(NULL, registration->waiting_version());
- EXPECT_EQ(NULL, registration->installing_version());
+ EXPECT_EQ(nullptr, registration->waiting_version());
+ EXPECT_EQ(nullptr, registration->installing_version());
}
TEST_F(ServiceWorkerJobTest, RegisterWhileUninstalling) {
@@ -1339,7 +1322,7 @@ TEST_F(ServiceWorkerJobTest, RegisterWhileUninstalling) {
registration->waiting_version();
// Verify the new version is installed but not activated yet.
- EXPECT_EQ(NULL, registration->installing_version());
+ EXPECT_EQ(nullptr, registration->installing_version());
EXPECT_TRUE(new_version);
EXPECT_EQ(EmbeddedWorkerStatus::RUNNING, new_version->running_status());
EXPECT_EQ(ServiceWorkerVersion::INSTALLED, new_version->status());
@@ -1351,8 +1334,8 @@ TEST_F(ServiceWorkerJobTest, RegisterWhileUninstalling) {
EXPECT_FALSE(registration->is_uninstalled());
// Verify the new version is activated.
- EXPECT_EQ(NULL, registration->installing_version());
- EXPECT_EQ(NULL, registration->waiting_version());
+ EXPECT_EQ(nullptr, registration->installing_version());
+ EXPECT_EQ(nullptr, registration->waiting_version());
EXPECT_EQ(new_version, registration->active_version());
EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status());
@@ -1450,8 +1433,8 @@ TEST_F(ServiceWorkerJobTest, RegisterSameScriptMultipleTimesWhileUninstalling) {
EXPECT_FALSE(registration->is_uninstalled());
// Verify the new version is activated.
- EXPECT_EQ(NULL, registration->installing_version());
- EXPECT_EQ(NULL, registration->waiting_version());
+ EXPECT_EQ(nullptr, registration->installing_version());
+ EXPECT_EQ(nullptr, registration->waiting_version());
EXPECT_EQ(new_version, registration->active_version());
EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status());
@@ -1506,8 +1489,8 @@ TEST_F(ServiceWorkerJobTest, RegisterMultipleTimesWhileUninstalling) {
EXPECT_FALSE(registration->is_uninstalled());
// Verify the new version is activated.
- EXPECT_EQ(NULL, registration->installing_version());
- EXPECT_EQ(NULL, registration->waiting_version());
+ EXPECT_EQ(nullptr, registration->installing_version());
+ EXPECT_EQ(nullptr, registration->waiting_version());
EXPECT_EQ(third_version, registration->active_version());
EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, third_version->status());
@@ -1592,8 +1575,8 @@ TEST_F(ServiceWorkerJobTest, RemoveControlleeDuringInstall) {
scoped_refptr<ServiceWorkerVersion> new_version =
registration->active_version();
EXPECT_NE(old_version, new_version);
- EXPECT_EQ(NULL, registration->installing_version());
- EXPECT_EQ(NULL, registration->waiting_version());
+ EXPECT_EQ(nullptr, registration->installing_version());
+ EXPECT_EQ(nullptr, registration->waiting_version());
EXPECT_EQ(new_version, registration->active_version());
EXPECT_EQ(EmbeddedWorkerStatus::RUNNING, new_version->running_status());
EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, new_version->status());

Powered by Google App Engine
This is Rietveld 408576698