| Index: content/browser/background_sync/background_sync_manager_unittest.cc
|
| diff --git a/content/browser/background_sync/background_sync_manager_unittest.cc b/content/browser/background_sync/background_sync_manager_unittest.cc
|
| index a118418dcf9e6addef20673fc918833e5c75aa5a..27c5c751ccc5cc208533e01c2efc5f60cf8e1173 100644
|
| --- a/content/browser/background_sync/background_sync_manager_unittest.cc
|
| +++ b/content/browser/background_sync/background_sync_manager_unittest.cc
|
| @@ -18,6 +18,7 @@
|
| #include "content/browser/service_worker/service_worker_context_wrapper.h"
|
| #include "content/browser/service_worker/service_worker_storage.h"
|
| #include "content/public/test/test_browser_thread_bundle.h"
|
| +#include "content/public/test/test_utils.h"
|
| #include "net/base/network_change_notifier.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -29,16 +30,16 @@ const char kPattern1[] = "https://example.com/a";
|
| const char kPattern2[] = "https://example.com/b";
|
| const char kScript1[] = "https://example.com/a/script.js";
|
| const char kScript2[] = "https://example.com/b/script.js";
|
| -const int kRenderProcessId = 99;
|
|
|
| -void RegisterServiceWorkerCallback(bool* called,
|
| - int64* store_registration_id,
|
| - ServiceWorkerStatusCode status,
|
| - const std::string& status_message,
|
| - int64 registration_id) {
|
| +void RegisterServiceWorkerCallback(
|
| + const scoped_refptr<MessageLoopRunner>& runner,
|
| + int64* store_registration_id,
|
| + ServiceWorkerStatusCode status,
|
| + const std::string& status_message,
|
| + int64 registration_id) {
|
| EXPECT_EQ(SERVICE_WORKER_OK, status) << ServiceWorkerStatusToString(status);
|
| - *called = true;
|
| *store_registration_id = registration_id;
|
| + runner->Quit();
|
| }
|
|
|
| void FindServiceWorkerRegistrationCallback(
|
| @@ -220,8 +221,7 @@ class BackgroundSyncManagerTest : public testing::Test {
|
| }
|
|
|
| void SetUp() override {
|
| - helper_.reset(
|
| - new EmbeddedWorkerTestHelper(base::FilePath(), kRenderProcessId));
|
| + helper_.reset(new EmbeddedWorkerTestHelper(base::FilePath()));
|
|
|
| power_monitor_source_ = new TestPowerSource();
|
| // power_monitor_ takes ownership of power_monitor_source.
|
| @@ -239,20 +239,20 @@ class BackgroundSyncManagerTest : public testing::Test {
|
| }
|
|
|
| void RegisterServiceWorkers() {
|
| - bool called_1 = false;
|
| - bool called_2 = false;
|
| + scoped_refptr<MessageLoopRunner> runner_1(new MessageLoopRunner);
|
| + scoped_refptr<MessageLoopRunner> runner_2(new MessageLoopRunner);
|
| helper_->context()->RegisterServiceWorker(
|
| GURL(kPattern1), GURL(kScript1), NULL,
|
| - base::Bind(&RegisterServiceWorkerCallback, &called_1,
|
| + base::Bind(&RegisterServiceWorkerCallback, runner_1,
|
| &sw_registration_id_1_));
|
|
|
| helper_->context()->RegisterServiceWorker(
|
| GURL(kPattern2), GURL(kScript2), NULL,
|
| - base::Bind(&RegisterServiceWorkerCallback, &called_2,
|
| + base::Bind(&RegisterServiceWorkerCallback, runner_2,
|
| &sw_registration_id_2_));
|
| - base::RunLoop().RunUntilIdle();
|
| - EXPECT_TRUE(called_1);
|
| - EXPECT_TRUE(called_2);
|
| +
|
| + runner_1->Run();
|
| + runner_2->Run();
|
|
|
| // Hang onto the registrations as they need to be "live" when
|
| // calling BackgroundSyncManager::Register.
|
|
|