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

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

Issue 1294603003: [BackgroundSync] Trigger Background Sync events when Chrome is backgrounded on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't register observers with nonexistant Autodetector 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
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 4817b0c0db90e80f1c18bb0321287578c11ba66e..72db49fc0f5acf441b93fb32b27813b9ee0affd0 100644
--- a/content/browser/background_sync/background_sync_manager_unittest.cc
+++ b/content/browser/background_sync/background_sync_manager_unittest.cc
@@ -14,6 +14,7 @@
#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_network_observer.h"
#include "content/browser/background_sync/background_sync_registration_handle.h"
#include "content/browser/background_sync/background_sync_status.h"
#include "content/browser/browser_thread_impl.h"
@@ -233,6 +234,9 @@ class BackgroundSyncManagerTest : public testing::Test {
}
void SetUp() override {
+ // Don't let the tests be confused by the real-world device connectivity
+ BackgroundSyncNetworkObserver::SetIgnoreNetworkChangeNotifierForTests(true);
+
helper_.reset(
new EmbeddedWorkerTestHelper(base::FilePath(), kRenderProcessId));
@@ -251,6 +255,12 @@ class BackgroundSyncManagerTest : public testing::Test {
RegisterServiceWorkers();
}
+ void TearDown() override {
+ // Restore the network observer functionality for subsequent tests
+ BackgroundSyncNetworkObserver::SetIgnoreNetworkChangeNotifierForTests(
+ false);
+ }
+
void RegisterServiceWorkers() {
bool called_1 = false;
bool called_2 = false;
@@ -304,7 +314,12 @@ class BackgroundSyncManagerTest : public testing::Test {
void SetNetwork(net::NetworkChangeNotifier::ConnectionType connection_type) {
net::NetworkChangeNotifier::NotifyObserversOfNetworkChangeForTests(
connection_type);
- base::RunLoop().RunUntilIdle();
+ if (test_background_sync_manager_) {
+ BackgroundSyncNetworkObserver* network_observer =
+ test_background_sync_manager_->GetNetworkObserverForTesting();
+ network_observer->NotifyManagerIfNetworkChanged(connection_type);
+ base::RunLoop().RunUntilIdle();
+ }
}
void SetOnBatteryPower(bool on_battery_power) {

Powered by Google App Engine
This is Rietveld 408576698