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

Side by Side Diff: chrome/browser/invalidation/invalidator_storage_unittest.cc

Issue 221963003: Reduce dependency of TiclInvalidationService on Profile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix sync_listen_notifications. Created 6 years, 8 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 #include "chrome/browser/invalidation/invalidator_storage.h" 5 #include "chrome/browser/invalidation/invalidator_storage.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "chrome/common/pref_names.h" 9 #include "chrome/common/pref_names.h"
10 #include "chrome/test/base/testing_pref_service_syncable.h" 10 #include "chrome/test/base/testing_pref_service_syncable.h"
(...skipping 14 matching lines...) Expand all
25 TestingPrefServiceSyncable pref_service_; 25 TestingPrefServiceSyncable pref_service_;
26 }; 26 };
27 27
28 // Clearing the storage should erase all version map entries, bootstrap data, 28 // Clearing the storage should erase all version map entries, bootstrap data,
29 // and the client ID. 29 // and the client ID.
30 TEST_F(InvalidatorStorageTest, Clear) { 30 TEST_F(InvalidatorStorageTest, Clear) {
31 InvalidatorStorage storage(&pref_service_); 31 InvalidatorStorage storage(&pref_service_);
32 EXPECT_TRUE(storage.GetBootstrapData().empty()); 32 EXPECT_TRUE(storage.GetBootstrapData().empty());
33 EXPECT_TRUE(storage.GetInvalidatorClientId().empty()); 33 EXPECT_TRUE(storage.GetInvalidatorClientId().empty());
34 34
35 storage.SetInvalidatorClientId("fake_id"); 35 storage.ClearAndSetNewClientId("fake_id");
36 EXPECT_EQ("fake_id", storage.GetInvalidatorClientId()); 36 EXPECT_EQ("fake_id", storage.GetInvalidatorClientId());
37 37
38 storage.SetBootstrapData("test"); 38 storage.SetBootstrapData("test");
39 EXPECT_EQ("test", storage.GetBootstrapData()); 39 EXPECT_EQ("test", storage.GetBootstrapData());
40 40
41 storage.Clear(); 41 storage.Clear();
42 42
43 EXPECT_TRUE(storage.GetBootstrapData().empty()); 43 EXPECT_TRUE(storage.GetBootstrapData().empty());
44 EXPECT_TRUE(storage.GetInvalidatorClientId().empty()); 44 EXPECT_TRUE(storage.GetInvalidatorClientId().empty());
45 } 45 }
46 46
47 TEST_F(InvalidatorStorageTest, SetGetNotifierClientId) { 47 TEST_F(InvalidatorStorageTest, SetGetNotifierClientId) {
48 InvalidatorStorage storage(&pref_service_); 48 InvalidatorStorage storage(&pref_service_);
49 const std::string client_id("fK6eDzAIuKqx9A4+93bljg=="); 49 const std::string client_id("fK6eDzAIuKqx9A4+93bljg==");
50 50
51 storage.SetInvalidatorClientId(client_id); 51 storage.ClearAndSetNewClientId(client_id);
52 EXPECT_EQ(client_id, storage.GetInvalidatorClientId()); 52 EXPECT_EQ(client_id, storage.GetInvalidatorClientId());
53 } 53 }
54 54
55 TEST_F(InvalidatorStorageTest, SetGetBootstrapData) { 55 TEST_F(InvalidatorStorageTest, SetGetBootstrapData) {
56 InvalidatorStorage storage(&pref_service_); 56 InvalidatorStorage storage(&pref_service_);
57 const std::string mess("n\0tK\0\0l\344", 8); 57 const std::string mess("n\0tK\0\0l\344", 8);
58 ASSERT_FALSE(IsStringUTF8(mess)); 58 ASSERT_FALSE(IsStringUTF8(mess));
59 59
60 storage.SetBootstrapData(mess); 60 storage.SetBootstrapData(mess);
61 EXPECT_EQ(mess, storage.GetBootstrapData()); 61 EXPECT_EQ(mess, storage.GetBootstrapData());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 map.insert(std::make_pair(storage2.object_id(), storage2)); 95 map.insert(std::make_pair(storage2.object_id(), storage2));
96 96
97 storage.SetSavedInvalidations(map); 97 storage.SetSavedInvalidations(map);
98 syncer::UnackedInvalidationsMap restored_map = 98 syncer::UnackedInvalidationsMap restored_map =
99 storage.GetSavedInvalidations(); 99 storage.GetSavedInvalidations();
100 100
101 EXPECT_THAT(map, syncer::test_util::Eq(restored_map)); 101 EXPECT_THAT(map, syncer::test_util::Eq(restored_map));
102 } 102 }
103 103
104 } // namespace invalidation 104 } // namespace invalidation
OLDNEW
« no previous file with comments | « chrome/browser/invalidation/invalidator_storage.cc ('k') | chrome/browser/invalidation/ticl_invalidation_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698