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

Unified Diff: chrome/browser/prefs/pref_value_map_unittest.cc

Issue 11243002: Move the bits of Prefs where production code has only trivially easy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments, fix gypi problem Created 8 years, 2 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
« no previous file with comments | « chrome/browser/prefs/pref_value_map.cc ('k') | chrome/browser/prefs/pref_value_store.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prefs/pref_value_map_unittest.cc
diff --git a/chrome/browser/prefs/pref_value_map_unittest.cc b/chrome/browser/prefs/pref_value_map_unittest.cc
deleted file mode 100644
index 6fbddea1958301f56c8430720af05ac1cb149e09..0000000000000000000000000000000000000000
--- a/chrome/browser/prefs/pref_value_map_unittest.cc
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright (c) 2011 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 "base/values.h"
-#include "chrome/browser/prefs/pref_value_map.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-class PrefValueMapTest : public testing::Test {
-};
-
-TEST_F(PrefValueMapTest, SetValue) {
- PrefValueMap map;
- const Value* result = NULL;
- EXPECT_FALSE(map.GetValue("key", &result));
- EXPECT_FALSE(result);
-
- EXPECT_TRUE(map.SetValue("key", Value::CreateStringValue("test")));
- EXPECT_FALSE(map.SetValue("key", Value::CreateStringValue("test")));
- EXPECT_TRUE(map.SetValue("key", Value::CreateStringValue("hi mom!")));
-
- EXPECT_TRUE(map.GetValue("key", &result));
- EXPECT_TRUE(StringValue("hi mom!").Equals(result));
-}
-
-TEST_F(PrefValueMapTest, GetAndSetIntegerValue) {
- PrefValueMap map;
- ASSERT_TRUE(map.SetValue("key", Value::CreateIntegerValue(5)));
-
- int int_value = 0;
- EXPECT_TRUE(map.GetInteger("key", &int_value));
- EXPECT_EQ(5, int_value);
-
- map.SetInteger("key", -14);
- EXPECT_TRUE(map.GetInteger("key", &int_value));
- EXPECT_EQ(-14, int_value);
-}
-
-TEST_F(PrefValueMapTest, RemoveValue) {
- PrefValueMap map;
- EXPECT_FALSE(map.RemoveValue("key"));
-
- EXPECT_TRUE(map.SetValue("key", Value::CreateStringValue("test")));
- EXPECT_TRUE(map.GetValue("key", NULL));
-
- EXPECT_TRUE(map.RemoveValue("key"));
- EXPECT_FALSE(map.GetValue("key", NULL));
-
- EXPECT_FALSE(map.RemoveValue("key"));
-}
-
-TEST_F(PrefValueMapTest, Clear) {
- PrefValueMap map;
- EXPECT_TRUE(map.SetValue("key", Value::CreateStringValue("test")));
- EXPECT_TRUE(map.GetValue("key", NULL));
-
- map.Clear();
-
- EXPECT_FALSE(map.GetValue("key", NULL));
-}
-
-TEST_F(PrefValueMapTest, GetDifferingKeys) {
- PrefValueMap reference;
- EXPECT_TRUE(reference.SetValue("b", Value::CreateStringValue("test")));
- EXPECT_TRUE(reference.SetValue("c", Value::CreateStringValue("test")));
- EXPECT_TRUE(reference.SetValue("e", Value::CreateStringValue("test")));
-
- PrefValueMap check;
- std::vector<std::string> differing_paths;
- std::vector<std::string> expected_differing_paths;
-
- reference.GetDifferingKeys(&check, &differing_paths);
- expected_differing_paths.push_back("b");
- expected_differing_paths.push_back("c");
- expected_differing_paths.push_back("e");
- EXPECT_EQ(expected_differing_paths, differing_paths);
-
- EXPECT_TRUE(check.SetValue("a", Value::CreateStringValue("test")));
- EXPECT_TRUE(check.SetValue("c", Value::CreateStringValue("test")));
- EXPECT_TRUE(check.SetValue("d", Value::CreateStringValue("test")));
-
- reference.GetDifferingKeys(&check, &differing_paths);
- expected_differing_paths.clear();
- expected_differing_paths.push_back("a");
- expected_differing_paths.push_back("b");
- expected_differing_paths.push_back("d");
- expected_differing_paths.push_back("e");
- EXPECT_EQ(expected_differing_paths, differing_paths);
-}
-
-TEST_F(PrefValueMapTest, SwapTwoMaps) {
- PrefValueMap first_map;
- EXPECT_TRUE(first_map.SetValue("a", Value::CreateStringValue("test")));
- EXPECT_TRUE(first_map.SetValue("b", Value::CreateStringValue("test")));
- EXPECT_TRUE(first_map.SetValue("c", Value::CreateStringValue("test")));
-
- PrefValueMap second_map;
- EXPECT_TRUE(second_map.SetValue("d", Value::CreateStringValue("test")));
- EXPECT_TRUE(second_map.SetValue("e", Value::CreateStringValue("test")));
- EXPECT_TRUE(second_map.SetValue("f", Value::CreateStringValue("test")));
-
- first_map.Swap(&second_map);
-
- EXPECT_TRUE(first_map.GetValue("d", NULL));
- EXPECT_TRUE(first_map.GetValue("e", NULL));
- EXPECT_TRUE(first_map.GetValue("f", NULL));
-
- EXPECT_TRUE(second_map.GetValue("a", NULL));
- EXPECT_TRUE(second_map.GetValue("b", NULL));
- EXPECT_TRUE(second_map.GetValue("c", NULL));
-}
« no previous file with comments | « chrome/browser/prefs/pref_value_map.cc ('k') | chrome/browser/prefs/pref_value_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698