| OLD | NEW |
| 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 Loading... |
| 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 |
| 45 } // namespace | 65 } // namespace |
| 46 | 66 |
| 47 class ExtensionSettingsApiTest : public ExtensionApiTest { | 67 class ExtensionSettingsApiTest : public ExtensionApiTest { |
| 48 protected: | 68 protected: |
| 49 void ReplyWhenSatisfied( | 69 void ReplyWhenSatisfied( |
| 50 Namespace settings_namespace, | 70 Namespace settings_namespace, |
| 51 const std::string& normal_action, | 71 const std::string& normal_action, |
| 52 const std::string& incognito_action) { | 72 const std::string& incognito_action) { |
| 53 MaybeLoadAndReplyWhenSatisfied( | 73 MaybeLoadAndReplyWhenSatisfied( |
| 54 settings_namespace, normal_action, incognito_action, NULL, false); | 74 settings_namespace, normal_action, incognito_action, NULL, false); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 std::string message_json; | 152 std::string message_json; |
| 133 base::JSONWriter::Write(message.get(), &message_json); | 153 base::JSONWriter::Write(message.get(), &message_json); |
| 134 return message_json; | 154 return message_json; |
| 135 } | 155 } |
| 136 | 156 |
| 137 void InitSyncWithSyncableService( | 157 void InitSyncWithSyncableService( |
| 138 SyncChangeProcessor* sync_processor, SyncableService* settings_service) { | 158 SyncChangeProcessor* sync_processor, SyncableService* settings_service) { |
| 139 EXPECT_FALSE(settings_service->MergeDataAndStartSyncing( | 159 EXPECT_FALSE(settings_service->MergeDataAndStartSyncing( |
| 140 kModelType, | 160 kModelType, |
| 141 SyncDataList(), | 161 SyncDataList(), |
| 142 sync_processor).IsSet()); | 162 scoped_ptr<SyncChangeProcessor>( |
| 163 new SyncChangeProcessorDelegate(sync_processor))).IsSet()); |
| 143 } | 164 } |
| 144 | 165 |
| 145 void SendChangesToSyncableService( | 166 void SendChangesToSyncableService( |
| 146 const SyncChangeList& change_list, SyncableService* settings_service) { | 167 const SyncChangeList& change_list, SyncableService* settings_service) { |
| 147 EXPECT_FALSE( | 168 EXPECT_FALSE( |
| 148 settings_service->ProcessSyncChanges(FROM_HERE, change_list).IsSet()); | 169 settings_service->ProcessSyncChanges(FROM_HERE, change_list).IsSet()); |
| 149 } | 170 } |
| 150 }; | 171 }; |
| 151 | 172 |
| 152 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, SimpleTest) { | 173 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, SimpleTest) { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 SendChanges(sync_changes); | 370 SendChanges(sync_changes); |
| 350 | 371 |
| 351 FinalReplyWhenSatisfied(LOCAL, | 372 FinalReplyWhenSatisfied(LOCAL, |
| 352 "assertNoNotifications", "assertNoNotifications"); | 373 "assertNoNotifications", "assertNoNotifications"); |
| 353 | 374 |
| 354 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 375 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 355 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); | 376 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); |
| 356 } | 377 } |
| 357 | 378 |
| 358 } // namespace extensions | 379 } // namespace extensions |
| OLD | NEW |