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

Unified Diff: chrome/browser/sync/invalidations/invalidator_storage_unittest.cc

Issue 10451058: sync: move invalidation version prefs out of SyncPrefs into InvalidatorStorage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: init Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/invalidations/invalidator_storage_unittest.cc
diff --git a/chrome/browser/sync/invalidations/invalidator_storage_unittest.cc b/chrome/browser/sync/invalidations/invalidator_storage_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..65b93c3c7a1adb74d6a1b111d90fd4cb1eb21ad4
--- /dev/null
+++ b/chrome/browser/sync/invalidations/invalidator_storage_unittest.cc
@@ -0,0 +1,73 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#include "chrome/browser/sync/invalidations/invalidator_storage.h"
+
+#include "base/message_loop.h"
+#include "chrome/test/base/testing_pref_service.h"
+#include "sync/syncable/model_type.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace browser_sync {
+
+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
+ protected:
+ TestingPrefService pref_service_;
+
+ private:
+ MessageLoop loop_;
+};
+
+TEST_F(InvalidatorStorageTest, MaxInvalidationVersions) {
+ InvalidatorStorage storage(&pref_service_);
+
+ sync_notifier::InvalidationVersionMap expected_max_versions;
+ EXPECT_EQ(expected_max_versions, storage.GetAllMaxVersions());
+
+ expected_max_versions[syncable::BOOKMARKS] = 2;
+ storage.SetMaxVersion(syncable::BOOKMARKS, 2);
+ EXPECT_EQ(expected_max_versions, storage.GetAllMaxVersions());
+
+ expected_max_versions[syncable::PREFERENCES] = 5;
+ storage.SetMaxVersion(syncable::PREFERENCES, 5);
+ EXPECT_EQ(expected_max_versions, storage.GetAllMaxVersions());
+
+ expected_max_versions[syncable::APP_NOTIFICATIONS] = 3;
+ storage.SetMaxVersion(syncable::APP_NOTIFICATIONS, 3);
+ EXPECT_EQ(expected_max_versions, storage.GetAllMaxVersions());
+
+ expected_max_versions[syncable::APP_NOTIFICATIONS] = 4;
+ storage.SetMaxVersion(syncable::APP_NOTIFICATIONS, 4);
+ EXPECT_EQ(expected_max_versions, storage.GetAllMaxVersions());
+}
+
+TEST_F(InvalidatorStorageTest, Clear) {
+ InvalidatorStorage storage(&pref_service_);
+ EXPECT_TRUE(storage.GetAllMaxVersions().empty());
+ EXPECT_TRUE(storage.GetInvalidationState().empty());
+
+ storage.SetInvalidationState("test");
+ EXPECT_EQ("test", storage.GetInvalidationState());
+ {
+ sync_notifier::InvalidationVersionMap expected_max_versions;
+ expected_max_versions[syncable::APP_NOTIFICATIONS] = 3;
+ storage.SetMaxVersion(syncable::APP_NOTIFICATIONS, 3);
+ EXPECT_EQ(expected_max_versions, storage.GetAllMaxVersions());
+ }
+
+ storage.Clear();
+
+ EXPECT_TRUE(storage.GetAllMaxVersions().empty());
+ EXPECT_TRUE(storage.GetInvalidationState().empty());
+}
+
+TEST_F(InvalidatorStorageTest, NullPrefService) {
+ InvalidatorStorage storage(NULL);
+ EXPECT_TRUE(storage.GetAllMaxVersions().empty());
+ EXPECT_TRUE(storage.GetInvalidationState().empty());
+}
+
+} // namespace browser_sync

Powered by Google App Engine
This is Rietveld 408576698