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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "chrome/browser/extensions/extension_service.h" | 6 #include "chrome/browser/extensions/extension_service.h" |
| 7 #include "chrome/browser/extensions/launch_util.h" |
7 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/sync/test/integration/apps_helper.h" | 9 #include "chrome/browser/sync/test/integration/apps_helper.h" |
9 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
10 #include "chrome/browser/sync/test/integration/sync_app_helper.h" | 11 #include "chrome/browser/sync/test/integration/sync_app_helper.h" |
11 #include "chrome/browser/sync/test/integration/sync_test.h" | 12 #include "chrome/browser/sync/test/integration/sync_test.h" |
12 #include "chrome/common/extensions/extension_constants.h" | 13 #include "chrome/common/extensions/extension_constants.h" |
13 #include "extensions/browser/app_sorting.h" | 14 #include "extensions/browser/app_sorting.h" |
14 #include "sync/api/string_ordinal.h" | 15 #include "sync/api/string_ordinal.h" |
15 | 16 |
16 using apps_helper::AllProfilesHaveSameAppsAsVerifier; | 17 using apps_helper::AllProfilesHaveSameAppsAsVerifier; |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 GetProfile(1)->GetExtensionService()->extension_prefs()-> | 416 GetProfile(1)->GetExtensionService()->extension_prefs()-> |
416 app_sorting()->SetPageOrdinal(extension_misc::kWebStoreAppId, | 417 app_sorting()->SetPageOrdinal(extension_misc::kWebStoreAppId, |
417 cws_page_ordinal.CreateAfter()); | 418 cws_page_ordinal.CreateAfter()); |
418 verifier()->GetExtensionService()->extension_prefs()-> | 419 verifier()->GetExtensionService()->extension_prefs()-> |
419 app_sorting()->SetPageOrdinal(extension_misc::kWebStoreAppId, | 420 app_sorting()->SetPageOrdinal(extension_misc::kWebStoreAppId, |
420 cws_page_ordinal.CreateAfter()); | 421 cws_page_ordinal.CreateAfter()); |
421 ASSERT_TRUE(AwaitQuiescence()); | 422 ASSERT_TRUE(AwaitQuiescence()); |
422 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | 423 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); |
423 } | 424 } |
424 | 425 |
| 426 // Adjust the launch type on the first client and sync. Both clients should |
| 427 // have the same launch type values for the CWS. |
| 428 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateLaunchType) { |
| 429 ASSERT_TRUE(SetupSync()); |
| 430 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); |
| 431 |
| 432 // Change the launch type to window. |
| 433 extensions::SetLaunchType(GetProfile(1)->GetExtensionService(), |
| 434 extension_misc::kWebStoreAppId, |
| 435 extensions::LAUNCH_TYPE_WINDOW); |
| 436 extensions::SetLaunchType(verifier()->GetExtensionService(), |
| 437 extension_misc::kWebStoreAppId, |
| 438 extensions::LAUNCH_TYPE_WINDOW); |
| 439 ASSERT_TRUE(AwaitQuiescence()); |
| 440 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); |
| 441 |
| 442 // Change the launch type to regular tab. |
| 443 extensions::SetLaunchType(GetProfile(1)->GetExtensionService(), |
| 444 extension_misc::kWebStoreAppId, |
| 445 extensions::LAUNCH_TYPE_REGULAR); |
| 446 ASSERT_FALSE(HasSameAppsAsVerifier(1)); |
| 447 extensions::SetLaunchType(verifier()->GetExtensionService(), |
| 448 extension_misc::kWebStoreAppId, |
| 449 extensions::LAUNCH_TYPE_REGULAR); |
| 450 ASSERT_TRUE(AwaitQuiescence()); |
| 451 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); |
| 452 } |
| 453 |
| 454 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UnexpectedLaunchType) { |
| 455 ASSERT_TRUE(SetupSync()); |
| 456 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); |
| 457 |
| 458 extensions::SetLaunchType(GetProfile(1)->GetExtensionService(), |
| 459 extension_misc::kWebStoreAppId, |
| 460 extensions::LAUNCH_TYPE_REGULAR); |
| 461 extensions::SetLaunchType(verifier()->GetExtensionService(), |
| 462 extension_misc::kWebStoreAppId, |
| 463 extensions::LAUNCH_TYPE_REGULAR); |
| 464 ASSERT_TRUE(AwaitQuiescence()); |
| 465 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); |
| 466 |
| 467 const extensions::Extension* extension = |
| 468 GetProfile(1)->GetExtensionService()-> |
| 469 GetInstalledExtension(extension_misc::kWebStoreAppId); |
| 470 ASSERT_TRUE(extension); |
| 471 |
| 472 ExtensionSyncService* extension_sync_service = |
| 473 ExtensionSyncService::Get(GetProfile(1)); |
| 474 |
| 475 extensions::AppSyncData original_data( |
| 476 extension_sync_service->GetAppSyncData(*extension)); |
| 477 |
| 478 // Create an invalid launch type and ensure it doesn't get down-synced. This |
| 479 // simulates the case of a future launch type being added which old versions |
| 480 // don't yet understand. |
| 481 extensions::AppSyncData invalid_launch_type_data( |
| 482 *extension, |
| 483 original_data.extension_sync_data().enabled(), |
| 484 original_data.extension_sync_data().incognito_enabled(), |
| 485 original_data.app_launch_ordinal(), |
| 486 original_data.page_ordinal(), |
| 487 extensions::NUM_LAUNCH_TYPES); |
| 488 extension_sync_service->ProcessAppSyncData(invalid_launch_type_data); |
| 489 |
| 490 // The launch type should remain the same. |
| 491 ASSERT_TRUE(AwaitQuiescence()); |
| 492 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); |
| 493 } |
| 494 |
425 // TODO(akalin): Add tests exercising: | 495 // TODO(akalin): Add tests exercising: |
426 // - Offline installation/uninstallation behavior | 496 // - Offline installation/uninstallation behavior |
427 // - App-specific properties | 497 // - App-specific properties |
OLD | NEW |