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

Side by Side Diff: chrome/browser/sync/invalidations/invalidator_storage_unittest.cc

Issue 10824140: Add InvalidationStateTracker::Forget() to erase an entry from storage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix sync_client target Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 syncer::ObjectIdSet to_forget;
89 to_forget.insert(kPreferencesId_);
90 storage.Forget(to_forget);
91 EXPECT_EQ(expected_max_versions, storage.GetAllMaxVersions());
92 }
93
75 // Clearing the storage should result in an empty version map. 94 // Clearing the storage should result in an empty version map.
76 TEST_F(InvalidatorStorageTest, Clear) { 95 TEST_F(InvalidatorStorageTest, Clear) {
77 InvalidatorStorage storage(&pref_service_); 96 InvalidatorStorage storage(&pref_service_);
78 EXPECT_TRUE(storage.GetAllMaxVersions().empty()); 97 EXPECT_TRUE(storage.GetAllMaxVersions().empty());
79 EXPECT_TRUE(storage.GetInvalidationState().empty()); 98 EXPECT_TRUE(storage.GetInvalidationState().empty());
80 99
81 storage.SetInvalidationState("test"); 100 storage.SetInvalidationState("test");
82 EXPECT_EQ("test", storage.GetInvalidationState()); 101 EXPECT_EQ("test", storage.GetInvalidationState());
83 { 102 {
84 InvalidationVersionMap expected_max_versions; 103 InvalidationVersionMap expected_max_versions;
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 TEST_F(InvalidatorStorageTest, SetGetInvalidationState) { 333 TEST_F(InvalidatorStorageTest, SetGetInvalidationState) {
315 InvalidatorStorage storage(&pref_service_); 334 InvalidatorStorage storage(&pref_service_);
316 const std::string mess("n\0tK\0\0l\344", 8); 335 const std::string mess("n\0tK\0\0l\344", 8);
317 ASSERT_FALSE(IsStringUTF8(mess)); 336 ASSERT_FALSE(IsStringUTF8(mess));
318 337
319 storage.SetInvalidationState(mess); 338 storage.SetInvalidationState(mess);
320 EXPECT_EQ(mess, storage.GetInvalidationState()); 339 EXPECT_EQ(mess, storage.GetInvalidationState());
321 } 340 }
322 341
323 } // namespace browser_sync 342 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/invalidations/invalidator_storage.cc ('k') | sync/notifier/chrome_invalidation_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698