| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Syncer unit tests. Unfortunately a lot of these tests | 5 // Syncer unit tests. Unfortunately a lot of these tests |
| 6 // are outdated and need to be reworked and updated. | 6 // are outdated and need to be reworked and updated. |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 using syncable::GetOnlyEntryWithName; | 78 using syncable::GetOnlyEntryWithName; |
| 79 using syncable::Id; | 79 using syncable::Id; |
| 80 using syncable::kEncryptedString; | 80 using syncable::kEncryptedString; |
| 81 using syncable::MutableEntry; | 81 using syncable::MutableEntry; |
| 82 using syncable::WriteTransaction; | 82 using syncable::WriteTransaction; |
| 83 | 83 |
| 84 using syncable::CREATE; | 84 using syncable::CREATE; |
| 85 using syncable::GET_BY_HANDLE; | 85 using syncable::GET_BY_HANDLE; |
| 86 using syncable::GET_BY_ID; | 86 using syncable::GET_BY_ID; |
| 87 using syncable::GET_BY_CLIENT_TAG; | 87 using syncable::GET_BY_CLIENT_TAG; |
| 88 using syncable::GET_BY_SERVER_TAG; | 88 using syncable::GET_BY_SERVER_TAG_DEPRECATED; |
| 89 using syncable::GET_TYPE_ROOT; |
| 89 using syncable::UNITTEST; | 90 using syncable::UNITTEST; |
| 90 | 91 |
| 91 using sessions::MockDebugInfoGetter; | 92 using sessions::MockDebugInfoGetter; |
| 92 using sessions::StatusController; | 93 using sessions::StatusController; |
| 93 using sessions::SyncSessionContext; | 94 using sessions::SyncSessionContext; |
| 94 using sessions::SyncSession; | 95 using sessions::SyncSession; |
| 95 | 96 |
| 96 namespace { | 97 namespace { |
| 97 | 98 |
| 98 // A helper to hold on to the counters emitted by the sync engine. | 99 // A helper to hold on to the counters emitted by the sync engine. |
| (...skipping 4034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4133 int64 hurdle_handle = CreateUnsyncedDirectory("bob", "id_bob"); | 4134 int64 hurdle_handle = CreateUnsyncedDirectory("bob", "id_bob"); |
| 4134 { | 4135 { |
| 4135 syncable::ReadTransaction trans(FROM_HERE, directory()); | 4136 syncable::ReadTransaction trans(FROM_HERE, directory()); |
| 4136 Entry hurdle(&trans, GET_BY_HANDLE, hurdle_handle); | 4137 Entry hurdle(&trans, GET_BY_HANDLE, hurdle_handle); |
| 4137 ASSERT_TRUE(hurdle.good()); | 4138 ASSERT_TRUE(hurdle.good()); |
| 4138 ASSERT_TRUE(!hurdle.GetIsDel()); | 4139 ASSERT_TRUE(!hurdle.GetIsDel()); |
| 4139 ASSERT_TRUE(hurdle.GetUniqueServerTag().empty()); | 4140 ASSERT_TRUE(hurdle.GetUniqueServerTag().empty()); |
| 4140 ASSERT_TRUE(hurdle.GetNonUniqueName()== "bob"); | 4141 ASSERT_TRUE(hurdle.GetNonUniqueName()== "bob"); |
| 4141 | 4142 |
| 4142 // Try to lookup by the tagname. These should fail. | 4143 // Try to lookup by the tagname. These should fail. |
| 4143 Entry tag_alpha(&trans, GET_BY_SERVER_TAG, "alpha"); | 4144 Entry tag_alpha(&trans, GET_BY_SERVER_TAG_DEPRECATED, "alpha"); |
| 4144 EXPECT_FALSE(tag_alpha.good()); | 4145 EXPECT_FALSE(tag_alpha.good()); |
| 4145 Entry tag_bob(&trans, GET_BY_SERVER_TAG, "bob"); | 4146 Entry tag_bob(&trans, GET_BY_SERVER_TAG_DEPRECATED, "bob"); |
| 4146 EXPECT_FALSE(tag_bob.good()); | 4147 EXPECT_FALSE(tag_bob.good()); |
| 4147 } | 4148 } |
| 4148 | 4149 |
| 4149 // Now download some tagged items as updates. | 4150 // Now download some tagged items as updates. |
| 4150 mock_server_->AddUpdateDirectory( | 4151 mock_server_->AddUpdateDirectory( |
| 4151 1, 0, "update1", 1, 10, std::string(), std::string()); | 4152 1, 0, "update1", 1, 10, std::string(), std::string()); |
| 4152 mock_server_->SetLastUpdateServerTag("alpha"); | 4153 mock_server_->SetLastUpdateServerTag("alpha"); |
| 4153 mock_server_->AddUpdateDirectory( | 4154 mock_server_->AddUpdateDirectory( |
| 4154 2, 0, "update2", 2, 20, std::string(), std::string()); | 4155 2, 0, "update2", 2, 20, std::string(), std::string()); |
| 4155 mock_server_->SetLastUpdateServerTag("bob"); | 4156 mock_server_->SetLastUpdateServerTag("bob"); |
| 4156 SyncShareNudge(); | 4157 SyncShareNudge(); |
| 4157 | 4158 |
| 4158 { | 4159 { |
| 4159 syncable::ReadTransaction trans(FROM_HERE, directory()); | 4160 syncable::ReadTransaction trans(FROM_HERE, directory()); |
| 4160 | 4161 |
| 4161 // The new items should be applied as new entries, and we should be able | 4162 // The new items should be applied as new entries, and we should be able |
| 4162 // to look them up by their tag values. | 4163 // to look them up by their tag values. |
| 4163 Entry tag_alpha(&trans, GET_BY_SERVER_TAG, "alpha"); | 4164 Entry tag_alpha(&trans, GET_BY_SERVER_TAG_DEPRECATED, "alpha"); |
| 4164 ASSERT_TRUE(tag_alpha.good()); | 4165 ASSERT_TRUE(tag_alpha.good()); |
| 4165 ASSERT_TRUE(!tag_alpha.GetIsDel()); | 4166 ASSERT_TRUE(!tag_alpha.GetIsDel()); |
| 4166 ASSERT_TRUE(tag_alpha.GetUniqueServerTag()== "alpha"); | 4167 ASSERT_TRUE(tag_alpha.GetUniqueServerTag()== "alpha"); |
| 4167 ASSERT_TRUE(tag_alpha.GetNonUniqueName()== "update1"); | 4168 ASSERT_TRUE(tag_alpha.GetNonUniqueName()== "update1"); |
| 4168 Entry tag_bob(&trans, GET_BY_SERVER_TAG, "bob"); | 4169 Entry tag_bob(&trans, GET_BY_SERVER_TAG_DEPRECATED, "bob"); |
| 4169 ASSERT_TRUE(tag_bob.good()); | 4170 ASSERT_TRUE(tag_bob.good()); |
| 4170 ASSERT_TRUE(!tag_bob.GetIsDel()); | 4171 ASSERT_TRUE(!tag_bob.GetIsDel()); |
| 4171 ASSERT_TRUE(tag_bob.GetUniqueServerTag()== "bob"); | 4172 ASSERT_TRUE(tag_bob.GetUniqueServerTag()== "bob"); |
| 4172 ASSERT_TRUE(tag_bob.GetNonUniqueName()== "update2"); | 4173 ASSERT_TRUE(tag_bob.GetNonUniqueName()== "update2"); |
| 4173 // The old item should be unchanged. | 4174 // The old item should be unchanged. |
| 4174 Entry hurdle(&trans, GET_BY_HANDLE, hurdle_handle); | 4175 Entry hurdle(&trans, GET_BY_HANDLE, hurdle_handle); |
| 4175 ASSERT_TRUE(hurdle.good()); | 4176 ASSERT_TRUE(hurdle.good()); |
| 4176 ASSERT_TRUE(!hurdle.GetIsDel()); | 4177 ASSERT_TRUE(!hurdle.GetIsDel()); |
| 4177 ASSERT_TRUE(hurdle.GetUniqueServerTag().empty()); | 4178 ASSERT_TRUE(hurdle.GetUniqueServerTag().empty()); |
| 4178 ASSERT_TRUE(hurdle.GetNonUniqueName()== "bob"); | 4179 ASSERT_TRUE(hurdle.GetNonUniqueName()== "bob"); |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4961 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); | 4962 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); |
| 4962 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); | 4963 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); |
| 4963 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); | 4964 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); |
| 4964 } else { | 4965 } else { |
| 4965 EXPECT_TRUE(final_monitor_records.empty()) | 4966 EXPECT_TRUE(final_monitor_records.empty()) |
| 4966 << "Should not restore records after successful bookmark commit."; | 4967 << "Should not restore records after successful bookmark commit."; |
| 4967 } | 4968 } |
| 4968 } | 4969 } |
| 4969 | 4970 |
| 4970 } // namespace syncer | 4971 } // namespace syncer |
| OLD | NEW |