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

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

Issue 1376533002: [BackgroundSync] Add ability to disable Background Sync via Field Trial (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit Created 5 years, 3 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 | « content/browser/background_sync/background_sync_manager.cc ('k') | no next file » | 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 0a47c6ce73b026d3ca1539de7961cf6a96e7c09b..f7f301655dbd75fe9d4dc6385410b061d460dfb8 100644
--- a/content/browser/background_sync/background_sync_manager_unittest.cc
+++ b/content/browser/background_sync/background_sync_manager_unittest.cc
@@ -7,10 +7,12 @@
#include "base/files/scoped_temp_dir.h"
#include "base/location.h"
#include "base/logging.h"
+#include "base/metrics/field_trial.h"
#include "base/power_monitor/power_monitor.h"
#include "base/power_monitor/power_monitor_source.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
+#include "base/test/mock_entropy_provider.h"
#include "base/thread_task_runner_handle.h"
#include "content/browser/background_sync/background_sync_registration_handle.h"
#include "content/browser/background_sync/background_sync_status.h"
@@ -1515,4 +1517,26 @@ TEST_F(BackgroundSyncManagerTest, UnregisterSucceedsWithoutWindow) {
EXPECT_FALSE(GetRegistration(sync_options_1_));
}
+TEST_F(BackgroundSyncManagerTest, FieldTrialDisablesManager) {
+ EXPECT_TRUE(Register(sync_options_1_));
+
+ base::FieldTrialList field_trial_list(new base::MockEntropyProvider());
+ base::FieldTrialList::CreateFieldTrial("BackgroundSync",
+ "ExperimentDisabled");
+
+ EXPECT_FALSE(Register(sync_options_2_));
+ EXPECT_EQ(BACKGROUND_SYNC_STATUS_STORAGE_ERROR, callback_status_);
+
+ // If the service worker is wiped and the manager is restarted, the manager
+ // should disable itself on init.
+ test_background_sync_manager_->set_corrupt_backend(false);
+ helper_->context()->ScheduleDeleteAndStartOver();
+ base::RunLoop().RunUntilIdle();
+
+ RegisterServiceWorkers();
+
+ EXPECT_FALSE(GetRegistrations(SYNC_ONE_SHOT));
+ EXPECT_EQ(BACKGROUND_SYNC_STATUS_STORAGE_ERROR, callback_status_);
+}
+
} // namespace content
« no previous file with comments | « content/browser/background_sync/background_sync_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698