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

Side by Side Diff: chrome/browser/extensions/settings/settings_apitest.cc

Issue 9749012: [Sync] Have SyncableService's take ownership of their SyncChangeProcessor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge conflict Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/settings/settings_frontend.h" 10 #include "chrome/browser/extensions/settings/settings_frontend.h"
(...skipping 24 matching lines...) Expand all
35 public: 35 public:
36 virtual SyncError ProcessSyncChanges( 36 virtual SyncError ProcessSyncChanges(
37 const tracked_objects::Location& from_here, 37 const tracked_objects::Location& from_here,
38 const SyncChangeList& change_list) OVERRIDE { 38 const SyncChangeList& change_list) OVERRIDE {
39 return SyncError(); 39 return SyncError();
40 } 40 }
41 41
42 virtual ~NoopSyncChangeProcessor() {}; 42 virtual ~NoopSyncChangeProcessor() {};
43 }; 43 };
44 44
45 class SyncChangeProcessorDelegate : public SyncChangeProcessor {
46 public:
47 explicit SyncChangeProcessorDelegate(SyncChangeProcessor* recipient)
48 : recipient_(recipient) {
49 DCHECK(recipient_);
50 }
51 virtual ~SyncChangeProcessorDelegate() {}
52
53 // SyncChangeProcessor implementation.
54 virtual SyncError ProcessSyncChanges(
55 const tracked_objects::Location& from_here,
56 const SyncChangeList& change_list) OVERRIDE {
57 return recipient_->ProcessSyncChanges(from_here, change_list);
58 }
59
60 private:
61 // The recipient of all sync changes.
62 SyncChangeProcessor* recipient_;
63
64 DISALLOW_COPY_AND_ASSIGN(SyncChangeProcessorDelegate);
65 };
66
45 } // namespace 67 } // namespace
46 68
47 class ExtensionSettingsApiTest : public ExtensionApiTest { 69 class ExtensionSettingsApiTest : public ExtensionApiTest {
48 protected: 70 protected:
49 void ReplyWhenSatisfied( 71 void ReplyWhenSatisfied(
50 Namespace settings_namespace, 72 Namespace settings_namespace,
51 const std::string& normal_action, 73 const std::string& normal_action,
52 const std::string& incognito_action) { 74 const std::string& incognito_action) {
53 MaybeLoadAndReplyWhenSatisfied( 75 MaybeLoadAndReplyWhenSatisfied(
54 settings_namespace, normal_action, incognito_action, NULL, false); 76 settings_namespace, normal_action, incognito_action, NULL, false);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 std::string message_json; 154 std::string message_json;
133 base::JSONWriter::Write(message.get(), &message_json); 155 base::JSONWriter::Write(message.get(), &message_json);
134 return message_json; 156 return message_json;
135 } 157 }
136 158
137 void InitSyncWithSyncableService( 159 void InitSyncWithSyncableService(
138 SyncChangeProcessor* sync_processor, SyncableService* settings_service) { 160 SyncChangeProcessor* sync_processor, SyncableService* settings_service) {
139 EXPECT_FALSE(settings_service->MergeDataAndStartSyncing( 161 EXPECT_FALSE(settings_service->MergeDataAndStartSyncing(
140 kModelType, 162 kModelType,
141 SyncDataList(), 163 SyncDataList(),
142 sync_processor).IsSet()); 164 scoped_ptr<SyncChangeProcessor>(
165 new SyncChangeProcessorDelegate(sync_processor))).IsSet());
143 } 166 }
144 167
145 void SendChangesToSyncableService( 168 void SendChangesToSyncableService(
146 const SyncChangeList& change_list, SyncableService* settings_service) { 169 const SyncChangeList& change_list, SyncableService* settings_service) {
147 EXPECT_FALSE( 170 EXPECT_FALSE(
148 settings_service->ProcessSyncChanges(FROM_HERE, change_list).IsSet()); 171 settings_service->ProcessSyncChanges(FROM_HERE, change_list).IsSet());
149 } 172 }
150 }; 173 };
151 174
152 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, SimpleTest) { 175 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, SimpleTest) {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 SendChanges(sync_changes); 372 SendChanges(sync_changes);
350 373
351 FinalReplyWhenSatisfied(LOCAL, 374 FinalReplyWhenSatisfied(LOCAL,
352 "assertNoNotifications", "assertNoNotifications"); 375 "assertNoNotifications", "assertNoNotifications");
353 376
354 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 377 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
355 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); 378 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message();
356 } 379 }
357 380
358 } // namespace extensions 381 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service_unittest.cc ('k') | chrome/browser/extensions/settings/settings_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698