| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
| 11 #include "chrome/browser/extensions/settings/settings_namespace.h" |
| 11 #include "chrome/browser/extensions/settings/settings_sync_util.h" | 12 #include "chrome/browser/extensions/settings/settings_sync_util.h" |
| 12 #include "chrome/browser/extensions/extension_test_message_listener.h" | 13 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/sync/api/sync_change.h" | 15 #include "chrome/browser/sync/api/sync_change.h" |
| 15 #include "chrome/browser/sync/api/sync_change_processor.h" | 16 #include "chrome/browser/sync/api/sync_change_processor.h" |
| 16 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
| 19 | 20 |
| 20 namespace extensions { | 21 namespace extensions { |
| 21 | 22 |
| 23 using namespace settings_namespace; |
| 24 |
| 22 namespace { | 25 namespace { |
| 23 | 26 |
| 24 class NoopSyncChangeProcessor : public SyncChangeProcessor { | 27 class NoopSyncChangeProcessor : public SyncChangeProcessor { |
| 25 public: | 28 public: |
| 26 virtual SyncError ProcessSyncChanges( | 29 virtual SyncError ProcessSyncChanges( |
| 27 const tracked_objects::Location& from_here, | 30 const tracked_objects::Location& from_here, |
| 28 const SyncChangeList& change_list) OVERRIDE { | 31 const SyncChangeList& change_list) OVERRIDE { |
| 29 return SyncError(); | 32 return SyncError(); |
| 30 } | 33 } |
| 31 | 34 |
| 32 virtual ~NoopSyncChangeProcessor() {}; | 35 virtual ~NoopSyncChangeProcessor() {}; |
| 33 }; | 36 }; |
| 34 | 37 |
| 35 } // namespace | 38 } // namespace |
| 36 | 39 |
| 37 class ExtensionSettingsApiTest : public ExtensionApiTest { | 40 class ExtensionSettingsApiTest : public ExtensionApiTest { |
| 38 protected: | 41 protected: |
| 39 void ReplyWhenSatisfied( | 42 void ReplyWhenSatisfied( |
| 43 Namespace settings_namespace, |
| 40 const std::string& normal_action, | 44 const std::string& normal_action, |
| 41 const std::string& incognito_action) { | 45 const std::string& incognito_action) { |
| 42 MaybeLoadAndReplyWhenSatisfied( | 46 MaybeLoadAndReplyWhenSatisfied( |
| 43 normal_action, incognito_action, NULL, false); | 47 settings_namespace, normal_action, incognito_action, NULL, false); |
| 44 } | 48 } |
| 45 | 49 |
| 46 const Extension* LoadAndReplyWhenSatisfied( | 50 const Extension* LoadAndReplyWhenSatisfied( |
| 51 Namespace settings_namespace, |
| 47 const std::string& normal_action, | 52 const std::string& normal_action, |
| 48 const std::string& incognito_action, | 53 const std::string& incognito_action, |
| 49 const std::string& extension_dir) { | 54 const std::string& extension_dir) { |
| 50 return MaybeLoadAndReplyWhenSatisfied( | 55 return MaybeLoadAndReplyWhenSatisfied( |
| 51 normal_action, incognito_action, &extension_dir, false); | 56 settings_namespace, |
| 57 normal_action, |
| 58 incognito_action, |
| 59 &extension_dir, |
| 60 false); |
| 52 } | 61 } |
| 53 | 62 |
| 54 void FinalReplyWhenSatisfied( | 63 void FinalReplyWhenSatisfied( |
| 64 Namespace settings_namespace, |
| 55 const std::string& normal_action, | 65 const std::string& normal_action, |
| 56 const std::string& incognito_action) { | 66 const std::string& incognito_action) { |
| 57 MaybeLoadAndReplyWhenSatisfied(normal_action, incognito_action, NULL, true); | 67 MaybeLoadAndReplyWhenSatisfied( |
| 68 settings_namespace, normal_action, incognito_action, NULL, true); |
| 58 } | 69 } |
| 59 | 70 |
| 60 void InitSync(SyncChangeProcessor* sync_processor) { | 71 void InitSync(SyncChangeProcessor* sync_processor) { |
| 61 browser()->profile()->GetExtensionService()-> | 72 browser()->profile()->GetExtensionService()-> |
| 62 settings_frontend()->RunWithSyncableService( | 73 settings_frontend()->RunWithSyncableService( |
| 63 // TODO(kalman): test both EXTENSION_SETTINGS and APP_SETTINGS. | 74 // TODO(kalman): test both EXTENSION_SETTINGS and APP_SETTINGS. |
| 64 syncable::EXTENSION_SETTINGS, | 75 syncable::EXTENSION_SETTINGS, |
| 65 base::Bind( | 76 base::Bind( |
| 66 &ExtensionSettingsApiTest::InitSyncWithSyncableService, | 77 &ExtensionSettingsApiTest::InitSyncWithSyncableService, |
| 67 this, | 78 this, |
| 68 sync_processor)); | 79 sync_processor)); |
| 69 MessageLoop::current()->RunAllPending(); | 80 MessageLoop::current()->RunAllPending(); |
| 70 } | 81 } |
| 71 | 82 |
| 72 void SendChanges(const SyncChangeList& change_list) { | 83 void SendChanges(const SyncChangeList& change_list) { |
| 73 browser()->profile()->GetExtensionService()-> | 84 browser()->profile()->GetExtensionService()-> |
| 74 settings_frontend()->RunWithSyncableService( | 85 settings_frontend()->RunWithSyncableService( |
| 75 // TODO(kalman): test both EXTENSION_SETTINGS and APP_SETTINGS. | 86 // TODO(kalman): test both EXTENSION_SETTINGS and APP_SETTINGS. |
| 76 syncable::EXTENSION_SETTINGS, | 87 syncable::EXTENSION_SETTINGS, |
| 77 base::Bind( | 88 base::Bind( |
| 78 &ExtensionSettingsApiTest::SendChangesToSyncableService, | 89 &ExtensionSettingsApiTest::SendChangesToSyncableService, |
| 79 this, | 90 this, |
| 80 change_list)); | 91 change_list)); |
| 81 MessageLoop::current()->RunAllPending(); | 92 MessageLoop::current()->RunAllPending(); |
| 82 } | 93 } |
| 83 | 94 |
| 84 private: | 95 private: |
| 85 const Extension* MaybeLoadAndReplyWhenSatisfied( | 96 const Extension* MaybeLoadAndReplyWhenSatisfied( |
| 97 Namespace settings_namespace, |
| 86 const std::string& normal_action, | 98 const std::string& normal_action, |
| 87 const std::string& incognito_action, | 99 const std::string& incognito_action, |
| 88 // May be NULL to imply not loading the extension. | 100 // May be NULL to imply not loading the extension. |
| 89 const std::string* extension_dir, | 101 const std::string* extension_dir, |
| 90 bool is_final_action) { | 102 bool is_final_action) { |
| 91 ExtensionTestMessageListener listener("waiting", true); | 103 ExtensionTestMessageListener listener("waiting", true); |
| 92 ExtensionTestMessageListener listener_incognito("waiting_incognito", true); | 104 ExtensionTestMessageListener listener_incognito("waiting_incognito", true); |
| 93 | 105 |
| 94 // Only load the extension after the listeners have been set up, to avoid | 106 // Only load the extension after the listeners have been set up, to avoid |
| 95 // initialisation race conditions. | 107 // initialisation race conditions. |
| 96 const Extension* extension = NULL; | 108 const Extension* extension = NULL; |
| 97 if (extension_dir) { | 109 if (extension_dir) { |
| 98 extension = LoadExtensionIncognito( | 110 extension = LoadExtensionIncognito( |
| 99 test_data_dir_.AppendASCII("settings").AppendASCII(*extension_dir)); | 111 test_data_dir_.AppendASCII("settings").AppendASCII(*extension_dir)); |
| 100 EXPECT_TRUE(extension); | 112 EXPECT_TRUE(extension); |
| 101 } | 113 } |
| 102 | 114 |
| 103 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 115 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 104 EXPECT_TRUE(listener_incognito.WaitUntilSatisfied()); | 116 EXPECT_TRUE(listener_incognito.WaitUntilSatisfied()); |
| 105 | 117 |
| 106 listener.Reply(CreateMessage(normal_action, is_final_action)); | 118 listener.Reply( |
| 107 listener_incognito.Reply(CreateMessage(incognito_action, is_final_action)); | 119 CreateMessage(settings_namespace, normal_action, is_final_action)); |
| 120 listener_incognito.Reply( |
| 121 CreateMessage(settings_namespace, incognito_action, is_final_action)); |
| 108 return extension; | 122 return extension; |
| 109 } | 123 } |
| 110 | 124 |
| 111 std::string CreateMessage(const std::string& action, bool is_final_action) { | 125 std::string CreateMessage( |
| 126 Namespace settings_namespace, |
| 127 const std::string& action, |
| 128 bool is_final_action) { |
| 112 scoped_ptr<DictionaryValue> message(new DictionaryValue()); | 129 scoped_ptr<DictionaryValue> message(new DictionaryValue()); |
| 130 message->SetString("namespace", ToString(settings_namespace)); |
| 113 message->SetString("action", action); | 131 message->SetString("action", action); |
| 114 message->SetBoolean("isFinalAction", is_final_action); | 132 message->SetBoolean("isFinalAction", is_final_action); |
| 115 std::string message_json; | 133 std::string message_json; |
| 116 base::JSONWriter::Write(message.get(), false, &message_json); | 134 base::JSONWriter::Write(message.get(), false, &message_json); |
| 117 return message_json; | 135 return message_json; |
| 118 } | 136 } |
| 119 | 137 |
| 120 void InitSyncWithSyncableService( | 138 void InitSyncWithSyncableService( |
| 121 SyncChangeProcessor* sync_processor, SyncableService* settings_service) { | 139 SyncChangeProcessor* sync_processor, SyncableService* settings_service) { |
| 122 EXPECT_FALSE(settings_service->MergeDataAndStartSyncing( | 140 EXPECT_FALSE(settings_service->MergeDataAndStartSyncing( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 146 CommandLine::ForCurrentProcess()->AppendSwitch( | 164 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 147 switches::kEnableExperimentalExtensionApis); | 165 switches::kEnableExperimentalExtensionApis); |
| 148 | 166 |
| 149 // We need 2 ResultCatchers because we'll be running the same test in both | 167 // We need 2 ResultCatchers because we'll be running the same test in both |
| 150 // regular and incognito mode. | 168 // regular and incognito mode. |
| 151 ResultCatcher catcher, catcher_incognito; | 169 ResultCatcher catcher, catcher_incognito; |
| 152 catcher.RestrictToProfile(browser()->profile()); | 170 catcher.RestrictToProfile(browser()->profile()); |
| 153 catcher_incognito.RestrictToProfile( | 171 catcher_incognito.RestrictToProfile( |
| 154 browser()->profile()->GetOffTheRecordProfile()); | 172 browser()->profile()->GetOffTheRecordProfile()); |
| 155 | 173 |
| 156 LoadAndReplyWhenSatisfied("assertEmpty", "assertEmpty", "split_incognito"); | 174 LoadAndReplyWhenSatisfied(SYNC, |
| 157 ReplyWhenSatisfied("noop", "setFoo"); | 175 "assertEmpty", "assertEmpty", "split_incognito"); |
| 158 ReplyWhenSatisfied("assertFoo", "assertFoo"); | 176 ReplyWhenSatisfied(SYNC, "noop", "setFoo"); |
| 159 ReplyWhenSatisfied("clear", "noop"); | 177 ReplyWhenSatisfied(SYNC, "assertFoo", "assertFoo"); |
| 160 ReplyWhenSatisfied("assertEmpty", "assertEmpty"); | 178 ReplyWhenSatisfied(SYNC, "clear", "noop"); |
| 161 ReplyWhenSatisfied("setFoo", "noop"); | 179 ReplyWhenSatisfied(SYNC, "assertEmpty", "assertEmpty"); |
| 162 ReplyWhenSatisfied("assertFoo", "assertFoo"); | 180 ReplyWhenSatisfied(SYNC, "setFoo", "noop"); |
| 163 ReplyWhenSatisfied("noop", "removeFoo"); | 181 ReplyWhenSatisfied(SYNC, "assertFoo", "assertFoo"); |
| 164 FinalReplyWhenSatisfied("assertEmpty", "assertEmpty"); | 182 ReplyWhenSatisfied(SYNC, "noop", "removeFoo"); |
| 183 FinalReplyWhenSatisfied(SYNC, "assertEmpty", "assertEmpty"); |
| 165 | 184 |
| 166 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 185 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 167 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); | 186 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); |
| 168 } | 187 } |
| 169 | 188 |
| 170 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, | 189 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, |
| 171 OnChangedNotificationsBetweenBackgroundPages) { | 190 OnChangedNotificationsBetweenBackgroundPages) { |
| 172 CommandLine::ForCurrentProcess()->AppendSwitch( | 191 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 173 switches::kEnableExperimentalExtensionApis); | 192 switches::kEnableExperimentalExtensionApis); |
| 174 | 193 |
| 175 // We need 2 ResultCatchers because we'll be running the same test in both | 194 // We need 2 ResultCatchers because we'll be running the same test in both |
| 176 // regular and incognito mode. | 195 // regular and incognito mode. |
| 177 ResultCatcher catcher, catcher_incognito; | 196 ResultCatcher catcher, catcher_incognito; |
| 178 catcher.RestrictToProfile(browser()->profile()); | 197 catcher.RestrictToProfile(browser()->profile()); |
| 179 catcher_incognito.RestrictToProfile( | 198 catcher_incognito.RestrictToProfile( |
| 180 browser()->profile()->GetOffTheRecordProfile()); | 199 browser()->profile()->GetOffTheRecordProfile()); |
| 181 | 200 |
| 182 LoadAndReplyWhenSatisfied( | 201 LoadAndReplyWhenSatisfied(SYNC, |
| 183 "assertNoNotifications", "assertNoNotifications", "split_incognito"); | 202 "assertNoNotifications", "assertNoNotifications", "split_incognito"); |
| 184 ReplyWhenSatisfied("noop", "setFoo"); | 203 ReplyWhenSatisfied(SYNC, "noop", "setFoo"); |
| 185 ReplyWhenSatisfied("assertAddFooNotification", "assertAddFooNotification"); | 204 ReplyWhenSatisfied(SYNC, |
| 186 ReplyWhenSatisfied("clearNotifications", "clearNotifications"); | 205 "assertAddFooNotification", "assertAddFooNotification"); |
| 187 ReplyWhenSatisfied("removeFoo", "noop"); | 206 ReplyWhenSatisfied(SYNC, "clearNotifications", "clearNotifications"); |
| 188 FinalReplyWhenSatisfied( | 207 ReplyWhenSatisfied(SYNC, "removeFoo", "noop"); |
| 208 FinalReplyWhenSatisfied(SYNC, |
| 189 "assertDeleteFooNotification", "assertDeleteFooNotification"); | 209 "assertDeleteFooNotification", "assertDeleteFooNotification"); |
| 190 | 210 |
| 191 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 211 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 192 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); | 212 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); |
| 213 } |
| 214 |
| 215 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, |
| 216 SyncAndLocalAreasAreSeparate) { |
| 217 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 218 switches::kEnableExperimentalExtensionApis); |
| 219 |
| 220 // We need 2 ResultCatchers because we'll be running the same test in both |
| 221 // regular and incognito mode. |
| 222 ResultCatcher catcher, catcher_incognito; |
| 223 catcher.RestrictToProfile(browser()->profile()); |
| 224 catcher_incognito.RestrictToProfile( |
| 225 browser()->profile()->GetOffTheRecordProfile()); |
| 226 |
| 227 LoadAndReplyWhenSatisfied(SYNC, |
| 228 "assertNoNotifications", "assertNoNotifications", "split_incognito"); |
| 229 |
| 230 ReplyWhenSatisfied(SYNC, "noop", "setFoo"); |
| 231 ReplyWhenSatisfied(SYNC, "assertFoo", "assertFoo"); |
| 232 ReplyWhenSatisfied(SYNC, |
| 233 "assertAddFooNotification", "assertAddFooNotification"); |
| 234 ReplyWhenSatisfied(LOCAL, "assertEmpty", "assertEmpty"); |
| 235 ReplyWhenSatisfied(LOCAL, "assertNoNotifications", "assertNoNotifications"); |
| 236 |
| 237 ReplyWhenSatisfied(SYNC, "clearNotifications", "clearNotifications"); |
| 238 |
| 239 ReplyWhenSatisfied(LOCAL, "setFoo", "noop"); |
| 240 ReplyWhenSatisfied(LOCAL, "assertFoo", "assertFoo"); |
| 241 ReplyWhenSatisfied(LOCAL, |
| 242 "assertAddFooNotification", "assertAddFooNotification"); |
| 243 ReplyWhenSatisfied(SYNC, "assertFoo", "assertFoo"); |
| 244 ReplyWhenSatisfied(SYNC, "assertNoNotifications", "assertNoNotifications"); |
| 245 |
| 246 ReplyWhenSatisfied(LOCAL, "clearNotifications", "clearNotifications"); |
| 247 |
| 248 ReplyWhenSatisfied(LOCAL, "noop", "removeFoo"); |
| 249 ReplyWhenSatisfied(LOCAL, "assertEmpty", "assertEmpty"); |
| 250 ReplyWhenSatisfied(LOCAL, |
| 251 "assertDeleteFooNotification", "assertDeleteFooNotification"); |
| 252 ReplyWhenSatisfied(SYNC, "assertFoo", "assertFoo"); |
| 253 ReplyWhenSatisfied(SYNC, "assertNoNotifications", "assertNoNotifications"); |
| 254 |
| 255 ReplyWhenSatisfied(LOCAL, "clearNotifications", "clearNotifications"); |
| 256 |
| 257 ReplyWhenSatisfied(SYNC, "removeFoo", "noop"); |
| 258 ReplyWhenSatisfied(SYNC, "assertEmpty", "assertEmpty"); |
| 259 ReplyWhenSatisfied(SYNC, |
| 260 "assertDeleteFooNotification", "assertDeleteFooNotification"); |
| 261 ReplyWhenSatisfied(LOCAL, "assertNoNotifications", "assertNoNotifications"); |
| 262 FinalReplyWhenSatisfied(LOCAL, "assertEmpty", "assertEmpty"); |
| 263 |
| 264 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 265 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); |
| 193 } | 266 } |
| 194 | 267 |
| 195 // Disabled, see crbug.com/101110 | 268 // Disabled, see crbug.com/101110 |
| 196 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, | 269 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, |
| 197 DISABLED_OnChangedNotificationsFromSync) { | 270 DISABLED_OnChangedNotificationsFromSync) { |
| 198 CommandLine::ForCurrentProcess()->AppendSwitch( | 271 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 199 switches::kEnableExperimentalExtensionApis); | 272 switches::kEnableExperimentalExtensionApis); |
| 200 | 273 |
| 201 // We need 2 ResultCatchers because we'll be running the same test in both | 274 // We need 2 ResultCatchers because we'll be running the same test in both |
| 202 // regular and incognito mode. | 275 // regular and incognito mode. |
| 203 ResultCatcher catcher, catcher_incognito; | 276 ResultCatcher catcher, catcher_incognito; |
| 204 catcher.RestrictToProfile(browser()->profile()); | 277 catcher.RestrictToProfile(browser()->profile()); |
| 205 catcher_incognito.RestrictToProfile( | 278 catcher_incognito.RestrictToProfile( |
| 206 browser()->profile()->GetOffTheRecordProfile()); | 279 browser()->profile()->GetOffTheRecordProfile()); |
| 207 | 280 |
| 208 const Extension* extension = | 281 const Extension* extension = |
| 209 LoadAndReplyWhenSatisfied( | 282 LoadAndReplyWhenSatisfied(SYNC, |
| 210 "assertNoNotifications", "assertNoNotifications", "split_incognito"); | 283 "assertNoNotifications", "assertNoNotifications", "split_incognito"); |
| 211 const std::string& extension_id = extension->id(); | 284 const std::string& extension_id = extension->id(); |
| 212 | 285 |
| 213 NoopSyncChangeProcessor sync_processor; | 286 NoopSyncChangeProcessor sync_processor; |
| 214 InitSync(&sync_processor); | 287 InitSync(&sync_processor); |
| 215 | 288 |
| 216 // Set "foo" to "bar" via sync. | 289 // Set "foo" to "bar" via sync. |
| 217 SyncChangeList sync_changes; | 290 SyncChangeList sync_changes; |
| 218 StringValue bar("bar"); | 291 StringValue bar("bar"); |
| 219 sync_changes.push_back(settings_sync_util::CreateAdd( | 292 sync_changes.push_back(settings_sync_util::CreateAdd( |
| 220 extension_id, "foo", bar)); | 293 extension_id, "foo", bar)); |
| 221 SendChanges(sync_changes); | 294 SendChanges(sync_changes); |
| 222 | 295 |
| 223 ReplyWhenSatisfied("assertAddFooNotification", "assertAddFooNotification"); | 296 ReplyWhenSatisfied(SYNC, |
| 224 ReplyWhenSatisfied("clearNotifications", "clearNotifications"); | 297 "assertAddFooNotification", "assertAddFooNotification"); |
| 298 ReplyWhenSatisfied(SYNC, "clearNotifications", "clearNotifications"); |
| 225 | 299 |
| 226 // Remove "foo" via sync. | 300 // Remove "foo" via sync. |
| 227 sync_changes.clear(); | 301 sync_changes.clear(); |
| 228 sync_changes.push_back(settings_sync_util::CreateDelete( | 302 sync_changes.push_back(settings_sync_util::CreateDelete( |
| 229 extension_id, "foo")); | 303 extension_id, "foo")); |
| 230 SendChanges(sync_changes); | 304 SendChanges(sync_changes); |
| 231 | 305 |
| 232 FinalReplyWhenSatisfied( | 306 FinalReplyWhenSatisfied(SYNC, |
| 233 "assertDeleteFooNotification", "assertDeleteFooNotification"); | 307 "assertDeleteFooNotification", "assertDeleteFooNotification"); |
| 234 | 308 |
| 235 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 309 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 236 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); | 310 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); |
| 237 } | 311 } |
| 238 | 312 |
| 313 // Disabled, see crbug.com/101110 |
| 314 // |
| 315 // TODO: boring test, already done in the unit tests. What we really should be |
| 316 // be testing is that the areas don't overlap. |
| 317 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, |
| 318 DISABLED_OnChangedNotificationsFromSyncNotSentToLocal) { |
| 319 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 320 switches::kEnableExperimentalExtensionApis); |
| 321 |
| 322 // We need 2 ResultCatchers because we'll be running the same test in both |
| 323 // regular and incognito mode. |
| 324 ResultCatcher catcher, catcher_incognito; |
| 325 catcher.RestrictToProfile(browser()->profile()); |
| 326 catcher_incognito.RestrictToProfile( |
| 327 browser()->profile()->GetOffTheRecordProfile()); |
| 328 |
| 329 const Extension* extension = |
| 330 LoadAndReplyWhenSatisfied(LOCAL, |
| 331 "assertNoNotifications", "assertNoNotifications", "split_incognito"); |
| 332 const std::string& extension_id = extension->id(); |
| 333 |
| 334 NoopSyncChangeProcessor sync_processor; |
| 335 InitSync(&sync_processor); |
| 336 |
| 337 // Set "foo" to "bar" via sync. |
| 338 SyncChangeList sync_changes; |
| 339 StringValue bar("bar"); |
| 340 sync_changes.push_back(settings_sync_util::CreateAdd( |
| 341 extension_id, "foo", bar)); |
| 342 SendChanges(sync_changes); |
| 343 |
| 344 ReplyWhenSatisfied(LOCAL, "assertNoNotifications", "assertNoNotifications"); |
| 345 |
| 346 // Remove "foo" via sync. |
| 347 sync_changes.clear(); |
| 348 sync_changes.push_back(settings_sync_util::CreateDelete( |
| 349 extension_id, "foo")); |
| 350 SendChanges(sync_changes); |
| 351 |
| 352 FinalReplyWhenSatisfied(LOCAL, |
| 353 "assertNoNotifications", "assertNoNotifications"); |
| 354 |
| 355 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 356 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); |
| 357 } |
| 358 |
| 239 } // namespace extensions | 359 } // namespace extensions |
| OLD | NEW |