| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 | 5 |
| 6 #include "chrome/browser/sync/invalidations/invalidator_storage.h" | 6 #include "chrome/browser/sync/invalidations/invalidator_storage.h" |
| 7 | 7 |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 expected_max_versions[kAppNotificationsId_] = 3; | 66 expected_max_versions[kAppNotificationsId_] = 3; |
| 67 storage.SetMaxVersion(kAppNotificationsId_, 3); | 67 storage.SetMaxVersion(kAppNotificationsId_, 3); |
| 68 EXPECT_EQ(expected_max_versions, storage.GetAllMaxVersions()); | 68 EXPECT_EQ(expected_max_versions, storage.GetAllMaxVersions()); |
| 69 | 69 |
| 70 expected_max_versions[kAppNotificationsId_] = 4; | 70 expected_max_versions[kAppNotificationsId_] = 4; |
| 71 storage.SetMaxVersion(kAppNotificationsId_, 4); | 71 storage.SetMaxVersion(kAppNotificationsId_, 4); |
| 72 EXPECT_EQ(expected_max_versions, storage.GetAllMaxVersions()); | 72 EXPECT_EQ(expected_max_versions, storage.GetAllMaxVersions()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 // Forgetting an entry should cause that entry to be deleted. |
| 76 TEST_F(InvalidatorStorageTest, Forget) { |
| 77 InvalidatorStorage storage(&pref_service_); |
| 78 EXPECT_TRUE(storage.GetAllMaxVersions().empty()); |
| 79 |
| 80 InvalidationVersionMap expected_max_versions; |
| 81 expected_max_versions[kBookmarksId_] = 2; |
| 82 expected_max_versions[kPreferencesId_] = 5; |
| 83 storage.SetMaxVersion(kBookmarksId_, 2); |
| 84 storage.SetMaxVersion(kPreferencesId_, 5); |
| 85 EXPECT_EQ(expected_max_versions, storage.GetAllMaxVersions()); |
| 86 |
| 87 expected_max_versions.erase(kPreferencesId_); |
| 88 storage.Forget(kPreferencesId_); |
| 89 EXPECT_EQ(expected_max_versions, storage.GetAllMaxVersions()); |
| 90 } |
| 91 |
| 75 // Clearing the storage should result in an empty version map. | 92 // Clearing the storage should result in an empty version map. |
| 76 TEST_F(InvalidatorStorageTest, Clear) { | 93 TEST_F(InvalidatorStorageTest, Clear) { |
| 77 InvalidatorStorage storage(&pref_service_); | 94 InvalidatorStorage storage(&pref_service_); |
| 78 EXPECT_TRUE(storage.GetAllMaxVersions().empty()); | 95 EXPECT_TRUE(storage.GetAllMaxVersions().empty()); |
| 79 EXPECT_TRUE(storage.GetInvalidationState().empty()); | 96 EXPECT_TRUE(storage.GetInvalidationState().empty()); |
| 80 | 97 |
| 81 storage.SetInvalidationState("test"); | 98 storage.SetInvalidationState("test"); |
| 82 EXPECT_EQ("test", storage.GetInvalidationState()); | 99 EXPECT_EQ("test", storage.GetInvalidationState()); |
| 83 { | 100 { |
| 84 InvalidationVersionMap expected_max_versions; | 101 InvalidationVersionMap expected_max_versions; |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 TEST_F(InvalidatorStorageTest, SetGetInvalidationState) { | 331 TEST_F(InvalidatorStorageTest, SetGetInvalidationState) { |
| 315 InvalidatorStorage storage(&pref_service_); | 332 InvalidatorStorage storage(&pref_service_); |
| 316 const std::string mess("n\0tK\0\0l\344", 8); | 333 const std::string mess("n\0tK\0\0l\344", 8); |
| 317 ASSERT_FALSE(IsStringUTF8(mess)); | 334 ASSERT_FALSE(IsStringUTF8(mess)); |
| 318 | 335 |
| 319 storage.SetInvalidationState(mess); | 336 storage.SetInvalidationState(mess); |
| 320 EXPECT_EQ(mess, storage.GetInvalidationState()); | 337 EXPECT_EQ(mess, storage.GetInvalidationState()); |
| 321 } | 338 } |
| 322 | 339 |
| 323 } // namespace browser_sync | 340 } // namespace browser_sync |
| OLD | NEW |