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/json/json_writer.h" | 6 #include "base/json/json_writer.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/extensions/api/storage/settings_sync_util.h" | 10 #include "chrome/browser/extensions/api/storage/settings_sync_util.h" |
11 #include "chrome/browser/extensions/extension_apitest.h" | 11 #include "chrome/browser/extensions/extension_apitest.h" |
12 #include "chrome/browser/extensions/extension_system_factory.h" | 12 #include "chrome/browser/extensions/extension_system_factory.h" |
13 #include "chrome/browser/extensions/extension_test_message_listener.h" | 13 #include "chrome/browser/extensions/extension_test_message_listener.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
17 #include "extensions/browser/api/storage/settings_namespace.h" | 17 #include "extensions/browser/api/storage/settings_namespace.h" |
18 #include "extensions/browser/api/storage/storage_frontend.h" | 18 #include "extensions/browser/api/storage/storage_frontend.h" |
19 #include "extensions/browser/extension_system.h" | 19 #include "extensions/browser/extension_system.h" |
20 #include "extensions/common/value_builder.h" | 20 #include "extensions/common/value_builder.h" |
| 21 #include "extensions/test/result_catcher.h" |
21 #include "sync/api/fake_sync_change_processor.h" | 22 #include "sync/api/fake_sync_change_processor.h" |
22 #include "sync/api/sync_change.h" | 23 #include "sync/api/sync_change.h" |
23 #include "sync/api/sync_change_processor.h" | 24 #include "sync/api/sync_change_processor.h" |
24 #include "sync/api/sync_change_processor_wrapper_for_test.h" | 25 #include "sync/api/sync_change_processor_wrapper_for_test.h" |
25 #include "sync/api/sync_error_factory.h" | 26 #include "sync/api/sync_error_factory.h" |
26 #include "sync/api/sync_error_factory_mock.h" | 27 #include "sync/api/sync_error_factory_mock.h" |
27 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" |
28 | 29 |
29 #if defined(ENABLE_CONFIGURATION_POLICY) | 30 #if defined(ENABLE_CONFIGURATION_POLICY) |
30 #include "chrome/browser/policy/schema_registry_service.h" | 31 #include "chrome/browser/policy/schema_registry_service.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 } | 218 } |
218 | 219 |
219 // Structure of this test taken from IncognitoSplitMode. | 220 // Structure of this test taken from IncognitoSplitMode. |
220 // Note that only split-mode incognito is tested, because spanning mode | 221 // Note that only split-mode incognito is tested, because spanning mode |
221 // incognito looks the same as normal mode when the only API activity comes | 222 // incognito looks the same as normal mode when the only API activity comes |
222 // from background pages. | 223 // from background pages. |
223 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, SplitModeIncognito) { | 224 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, SplitModeIncognito) { |
224 // We need 2 ResultCatchers because we'll be running the same test in both | 225 // We need 2 ResultCatchers because we'll be running the same test in both |
225 // regular and incognito mode. | 226 // regular and incognito mode. |
226 ResultCatcher catcher, catcher_incognito; | 227 ResultCatcher catcher, catcher_incognito; |
227 catcher.RestrictToProfile(browser()->profile()); | 228 catcher.RestrictToBrowserContext(browser()->profile()); |
228 catcher_incognito.RestrictToProfile( | 229 catcher_incognito.RestrictToBrowserContext( |
229 browser()->profile()->GetOffTheRecordProfile()); | 230 browser()->profile()->GetOffTheRecordProfile()); |
230 | 231 |
231 LoadAndReplyWhenSatisfied(SYNC, | 232 LoadAndReplyWhenSatisfied(SYNC, |
232 "assertEmpty", "assertEmpty", "split_incognito"); | 233 "assertEmpty", "assertEmpty", "split_incognito"); |
233 ReplyWhenSatisfied(SYNC, "noop", "setFoo"); | 234 ReplyWhenSatisfied(SYNC, "noop", "setFoo"); |
234 ReplyWhenSatisfied(SYNC, "assertFoo", "assertFoo"); | 235 ReplyWhenSatisfied(SYNC, "assertFoo", "assertFoo"); |
235 ReplyWhenSatisfied(SYNC, "clear", "noop"); | 236 ReplyWhenSatisfied(SYNC, "clear", "noop"); |
236 ReplyWhenSatisfied(SYNC, "assertEmpty", "assertEmpty"); | 237 ReplyWhenSatisfied(SYNC, "assertEmpty", "assertEmpty"); |
237 ReplyWhenSatisfied(SYNC, "setFoo", "noop"); | 238 ReplyWhenSatisfied(SYNC, "setFoo", "noop"); |
238 ReplyWhenSatisfied(SYNC, "assertFoo", "assertFoo"); | 239 ReplyWhenSatisfied(SYNC, "assertFoo", "assertFoo"); |
239 ReplyWhenSatisfied(SYNC, "noop", "removeFoo"); | 240 ReplyWhenSatisfied(SYNC, "noop", "removeFoo"); |
240 FinalReplyWhenSatisfied(SYNC, "assertEmpty", "assertEmpty"); | 241 FinalReplyWhenSatisfied(SYNC, "assertEmpty", "assertEmpty"); |
241 | 242 |
242 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 243 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
243 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); | 244 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); |
244 } | 245 } |
245 | 246 |
246 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, | 247 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, |
247 OnChangedNotificationsBetweenBackgroundPages) { | 248 OnChangedNotificationsBetweenBackgroundPages) { |
248 // We need 2 ResultCatchers because we'll be running the same test in both | 249 // We need 2 ResultCatchers because we'll be running the same test in both |
249 // regular and incognito mode. | 250 // regular and incognito mode. |
250 ResultCatcher catcher, catcher_incognito; | 251 ResultCatcher catcher, catcher_incognito; |
251 catcher.RestrictToProfile(browser()->profile()); | 252 catcher.RestrictToBrowserContext(browser()->profile()); |
252 catcher_incognito.RestrictToProfile( | 253 catcher_incognito.RestrictToBrowserContext( |
253 browser()->profile()->GetOffTheRecordProfile()); | 254 browser()->profile()->GetOffTheRecordProfile()); |
254 | 255 |
255 LoadAndReplyWhenSatisfied(SYNC, | 256 LoadAndReplyWhenSatisfied(SYNC, |
256 "assertNoNotifications", "assertNoNotifications", "split_incognito"); | 257 "assertNoNotifications", "assertNoNotifications", "split_incognito"); |
257 ReplyWhenSatisfied(SYNC, "noop", "setFoo"); | 258 ReplyWhenSatisfied(SYNC, "noop", "setFoo"); |
258 ReplyWhenSatisfied(SYNC, | 259 ReplyWhenSatisfied(SYNC, |
259 "assertAddFooNotification", "assertAddFooNotification"); | 260 "assertAddFooNotification", "assertAddFooNotification"); |
260 ReplyWhenSatisfied(SYNC, "clearNotifications", "clearNotifications"); | 261 ReplyWhenSatisfied(SYNC, "clearNotifications", "clearNotifications"); |
261 ReplyWhenSatisfied(SYNC, "removeFoo", "noop"); | 262 ReplyWhenSatisfied(SYNC, "removeFoo", "noop"); |
262 FinalReplyWhenSatisfied(SYNC, | 263 FinalReplyWhenSatisfied(SYNC, |
263 "assertDeleteFooNotification", "assertDeleteFooNotification"); | 264 "assertDeleteFooNotification", "assertDeleteFooNotification"); |
264 | 265 |
265 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 266 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
266 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); | 267 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); |
267 } | 268 } |
268 | 269 |
269 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, | 270 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, |
270 SyncAndLocalAreasAreSeparate) { | 271 SyncAndLocalAreasAreSeparate) { |
271 // We need 2 ResultCatchers because we'll be running the same test in both | 272 // We need 2 ResultCatchers because we'll be running the same test in both |
272 // regular and incognito mode. | 273 // regular and incognito mode. |
273 ResultCatcher catcher, catcher_incognito; | 274 ResultCatcher catcher, catcher_incognito; |
274 catcher.RestrictToProfile(browser()->profile()); | 275 catcher.RestrictToBrowserContext(browser()->profile()); |
275 catcher_incognito.RestrictToProfile( | 276 catcher_incognito.RestrictToBrowserContext( |
276 browser()->profile()->GetOffTheRecordProfile()); | 277 browser()->profile()->GetOffTheRecordProfile()); |
277 | 278 |
278 LoadAndReplyWhenSatisfied(SYNC, | 279 LoadAndReplyWhenSatisfied(SYNC, |
279 "assertNoNotifications", "assertNoNotifications", "split_incognito"); | 280 "assertNoNotifications", "assertNoNotifications", "split_incognito"); |
280 | 281 |
281 ReplyWhenSatisfied(SYNC, "noop", "setFoo"); | 282 ReplyWhenSatisfied(SYNC, "noop", "setFoo"); |
282 ReplyWhenSatisfied(SYNC, "assertFoo", "assertFoo"); | 283 ReplyWhenSatisfied(SYNC, "assertFoo", "assertFoo"); |
283 ReplyWhenSatisfied(SYNC, | 284 ReplyWhenSatisfied(SYNC, |
284 "assertAddFooNotification", "assertAddFooNotification"); | 285 "assertAddFooNotification", "assertAddFooNotification"); |
285 ReplyWhenSatisfied(LOCAL, "assertEmpty", "assertEmpty"); | 286 ReplyWhenSatisfied(LOCAL, "assertEmpty", "assertEmpty"); |
(...skipping 29 matching lines...) Expand all Loading... |
315 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 316 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
316 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); | 317 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); |
317 } | 318 } |
318 | 319 |
319 // Disabled, see crbug.com/101110 | 320 // Disabled, see crbug.com/101110 |
320 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, | 321 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, |
321 DISABLED_OnChangedNotificationsFromSync) { | 322 DISABLED_OnChangedNotificationsFromSync) { |
322 // We need 2 ResultCatchers because we'll be running the same test in both | 323 // We need 2 ResultCatchers because we'll be running the same test in both |
323 // regular and incognito mode. | 324 // regular and incognito mode. |
324 ResultCatcher catcher, catcher_incognito; | 325 ResultCatcher catcher, catcher_incognito; |
325 catcher.RestrictToProfile(browser()->profile()); | 326 catcher.RestrictToBrowserContext(browser()->profile()); |
326 catcher_incognito.RestrictToProfile( | 327 catcher_incognito.RestrictToBrowserContext( |
327 browser()->profile()->GetOffTheRecordProfile()); | 328 browser()->profile()->GetOffTheRecordProfile()); |
328 | 329 |
329 const Extension* extension = | 330 const Extension* extension = |
330 LoadAndReplyWhenSatisfied(SYNC, | 331 LoadAndReplyWhenSatisfied(SYNC, |
331 "assertNoNotifications", "assertNoNotifications", "split_incognito"); | 332 "assertNoNotifications", "assertNoNotifications", "split_incognito"); |
332 const std::string& extension_id = extension->id(); | 333 const std::string& extension_id = extension->id(); |
333 | 334 |
334 syncer::FakeSyncChangeProcessor sync_processor; | 335 syncer::FakeSyncChangeProcessor sync_processor; |
335 InitSync(&sync_processor); | 336 InitSync(&sync_processor); |
336 | 337 |
(...skipping 23 matching lines...) Expand all Loading... |
360 | 361 |
361 // Disabled, see crbug.com/101110 | 362 // Disabled, see crbug.com/101110 |
362 // | 363 // |
363 // TODO: boring test, already done in the unit tests. What we really should be | 364 // TODO: boring test, already done in the unit tests. What we really should be |
364 // be testing is that the areas don't overlap. | 365 // be testing is that the areas don't overlap. |
365 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, | 366 IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, |
366 DISABLED_OnChangedNotificationsFromSyncNotSentToLocal) { | 367 DISABLED_OnChangedNotificationsFromSyncNotSentToLocal) { |
367 // We need 2 ResultCatchers because we'll be running the same test in both | 368 // We need 2 ResultCatchers because we'll be running the same test in both |
368 // regular and incognito mode. | 369 // regular and incognito mode. |
369 ResultCatcher catcher, catcher_incognito; | 370 ResultCatcher catcher, catcher_incognito; |
370 catcher.RestrictToProfile(browser()->profile()); | 371 catcher.RestrictToBrowserContext(browser()->profile()); |
371 catcher_incognito.RestrictToProfile( | 372 catcher_incognito.RestrictToBrowserContext( |
372 browser()->profile()->GetOffTheRecordProfile()); | 373 browser()->profile()->GetOffTheRecordProfile()); |
373 | 374 |
374 const Extension* extension = | 375 const Extension* extension = |
375 LoadAndReplyWhenSatisfied(LOCAL, | 376 LoadAndReplyWhenSatisfied(LOCAL, |
376 "assertNoNotifications", "assertNoNotifications", "split_incognito"); | 377 "assertNoNotifications", "assertNoNotifications", "split_incognito"); |
377 const std::string& extension_id = extension->id(); | 378 const std::string& extension_id = extension->id(); |
378 | 379 |
379 syncer::FakeSyncChangeProcessor sync_processor; | 380 syncer::FakeSyncChangeProcessor sync_processor; |
380 InitSync(&sync_processor); | 381 InitSync(&sync_processor); |
381 | 382 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 // ENABLE_CONFIGURATION_POLICY is not defined. | 573 // ENABLE_CONFIGURATION_POLICY is not defined. |
573 StorageFrontend* frontend = StorageFrontend::Get(browser()->profile()); | 574 StorageFrontend* frontend = StorageFrontend::Get(browser()->profile()); |
574 frontend->DisableStorageForTesting(MANAGED); | 575 frontend->DisableStorageForTesting(MANAGED); |
575 EXPECT_FALSE(frontend->IsStorageEnabled(MANAGED)); | 576 EXPECT_FALSE(frontend->IsStorageEnabled(MANAGED)); |
576 // Now run the extension. | 577 // Now run the extension. |
577 ASSERT_TRUE(RunExtensionTest("settings/managed_storage_disabled")) | 578 ASSERT_TRUE(RunExtensionTest("settings/managed_storage_disabled")) |
578 << message_; | 579 << message_; |
579 } | 580 } |
580 | 581 |
581 } // namespace extensions | 582 } // namespace extensions |
OLD | NEW |