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

Unified Diff: components/sync/device_info/device_info_service_unittest.cc

Issue 2455693002: [Sync] On disabling sync, device info records are removed. (Closed)
Patch Set: Adjusting TODOs. Created 4 years, 2 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 | « components/sync/device_info/device_info_service.cc ('k') | components/sync/model/model_type_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/device_info/device_info_service_unittest.cc
diff --git a/components/sync/device_info/device_info_service_unittest.cc b/components/sync/device_info/device_info_service_unittest.cc
index 6b4d4a684222a3a3a12fab90eb910136b0df12ee..010e9dee49fa81a39e5e59a2847d5dfee0766967 100644
--- a/components/sync/device_info/device_info_service_unittest.cc
+++ b/components/sync/device_info/device_info_service_unittest.cc
@@ -760,22 +760,47 @@ TEST_F(DeviceInfoServiceTest, MultipleOnProviderInitialized) {
TEST_F(DeviceInfoServiceTest, SendLocalData) {
InitializeAndPump();
- EXPECT_EQ(1, service()->CountActiveDevices());
EXPECT_EQ(1, change_count());
EXPECT_EQ(1u, processor()->put_multimap().size());
ForcePulse();
- EXPECT_EQ(1, service()->CountActiveDevices());
EXPECT_EQ(2, change_count());
EXPECT_EQ(2u, processor()->put_multimap().size());
+ // After clearing, pulsing should no-op and not result in a processor put or
+ // a notification to observers.
local_device()->Clear();
ForcePulse();
- EXPECT_EQ(1, service()->CountActiveDevices());
EXPECT_EQ(2, change_count());
EXPECT_EQ(2u, processor()->put_multimap().size());
}
+TEST_F(DeviceInfoServiceTest, DisableSync) {
+ InitializeAndPump();
+ EXPECT_EQ(1u, service()->GetAllDeviceInfo().size());
+ EXPECT_EQ(1, change_count());
+
+ DeviceInfoSpecifics specifics = GenerateTestSpecifics();
+ EntityChangeList add_changes;
+ PushBackEntityChangeAdd(specifics, &add_changes);
+ EXPECT_FALSE(
+ service()
maxbogue 2016/10/26 18:18:30 nit: pull the error out onto a separate line to ma
skym 2016/10/26 18:24:35 Done.
+ ->ApplySyncChanges(service()->CreateMetadataChangeList(), add_changes)
+ .IsSet());
+ EXPECT_EQ(2u, service()->GetAllDeviceInfo().size());
+ EXPECT_EQ(2, change_count());
+
+ // Should clear out all local data and notify observers.
+ service()->DisableSync();
+ EXPECT_EQ(0u, service()->GetAllDeviceInfo().size());
+ EXPECT_EQ(3, change_count());
+
+ // Reloading from storage shouldn't contain remote data.
+ RestartService();
+ EXPECT_EQ(1u, service()->GetAllDeviceInfo().size());
+ EXPECT_EQ(4, change_count());
+}
+
} // namespace
} // namespace syncer
« no previous file with comments | « components/sync/device_info/device_info_service.cc ('k') | components/sync/model/model_type_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698