Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 // | |
| 5 | |
| 6 #include "chrome/browser/sync/invalidations/invalidator_storage.h" | |
| 7 | |
| 8 #include "base/message_loop.h" | |
| 9 #include "chrome/test/base/testing_pref_service.h" | |
| 10 #include "sync/syncable/model_type.h" | |
| 11 #include "testing/gmock/include/gmock/gmock.h" | |
| 12 #include "testing/gtest/include/gtest/gtest.h" | |
| 13 | |
| 14 namespace browser_sync { | |
| 15 | |
| 16 class InvalidatorStorageTest : public testing::Test { | |
|
rlarocque
2012/05/29 18:28:24
I'd like to see some tests for the parsing code.
tim (not reviewing)
2012/05/29 23:17:31
Get and Set actually deserialize and serialize fro
| |
| 17 protected: | |
| 18 TestingPrefService pref_service_; | |
| 19 | |
| 20 private: | |
| 21 MessageLoop loop_; | |
| 22 }; | |
| 23 | |
| 24 TEST_F(InvalidatorStorageTest, MaxInvalidationVersions) { | |
| 25 InvalidatorStorage storage(&pref_service_); | |
| 26 | |
| 27 sync_notifier::InvalidationVersionMap expected_max_versions; | |
| 28 EXPECT_EQ(expected_max_versions, storage.GetAllMaxVersions()); | |
| 29 | |
| 30 expected_max_versions[syncable::BOOKMARKS] = 2; | |
| 31 storage.SetMaxVersion(syncable::BOOKMARKS, 2); | |
| 32 EXPECT_EQ(expected_max_versions, storage.GetAllMaxVersions()); | |
| 33 | |
| 34 expected_max_versions[syncable::PREFERENCES] = 5; | |
| 35 storage.SetMaxVersion(syncable::PREFERENCES, 5); | |
| 36 EXPECT_EQ(expected_max_versions, storage.GetAllMaxVersions()); | |
| 37 | |
| 38 expected_max_versions[syncable::APP_NOTIFICATIONS] = 3; | |
| 39 storage.SetMaxVersion(syncable::APP_NOTIFICATIONS, 3); | |
| 40 EXPECT_EQ(expected_max_versions, storage.GetAllMaxVersions()); | |
| 41 | |
| 42 expected_max_versions[syncable::APP_NOTIFICATIONS] = 4; | |
| 43 storage.SetMaxVersion(syncable::APP_NOTIFICATIONS, 4); | |
| 44 EXPECT_EQ(expected_max_versions, storage.GetAllMaxVersions()); | |
| 45 } | |
| 46 | |
| 47 TEST_F(InvalidatorStorageTest, Clear) { | |
| 48 InvalidatorStorage storage(&pref_service_); | |
| 49 EXPECT_TRUE(storage.GetAllMaxVersions().empty()); | |
| 50 EXPECT_TRUE(storage.GetInvalidationState().empty()); | |
| 51 | |
| 52 storage.SetInvalidationState("test"); | |
| 53 EXPECT_EQ("test", storage.GetInvalidationState()); | |
| 54 { | |
| 55 sync_notifier::InvalidationVersionMap expected_max_versions; | |
| 56 expected_max_versions[syncable::APP_NOTIFICATIONS] = 3; | |
| 57 storage.SetMaxVersion(syncable::APP_NOTIFICATIONS, 3); | |
| 58 EXPECT_EQ(expected_max_versions, storage.GetAllMaxVersions()); | |
| 59 } | |
| 60 | |
| 61 storage.Clear(); | |
| 62 | |
| 63 EXPECT_TRUE(storage.GetAllMaxVersions().empty()); | |
| 64 EXPECT_TRUE(storage.GetInvalidationState().empty()); | |
| 65 } | |
| 66 | |
| 67 TEST_F(InvalidatorStorageTest, NullPrefService) { | |
| 68 InvalidatorStorage storage(NULL); | |
| 69 EXPECT_TRUE(storage.GetAllMaxVersions().empty()); | |
| 70 EXPECT_TRUE(storage.GetInvalidationState().empty()); | |
| 71 } | |
| 72 | |
| 73 } // namespace browser_sync | |
| OLD | NEW |