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 #include "services/preferences/public/cpp/pref_observer_store.h" | 5 #include "services/preferences/public/cpp/pref_observer_store.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 prefs::mojom::PreferencesManagerPtr proxy_; | 84 prefs::mojom::PreferencesManagerPtr proxy_; |
85 std::unique_ptr<TestPreferenceManager> manager_; | 85 std::unique_ptr<TestPreferenceManager> manager_; |
86 PrefStoreObserverMock observer_; | 86 PrefStoreObserverMock observer_; |
87 // Required by mojo binding code within PrefObserverStore. | 87 // Required by mojo binding code within PrefObserverStore. |
88 base::MessageLoop message_loop_; | 88 base::MessageLoop message_loop_; |
89 | 89 |
90 DISALLOW_COPY_AND_ASSIGN(PrefObserverStoreTest); | 90 DISALLOW_COPY_AND_ASSIGN(PrefObserverStoreTest); |
91 }; | 91 }; |
92 | 92 |
93 void PrefObserverStoreTest::SetUp() { | 93 void PrefObserverStoreTest::SetUp() { |
94 manager_.reset(new TestPreferenceManager(mojo::GetProxy(&proxy_))); | 94 manager_.reset(new TestPreferenceManager(mojo::MakeRequest(&proxy_))); |
95 store_ = new PrefObserverStore(std::move(proxy_)); | 95 store_ = new PrefObserverStore(std::move(proxy_)); |
96 store_->AddObserver(&observer_); | 96 store_->AddObserver(&observer_); |
97 } | 97 } |
98 | 98 |
99 void PrefObserverStoreTest::TearDown() { | 99 void PrefObserverStoreTest::TearDown() { |
100 store_->RemoveObserver(&observer_); | 100 store_->RemoveObserver(&observer_); |
101 } | 101 } |
102 | 102 |
103 // Tests that observers are notified upon the completion of initialization, and | 103 // Tests that observers are notified upon the completion of initialization, and |
104 // that values become available. | 104 // that values become available. |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 observer()->changed_keys.end(), key2)); | 326 observer()->changed_keys.end(), key2)); |
327 | 327 |
328 observer()->changed_keys.clear(); | 328 observer()->changed_keys.clear(); |
329 const int kValue3 = 9001; | 329 const int kValue3 = 9001; |
330 base::FundamentalValue pref3(kValue3); | 330 base::FundamentalValue pref3(kValue3); |
331 store()->SetValue(key1, pref3.CreateDeepCopy(), 0); | 331 store()->SetValue(key1, pref3.CreateDeepCopy(), 0); |
332 base::RunLoop().RunUntilIdle(); | 332 base::RunLoop().RunUntilIdle(); |
333 EXPECT_EQ(1u, observer()->changed_keys.size()); | 333 EXPECT_EQ(1u, observer()->changed_keys.size()); |
334 EXPECT_TRUE(manager()->set_preferences_called()); | 334 EXPECT_TRUE(manager()->set_preferences_called()); |
335 } | 335 } |
OLD | NEW |