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

Side by Side Diff: chrome/browser/prefs/pref_value_map_unittest.cc

Issue 9016010: Implement pref_value_map swap function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
« no previous file with comments | « chrome/browser/prefs/pref_value_map.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/values.h" 5 #include "base/values.h"
6 #include "chrome/browser/prefs/pref_value_map.h" 6 #include "chrome/browser/prefs/pref_value_map.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 class PrefValueMapTest : public testing::Test { 9 class PrefValueMapTest : public testing::Test {
10 }; 10 };
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 EXPECT_TRUE(check.SetValue("d", Value::CreateStringValue("test"))); 80 EXPECT_TRUE(check.SetValue("d", Value::CreateStringValue("test")));
81 81
82 reference.GetDifferingKeys(&check, &differing_paths); 82 reference.GetDifferingKeys(&check, &differing_paths);
83 expected_differing_paths.clear(); 83 expected_differing_paths.clear();
84 expected_differing_paths.push_back("a"); 84 expected_differing_paths.push_back("a");
85 expected_differing_paths.push_back("b"); 85 expected_differing_paths.push_back("b");
86 expected_differing_paths.push_back("d"); 86 expected_differing_paths.push_back("d");
87 expected_differing_paths.push_back("e"); 87 expected_differing_paths.push_back("e");
88 EXPECT_EQ(expected_differing_paths, differing_paths); 88 EXPECT_EQ(expected_differing_paths, differing_paths);
89 } 89 }
90
91 TEST_F(PrefValueMapTest, SwapTwoMaps) {
92 PrefValueMap first_map;
93 EXPECT_TRUE(first_map.SetValue("a", Value::CreateStringValue("test")));
94 EXPECT_TRUE(first_map.SetValue("b", Value::CreateStringValue("test")));
95 EXPECT_TRUE(first_map.SetValue("c", Value::CreateStringValue("test")));
96
97 PrefValueMap second_map;
98 EXPECT_TRUE(second_map.SetValue("d", Value::CreateStringValue("test")));
99 EXPECT_TRUE(second_map.SetValue("e", Value::CreateStringValue("test")));
100 EXPECT_TRUE(second_map.SetValue("f", Value::CreateStringValue("test")));
101
102 first_map.Swap(&second_map);
103
104 EXPECT_TRUE(first_map.GetValue("d", NULL));
105 EXPECT_TRUE(first_map.GetValue("e", NULL));
106 EXPECT_TRUE(first_map.GetValue("f", NULL));
107
108 EXPECT_TRUE(second_map.GetValue("a", NULL));
109 EXPECT_TRUE(second_map.GetValue("b", NULL));
110 EXPECT_TRUE(second_map.GetValue("c", NULL));
111 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_value_map.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698