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

Unified Diff: chrome/browser/sync/glue/sync_backend_host_unittest.cc

Issue 12022041: Separate local and remote sync invalidations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 11 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 | « chrome/browser/sync/glue/sync_backend_host.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/glue/sync_backend_host_unittest.cc
diff --git a/chrome/browser/sync/glue/sync_backend_host_unittest.cc b/chrome/browser/sync/glue/sync_backend_host_unittest.cc
index 90761c954cffb02d5abdd2aec916763a06450727..1b2abfdc2cedf38c2f128ae1789c5263f1c2e4ff 100644
--- a/chrome/browser/sync/glue/sync_backend_host_unittest.cc
+++ b/chrome/browser/sync/glue/sync_backend_host_unittest.cc
@@ -15,7 +15,9 @@
#include "chrome/browser/sync/glue/synced_device_tracker.h"
#include "chrome/browser/sync/invalidations/invalidator_storage.h"
#include "chrome/browser/sync/sync_prefs.h"
+#include "chrome/common/chrome_notification_types.h"
#include "chrome/test/base/testing_profile.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/test/test_browser_thread.h"
#include "google/cacheinvalidation/include/types.h"
#include "googleurl/src/gurl.h"
@@ -229,6 +231,19 @@ class SyncBackendHostTest : public testing::Test {
ui_loop_.Run();
}
+ void IssueRefreshRequest(syncer::ModelTypeSet types) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ syncer::ModelTypeInvalidationMap invalidation_map(
+ ModelTypeSetToInvalidationMap(types, std::string()));
+
+ content::NotificationService::current()->Notify(
+ chrome::NOTIFICATION_SYNC_REFRESH_LOCAL,
+ content::Source<Profile>(profile_.get()),
+ content::Details<syncer::ModelTypeInvalidationMap>(
+ &invalidation_map));
+ }
+
protected:
void DownloadReady(syncer::ModelTypeSet types) {
MessageLoop::current()->Quit();
@@ -690,6 +705,47 @@ TEST_F(SyncBackendHostTest, SilentlyFailToDownloadControlTypes) {
InitializeBackend(false);
}
+// Test that local refresh requests are delivered to sync.
+TEST_F(SyncBackendHostTest, ForwardLocalRefreshRequest) {
+ InitializeBackend(true);
+
+ syncer::ModelTypeSet set1 = syncer::ModelTypeSet::All();
+ IssueRefreshRequest(set1);
+ fake_manager_->WaitForSyncThread();
+ EXPECT_TRUE(set1.Equals(fake_manager_->GetLastRefreshRequestTypes()));
+
+ syncer::ModelTypeSet set2 = syncer::ModelTypeSet(syncer::SESSIONS);
+ IssueRefreshRequest(set2);
+ fake_manager_->WaitForSyncThread();
+ EXPECT_TRUE(set2.Equals(fake_manager_->GetLastRefreshRequestTypes()));
+}
+
+// Test that local invalidations issued before sync is initialized are ignored.
+TEST_F(SyncBackendHostTest, AttemptForwardLocalRefreshRequestEarly) {
+ syncer::ModelTypeSet set1 = syncer::ModelTypeSet::All();
+ IssueRefreshRequest(set1);
+
+ InitializeBackend(true);
+
+ fake_manager_->WaitForSyncThread();
+ EXPECT_FALSE(set1.Equals(fake_manager_->GetLastRefreshRequestTypes()));
+}
+
+// Test that local invalidations issued while sync is shutting down are ignored.
+TEST_F(SyncBackendHostTest, AttemptForwardLocalRefreshRequestLate) {
+ InitializeBackend(true);
+
+ backend_->StopSyncingForShutdown();
+
+ syncer::ModelTypeSet types = syncer::ModelTypeSet::All();
+ IssueRefreshRequest(types);
+ fake_manager_->WaitForSyncThread();
+ EXPECT_FALSE(types.Equals(fake_manager_->GetLastRefreshRequestTypes()));
+
+ backend_->Shutdown(false);
+ backend_.reset();
+}
+
} // namespace
} // namespace browser_sync
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698