OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/macros.h" | 5 #include "base/macros.h" |
6 #include "components/prefs/default_pref_store.h" | 6 #include "components/prefs/default_pref_store.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 using base::StringValue; | 9 using base::StringValue; |
10 using base::Value; | 10 using base::Value; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 TEST(DefaultPrefStoreTest, NotifyPrefValueChanged) { | 50 TEST(DefaultPrefStoreTest, NotifyPrefValueChanged) { |
51 scoped_refptr<DefaultPrefStore> pref_store(new DefaultPrefStore); | 51 scoped_refptr<DefaultPrefStore> pref_store(new DefaultPrefStore); |
52 MockPrefStoreObserver observer(pref_store.get()); | 52 MockPrefStoreObserver observer(pref_store.get()); |
53 std::string kPrefKey("pref_key"); | 53 std::string kPrefKey("pref_key"); |
54 | 54 |
55 // Setting a default value shouldn't send a change notification. | 55 // Setting a default value shouldn't send a change notification. |
56 pref_store->SetDefaultValue(kPrefKey, | 56 pref_store->SetDefaultValue(kPrefKey, |
57 scoped_ptr<Value>(new StringValue("foo"))); | 57 std::unique_ptr<Value>(new StringValue("foo"))); |
58 EXPECT_EQ(0, observer.change_count()); | 58 EXPECT_EQ(0, observer.change_count()); |
59 | 59 |
60 // Replacing the default value should send a change notification... | 60 // Replacing the default value should send a change notification... |
61 pref_store->ReplaceDefaultValue(kPrefKey, | 61 pref_store->ReplaceDefaultValue( |
62 scoped_ptr<Value>(new StringValue("bar"))); | 62 kPrefKey, std::unique_ptr<Value>(new StringValue("bar"))); |
63 EXPECT_EQ(1, observer.change_count()); | 63 EXPECT_EQ(1, observer.change_count()); |
64 | 64 |
65 // But only if the value actually changed. | 65 // But only if the value actually changed. |
66 pref_store->ReplaceDefaultValue(kPrefKey, | 66 pref_store->ReplaceDefaultValue( |
67 scoped_ptr<Value>(new StringValue("bar"))); | 67 kPrefKey, std::unique_ptr<Value>(new StringValue("bar"))); |
68 EXPECT_EQ(1, observer.change_count()); | 68 EXPECT_EQ(1, observer.change_count()); |
69 } | 69 } |
70 | 70 |
OLD | NEW |