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

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

Issue 2791893002: Pref service: Batch pref updates. (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 22 matching lines...) Expand all
33 class PrefStoreClientTest : public testing::Test { 33 class PrefStoreClientTest : public testing::Test {
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 observer_ptr_->OnPrefChanged(key, value.CreateDeepCopy()); 43 std::vector<mojom::PrefUpdatePtr> updates;
44 updates.push_back(mojom::PrefUpdate::New(key, value.CreateDeepCopy(), 0));
45 observer_ptr_->OnPrefsChanged(std::move(updates));
44 } 46 }
45 void OnInitializationCompleted() { 47 void OnInitializationCompleted() {
46 observer_ptr_->OnInitializationCompleted(true); 48 observer_ptr_->OnInitializationCompleted(true);
47 } 49 }
48 50
49 // testing::Test: 51 // testing::Test:
50 void SetUp() override { 52 void SetUp() override {
51 store_ = new PrefStoreClient(mojom::PrefStoreConnection::New( 53 store_ = new PrefStoreClient(mojom::PrefStoreConnection::New(
52 mojo::MakeRequest(&observer_ptr_), 54 mojo::MakeRequest(&observer_ptr_),
53 base::MakeUnique<base::DictionaryValue>(), false)); 55 base::MakeUnique<base::DictionaryValue>(), false));
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 EXPECT_TRUE(value->GetAsInteger(&actual_value)); 180 EXPECT_TRUE(value->GetAsInteger(&actual_value));
179 EXPECT_EQ(kValue, actual_value); 181 EXPECT_EQ(kValue, actual_value);
180 EXPECT_CALL(observer, OnInitializationCompleted(_)).Times(0); 182 EXPECT_CALL(observer, OnInitializationCompleted(_)).Times(0);
181 EXPECT_CALL(observer, OnPrefValueChanged(_)).Times(0); 183 EXPECT_CALL(observer, OnPrefValueChanged(_)).Times(0);
182 observer_ptr.FlushForTesting(); 184 observer_ptr.FlushForTesting();
183 185
184 store->RemoveObserver(&observer); 186 store->RemoveObserver(&observer);
185 } 187 }
186 188
187 } // namespace prefs 189 } // namespace prefs
OLDNEW
« no previous file with comments | « services/preferences/public/cpp/pref_store_impl.cc ('k') | services/preferences/public/interfaces/preferences.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698