Index: sync/internal_api/sync_manager_impl_unittest.cc |
diff --git a/sync/internal_api/sync_manager_impl_unittest.cc b/sync/internal_api/sync_manager_impl_unittest.cc |
index 9f5538eb7d51d6be0fe8155178ae800d2e49d85d..c4410577ababe1e299781468375175c4928fa7aa 100644 |
--- a/sync/internal_api/sync_manager_impl_unittest.cc |
+++ b/sync/internal_api/sync_manager_impl_unittest.cc |
@@ -753,7 +753,6 @@ class SyncManagerTest : public testing::Test, |
sync_manager_.Init(temp_dir_.path(), |
WeakHandle<JsEventHandler>(), |
"bogus", 0, false, |
- base::MessageLoopProxy::current(), |
scoped_ptr<HttpPostProviderFactory>( |
new TestHttpPostProviderFactory()), |
workers, &extensions_activity_monitor_, this, |
@@ -791,6 +790,7 @@ class SyncManagerTest : public testing::Test, |
void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { |
(*out)[NIGORI] = GROUP_PASSIVE; |
+ (*out)[DEVICE_INFO] = GROUP_PASSIVE; |
(*out)[BOOKMARKS] = GROUP_PASSIVE; |
(*out)[THEMES] = GROUP_PASSIVE; |
(*out)[SESSIONS] = GROUP_PASSIVE; |
@@ -1189,7 +1189,7 @@ TEST_F(SyncManagerTest, GetChildNodeIds) { |
const ListValue* nodes = NULL; |
ASSERT_TRUE(return_args.Get().GetList(0, &nodes)); |
ASSERT_TRUE(nodes); |
- EXPECT_EQ(6u, nodes->GetSize()); |
+ EXPECT_EQ(7u, nodes->GetSize()); |
} |
TEST_F(SyncManagerTest, GetChildNodeIdsFailure) { |
@@ -1349,6 +1349,84 @@ TEST_F(SyncManagerTest, OnIncomingNotification) { |
PumpLoop(); |
} |
+#if 0 // FIXME -> Move these |
Nicolas Zea
2012/09/13 00:45:55
did you mean to leave this?
rlarocque
2012/09/14 01:03:07
Nope, that was a mistake. The tests have already
|
+// New client scenario: set device info when no previous info existed. |
+TEST_F(SyncManagerTest, CreateNewDeviceInfo) { |
+ UserShare* share = sync_manager_.GetUserShare(); |
+ const std::string version("v1"); |
+ const std::string session_name("session"); |
+ sync_pb::DeviceInfoSpecifics device_info; |
+ |
+ ASSERT_FALSE(GetDeviceInfo(share->directory.get(), &device_info)); |
+ |
+ UpdateDeviceInfo(version, session_name); |
+ |
+ ASSERT_TRUE(GetDeviceInfo(share->directory.get(), &device_info)); |
+ |
+ EXPECT_EQ(version, device_info.chrome_version()); |
+ EXPECT_EQ(session_name, device_info.name()); |
+ EXPECT_EQ(share->directory->cache_guid(), device_info.cache_guid()); |
+} |
+ |
+// Restart scenario: update existing device info with identical data. |
+TEST_F(SyncManagerTest, DontModifyExistingDeviceInfo) { |
+ UserShare* share = sync_manager_.GetUserShare(); |
+ const std::string version("v1"); |
+ const std::string session_name("session"); |
+ sync_pb::DeviceInfoSpecifics old_device_info; |
+ sync_pb::DeviceInfoSpecifics new_device_info; |
+ |
+ UpdateDeviceInfo(version, session_name); |
+ ASSERT_TRUE(GetDeviceInfo(share->directory.get(), &old_device_info)); |
+ |
+ // Pretend we committed by unsetting all unsynced bits. |
+ share->directory->SetInvariantCheckLevel(syncable::OFF); |
+ { |
+ syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, |
+ share->directory.get()); |
+ syncable::Directory::UnsyncedMetaHandles handles; |
+ share->directory->GetUnsyncedMetaHandles(&trans, &handles); |
+ |
+ for (syncable::Directory::UnsyncedMetaHandles::iterator it = |
+ handles.begin(); it != handles.end(); ++it) { |
+ syncable::MutableEntry entry(&trans, syncable::GET_BY_HANDLE, *it); |
+ entry.Put(syncable::IS_UNSYNCED, false); |
+ } |
+ |
+ ASSERT_EQ(0, share->directory->unsynced_entity_count()); |
+ } |
+ |
+ // Overwrite the device info with the same data as before. |
+ UpdateDeviceInfo(version, session_name); |
+ ASSERT_TRUE(GetDeviceInfo(share->directory.get(), &new_device_info)); |
+ |
+ // Ensure that this didn't count as a change worth syncing. |
+ EXPECT_EQ(0, share->directory->unsynced_entity_count()); |
+ EXPECT_EQ(old_device_info.SerializeAsString(), |
+ new_device_info.SerializeAsString()); |
+ |
+ EXPECT_EQ(old_device_info.chrome_version(), new_device_info.chrome_version()); |
+ EXPECT_EQ(old_device_info.name(), new_device_info.name()); |
+ EXPECT_EQ(old_device_info.cache_guid(), new_device_info.cache_guid()); |
+} |
+ |
+// Upgrade scenario: update existing device info with new version. |
+TEST_F(SyncManagerTest, UpdateExistingDeviceInfo) { |
+ UserShare* share = sync_manager_.GetUserShare(); |
+ const std::string old_version("v1"); |
+ const std::string new_version("v2"); |
+ const std::string session_name("session"); |
+ sync_pb::DeviceInfoSpecifics device_info; |
+ |
+ UpdateDeviceInfo(old_version, session_name); |
+ UpdateDeviceInfo(new_version, session_name); |
+ |
+ GetDeviceInfo(share->directory.get(), &device_info); |
+ |
+ EXPECT_EQ(new_version, device_info.chrome_version()); |
+} |
+#endif |
+ |
TEST_F(SyncManagerTest, RefreshEncryptionReady) { |
EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION)); |
EXPECT_CALL(encryption_observer_, OnEncryptionComplete()); |