OLD | NEW |
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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_service_factory.h" | 5 #include "services/preferences/public/cpp/pref_service_factory.h" |
6 | 6 |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.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/test/sequenced_worker_pool_owner.h" | 10 #include "base/test/sequenced_worker_pool_owner.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 base::ScopedTempDir profile_dir_; | 156 base::ScopedTempDir profile_dir_; |
157 std::unique_ptr<base::SequencedWorkerPoolOwner> worker_pool_owner_; | 157 std::unique_ptr<base::SequencedWorkerPoolOwner> worker_pool_owner_; |
158 | 158 |
159 DISALLOW_COPY_AND_ASSIGN(PrefServiceFactoryTest); | 159 DISALLOW_COPY_AND_ASSIGN(PrefServiceFactoryTest); |
160 }; | 160 }; |
161 | 161 |
162 // Check that a single client can set and read back values. | 162 // Check that a single client can set and read back values. |
163 TEST_F(PrefServiceFactoryTest, Basic) { | 163 TEST_F(PrefServiceFactoryTest, Basic) { |
164 auto pref_service = Create(); | 164 auto pref_service = Create(); |
165 | 165 |
166 // TODO(tibell): Once we have a default store check the value prior to | 166 EXPECT_EQ(kInitialValue, pref_service->GetInteger(kKey)); |
167 // setting. | |
168 pref_service->SetInteger(kKey, kUpdatedValue); | 167 pref_service->SetInteger(kKey, kUpdatedValue); |
169 EXPECT_EQ(kUpdatedValue, pref_service->GetInteger(kKey)); | 168 EXPECT_EQ(kUpdatedValue, pref_service->GetInteger(kKey)); |
170 } | 169 } |
171 | 170 |
172 // Check that updates in one client eventually propagates to the other. | 171 // Check that updates in one client eventually propagates to the other. |
173 TEST_F(PrefServiceFactoryTest, MultipleClients) { | 172 TEST_F(PrefServiceFactoryTest, MultipleClients) { |
174 auto pref_service = Create(); | 173 auto pref_service = Create(); |
175 auto pref_service2 = Create(); | 174 auto pref_service2 = Create(); |
176 | 175 |
177 // TODO(tibell): Once we have a default store check the value prior to | 176 EXPECT_EQ(kInitialValue, pref_service->GetInteger(kKey)); |
178 // setting. | 177 EXPECT_EQ(kInitialValue, pref_service2->GetInteger(kKey)); |
179 pref_service->SetInteger(kKey, kUpdatedValue); | 178 pref_service->SetInteger(kKey, kUpdatedValue); |
180 WaitForPrefChange(pref_service2.get(), kKey); | 179 WaitForPrefChange(pref_service2.get(), kKey); |
181 EXPECT_EQ(kUpdatedValue, pref_service2->GetInteger(kKey)); | 180 EXPECT_EQ(kUpdatedValue, pref_service2->GetInteger(kKey)); |
182 } | 181 } |
183 | 182 |
184 } // namespace | 183 } // namespace |
185 } // namespace prefs | 184 } // namespace prefs |
OLD | NEW |