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

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 browser_tests 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 {
akalin 2012/03/21 01:23:19 hmm...it seems like we either need to avoid creati
Nicolas Zea 2012/03/21 17:38:27 Yeah, I plan to pull this and some form of the Noo
46 public:
47 explicit SyncChangeProcessorDelegate(SyncChangeProcessor* recipient)
48 : recipient_(recipient) {
49 DCHECK(recipient_);
50 }
51
52 // SyncChangeProcessor implementation.
53 virtual SyncError ProcessSyncChanges(
54 const tracked_objects::Location& from_here,
55 const SyncChangeList& change_list) OVERRIDE {
56 return recipient_->ProcessSyncChanges(from_here, change_list);
57 }
58
59 private:
60 // The recipient of all sync changes.
61 SyncChangeProcessor* recipient_;
62 };
63
45 } // namespace 64 } // namespace
46 65
47 class ExtensionSettingsApiTest : public ExtensionApiTest { 66 class ExtensionSettingsApiTest : public ExtensionApiTest {
48 protected: 67 protected:
49 void ReplyWhenSatisfied( 68 void ReplyWhenSatisfied(
50 Namespace settings_namespace, 69 Namespace settings_namespace,
51 const std::string& normal_action, 70 const std::string& normal_action,
52 const std::string& incognito_action) { 71 const std::string& incognito_action) {
53 MaybeLoadAndReplyWhenSatisfied( 72 MaybeLoadAndReplyWhenSatisfied(
54 settings_namespace, normal_action, incognito_action, NULL, false); 73 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; 151 std::string message_json;
133 base::JSONWriter::Write(message.get(), &message_json); 152 base::JSONWriter::Write(message.get(), &message_json);
134 return message_json; 153 return message_json;
135 } 154 }
136 155
137 void InitSyncWithSyncableService( 156 void InitSyncWithSyncableService(
138 SyncChangeProcessor* sync_processor, SyncableService* settings_service) { 157 SyncChangeProcessor* sync_processor, SyncableService* settings_service) {
139 EXPECT_FALSE(settings_service->MergeDataAndStartSyncing( 158 EXPECT_FALSE(settings_service->MergeDataAndStartSyncing(
140 kModelType, 159 kModelType,
141 SyncDataList(), 160 SyncDataList(),
142 sync_processor).IsSet()); 161 scoped_ptr<SyncChangeProcessor>(
162 new SyncChangeProcessorDelegate(sync_processor))).IsSet());
143 } 163 }
144 164
145 void SendChangesToSyncableService( 165 void SendChangesToSyncableService(
146 const SyncChangeList& change_list, SyncableService* settings_service) { 166 const SyncChangeList& change_list, SyncableService* settings_service) {
147 EXPECT_FALSE( 167 EXPECT_FALSE(
148 settings_service->ProcessSyncChanges(FROM_HERE, change_list).IsSet()); 168 settings_service->ProcessSyncChanges(FROM_HERE, change_list).IsSet());
149 } 169 }
150 }; 170 };
151 171
152 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, SimpleTest) { 172 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, SimpleTest) {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 SendChanges(sync_changes); 369 SendChanges(sync_changes);
350 370
351 FinalReplyWhenSatisfied(LOCAL, 371 FinalReplyWhenSatisfied(LOCAL,
352 "assertNoNotifications", "assertNoNotifications"); 372 "assertNoNotifications", "assertNoNotifications");
353 373
354 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 374 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
355 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); 375 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message();
356 } 376 }
357 377
358 } // namespace extensions 378 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698