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

Unified Diff: content/browser/background_sync/background_sync_manager_unittest.cc

Issue 1223193009: WIP attempt to replace StartWorker/StopWorker IPCs with a new mojo EmbeddedWorker service. Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-event-dispatching-option2
Patch Set: Created 5 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
« no previous file with comments | « no previous file | content/browser/background_sync/background_sync_service_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | content/browser/background_sync/background_sync_service_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698