Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: services/preferences/public/cpp/tests/pref_store_client_unittest.cc

Issue 2812863002: Pref service: Add a ScopedDictionaryPrefUpdate to track value changes. (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 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_store_client.h" 5 #include "services/preferences/public/cpp/pref_store_client.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 23 matching lines...) Expand all
34 public: 34 public:
35 PrefStoreClientTest() = default; 35 PrefStoreClientTest() = default;
36 ~PrefStoreClientTest() override {} 36 ~PrefStoreClientTest() override {}
37 37
38 PrefStoreObserverMock& observer() { return observer_; } 38 PrefStoreObserverMock& observer() { return observer_; }
39 PrefStoreClient* store() { return store_.get(); } 39 PrefStoreClient* store() { return store_.get(); }
40 40
41 bool initialized() { return store_->IsInitializationComplete(); } 41 bool initialized() { return store_->IsInitializationComplete(); }
42 void OnPrefChanged(const std::string& key, const base::Value& value) { 42 void OnPrefChanged(const std::string& key, const base::Value& value) {
43 std::vector<mojom::PrefUpdatePtr> updates; 43 std::vector<mojom::PrefUpdatePtr> updates;
44 updates.push_back(mojom::PrefUpdate::New(key, value.CreateDeepCopy(), 0)); 44 updates.push_back(mojom::PrefUpdate::New(
45 key, mojom::PrefUpdateValue::NewAtomicUpdate(value.CreateDeepCopy()),
46 0));
45 observer_ptr_->OnPrefsChanged(std::move(updates)); 47 observer_ptr_->OnPrefsChanged(std::move(updates));
46 } 48 }
47 void OnInitializationCompleted() { 49 void OnInitializationCompleted() {
48 observer_ptr_->OnInitializationCompleted(true); 50 observer_ptr_->OnInitializationCompleted(true);
49 } 51 }
50 52
51 // testing::Test: 53 // testing::Test:
52 void SetUp() override { 54 void SetUp() override {
53 store_ = new PrefStoreClient(mojom::PrefStoreConnection::New( 55 store_ = new PrefStoreClient(mojom::PrefStoreConnection::New(
54 mojo::MakeRequest(&observer_ptr_), 56 mojo::MakeRequest(&observer_ptr_),
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 EXPECT_TRUE(value->GetAsInteger(&actual_value)); 182 EXPECT_TRUE(value->GetAsInteger(&actual_value));
181 EXPECT_EQ(kValue, actual_value); 183 EXPECT_EQ(kValue, actual_value);
182 EXPECT_CALL(observer, OnInitializationCompleted(_)).Times(0); 184 EXPECT_CALL(observer, OnInitializationCompleted(_)).Times(0);
183 EXPECT_CALL(observer, OnPrefValueChanged(_)).Times(0); 185 EXPECT_CALL(observer, OnPrefValueChanged(_)).Times(0);
184 observer_ptr.FlushForTesting(); 186 observer_ptr.FlushForTesting();
185 187
186 store->RemoveObserver(&observer); 188 store->RemoveObserver(&observer);
187 } 189 }
188 190
189 } // namespace prefs 191 } // namespace prefs
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698