| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/prefs/tracked/pref_service_hash_store_contents.h" | 5 #include "chrome/browser/prefs/tracked/pref_service_hash_store_contents.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/prefs/testing_pref_service.h" | 10 #include "base/prefs/testing_pref_service.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 } | 61 } |
| 62 { | 62 { |
| 63 PrefServiceHashStoreContents contents("store_id", &local_state_); | 63 PrefServiceHashStoreContents contents("store_id", &local_state_); |
| 64 ASSERT_FALSE(contents.IsInitialized()); | 64 ASSERT_FALSE(contents.IsInitialized()); |
| 65 PrefServiceHashStoreContents other_contents("other_store_id", | 65 PrefServiceHashStoreContents other_contents("other_store_id", |
| 66 &local_state_); | 66 &local_state_); |
| 67 ASSERT_TRUE(other_contents.IsInitialized()); | 67 ASSERT_TRUE(other_contents.IsInitialized()); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 TEST_F(PrefServiceHashStoreContentsTest, GetAndSetVersion) { | |
| 72 int version = 0; | |
| 73 { | |
| 74 PrefServiceHashStoreContents contents("store_id", &local_state_); | |
| 75 ASSERT_FALSE(contents.GetVersion(&version)); | |
| 76 (*contents.GetMutableContents())->Set("foo", new base::StringValue("bar")); | |
| 77 ASSERT_FALSE(contents.GetVersion(&version)); | |
| 78 } | |
| 79 { | |
| 80 PrefServiceHashStoreContents contents("store_id", &local_state_); | |
| 81 ASSERT_FALSE(contents.GetVersion(&version)); | |
| 82 contents.SetVersion(1); | |
| 83 ASSERT_TRUE(contents.GetVersion(&version)); | |
| 84 ASSERT_EQ(1, version); | |
| 85 } | |
| 86 | |
| 87 version = 0; | |
| 88 | |
| 89 { | |
| 90 PrefServiceHashStoreContents contents("store_id", &local_state_); | |
| 91 ASSERT_TRUE(contents.GetVersion(&version)); | |
| 92 ASSERT_EQ(1, version); | |
| 93 PrefServiceHashStoreContents other_contents("other_store_id", | |
| 94 &local_state_); | |
| 95 ASSERT_FALSE(other_contents.GetVersion(&version)); | |
| 96 } | |
| 97 } | |
| 98 | |
| 99 TEST_F(PrefServiceHashStoreContentsTest, GetAndSetContents) { | 71 TEST_F(PrefServiceHashStoreContentsTest, GetAndSetContents) { |
| 100 { | 72 { |
| 101 PrefServiceHashStoreContents contents("store_id", &local_state_); | 73 PrefServiceHashStoreContents contents("store_id", &local_state_); |
| 102 ASSERT_EQ(NULL, contents.GetContents()); | 74 ASSERT_EQ(NULL, contents.GetContents()); |
| 103 (*contents.GetMutableContents())->Set("foo", new base::StringValue("bar")); | 75 (*contents.GetMutableContents())->Set("foo", new base::StringValue("bar")); |
| 104 ASSERT_FALSE(contents.GetContents() == NULL); | 76 ASSERT_FALSE(contents.GetContents() == NULL); |
| 105 std::string actual_value; | 77 std::string actual_value; |
| 106 ASSERT_TRUE(contents.GetContents()->GetString("foo", &actual_value)); | 78 ASSERT_TRUE(contents.GetContents()->GetString("foo", &actual_value)); |
| 107 ASSERT_EQ("bar", actual_value); | 79 ASSERT_EQ("bar", actual_value); |
| 108 PrefServiceHashStoreContents other_contents("other_store_id", | 80 PrefServiceHashStoreContents other_contents("other_store_id", |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 123 |
| 152 PrefServiceHashStoreContents::ResetAllPrefHashStores(&local_state_); | 124 PrefServiceHashStoreContents::ResetAllPrefHashStores(&local_state_); |
| 153 | 125 |
| 154 { | 126 { |
| 155 PrefServiceHashStoreContents contents_1("store_id_1", &local_state_); | 127 PrefServiceHashStoreContents contents_1("store_id_1", &local_state_); |
| 156 PrefServiceHashStoreContents contents_2("store_id_2", &local_state_); | 128 PrefServiceHashStoreContents contents_2("store_id_2", &local_state_); |
| 157 ASSERT_FALSE(contents_1.IsInitialized()); | 129 ASSERT_FALSE(contents_1.IsInitialized()); |
| 158 ASSERT_FALSE(contents_2.IsInitialized()); | 130 ASSERT_FALSE(contents_2.IsInitialized()); |
| 159 } | 131 } |
| 160 } | 132 } |
| OLD | NEW |