| OLD | NEW |
| 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 Loading... |
| 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 } |
| OLD | NEW |