OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import "ios/chrome/browser/ui/settings/utils/pref_backed_boolean.h" | 5 #import "ios/chrome/browser/ui/settings/utils/pref_backed_boolean.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "components/prefs/pref_registry_simple.h" | 8 #include "components/prefs/pref_registry_simple.h" |
9 #include "components/prefs/testing_pref_service.h" | 9 #include "components/prefs/testing_pref_service.h" |
10 #import "ios/chrome/browser/ui/settings/utils/fake_observable_boolean.h" | 10 #import "ios/chrome/browser/ui/settings/utils/fake_observable_boolean.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 pref_service_.registry()->RegisterBooleanPref(kTestSwitchPref, false); | 26 pref_service_.registry()->RegisterBooleanPref(kTestSwitchPref, false); |
27 observable_boolean_ = | 27 observable_boolean_ = |
28 [[PrefBackedBoolean alloc] initWithPrefService:&pref_service_ | 28 [[PrefBackedBoolean alloc] initWithPrefService:&pref_service_ |
29 prefName:kTestSwitchPref]; | 29 prefName:kTestSwitchPref]; |
30 } | 30 } |
31 | 31 |
32 protected: | 32 protected: |
33 bool GetPref() { return pref_service_.GetBoolean(kTestSwitchPref); } | 33 bool GetPref() { return pref_service_.GetBoolean(kTestSwitchPref); } |
34 | 34 |
35 void SetPref(bool value) { | 35 void SetPref(bool value) { |
36 base::Value* booleanValue = new base::FundamentalValue(value); | 36 base::Value* booleanValue = new base::Value(value); |
37 pref_service_.SetUserPref(kTestSwitchPref, booleanValue); | 37 pref_service_.SetUserPref(kTestSwitchPref, booleanValue); |
38 } | 38 } |
39 | 39 |
40 PrefBackedBoolean* GetObservableBoolean() { return observable_boolean_; } | 40 PrefBackedBoolean* GetObservableBoolean() { return observable_boolean_; } |
41 | 41 |
42 web::TestWebThreadBundle thread_bundle_; | 42 web::TestWebThreadBundle thread_bundle_; |
43 TestingPrefServiceSimple pref_service_; | 43 TestingPrefServiceSimple pref_service_; |
44 PrefBackedBoolean* observable_boolean_; | 44 PrefBackedBoolean* observable_boolean_; |
45 }; | 45 }; |
46 | 46 |
(...skipping 21 matching lines...) Expand all Loading... |
68 | 68 |
69 SetPref(true); | 69 SetPref(true); |
70 EXPECT_EQ(1, observer.updateCount) << "Changing value should update observer"; | 70 EXPECT_EQ(1, observer.updateCount) << "Changing value should update observer"; |
71 | 71 |
72 SetPref(true); | 72 SetPref(true); |
73 EXPECT_EQ(1, observer.updateCount) | 73 EXPECT_EQ(1, observer.updateCount) |
74 << "Setting the same value should not update observer"; | 74 << "Setting the same value should not update observer"; |
75 } | 75 } |
76 | 76 |
77 } // namespace | 77 } // namespace |
OLD | NEW |