diff options
Diffstat (limited to 'chrome/browser/sync')
-rw-r--r-- | chrome/browser/sync/test/integration/sync_app_helper.cc | 11 | ||||
-rw-r--r-- | chrome/browser/sync/test/integration/two_client_apps_sync_test.cc | 70 |
2 files changed, 79 insertions, 2 deletions
diff --git a/chrome/browser/sync/test/integration/sync_app_helper.cc b/chrome/browser/sync/test/integration/sync_app_helper.cc index 5e1f845..cde49ed 100644 --- a/chrome/browser/sync/test/integration/sync_app_helper.cc +++ b/chrome/browser/sync/test/integration/sync_app_helper.cc @@ -6,10 +6,12 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" +#include "chrome/browser/extensions/launch_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/test/integration/extensions_helper.h" #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" #include "chrome/browser/sync/test/integration/sync_extension_helper.h" +#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/sync_helper.h" #include "extensions/browser/app_sorting.h" #include "extensions/common/extension.h" @@ -26,11 +28,12 @@ struct AppState { syncer::StringOrdinal app_launch_ordinal; syncer::StringOrdinal page_ordinal; + extensions::LaunchType launch_type; }; typedef std::map<std::string, AppState> AppStateMap; -AppState::AppState() {} +AppState::AppState() : launch_type(extensions::LAUNCH_TYPE_INVALID) {} AppState::~AppState() {} @@ -40,7 +43,8 @@ bool AppState::IsValid() const { bool AppState::Equals(const AppState& other) const { return app_launch_ordinal.Equals(other.app_launch_ordinal) && - page_ordinal.Equals(other.page_ordinal); + page_ordinal.Equals(other.page_ordinal) && + launch_type == other.launch_type; } // Load all the app specific values for |id| into |app_state|. @@ -51,6 +55,9 @@ void LoadApp(ExtensionService* extension_service, app_sorting()->GetAppLaunchOrdinal(id); app_state->page_ordinal = extension_service->extension_prefs()-> app_sorting()->GetPageOrdinal(id); + app_state->launch_type = + extensions::GetLaunchTypePrefValue(extension_service->extension_prefs(), + id); } // Returns a map from |profile|'s installed extensions to their state. diff --git a/chrome/browser/sync/test/integration/two_client_apps_sync_test.cc b/chrome/browser/sync/test/integration/two_client_apps_sync_test.cc index 9d953db..8b9e9a9 100644 --- a/chrome/browser/sync/test/integration/two_client_apps_sync_test.cc +++ b/chrome/browser/sync/test/integration/two_client_apps_sync_test.cc @@ -4,6 +4,7 @@ #include "base/basictypes.h" #include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/extensions/launch_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/test/integration/apps_helper.h" #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" @@ -422,6 +423,75 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateCWSOrdinals) { ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); } +// Adjust the launch type on the first client and sync. Both clients should +// have the same launch type values for the CWS. +IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateLaunchType) { + ASSERT_TRUE(SetupSync()); + ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); + + // Change the launch type to window. + extensions::SetLaunchType(GetProfile(1)->GetExtensionService(), + extension_misc::kWebStoreAppId, + extensions::LAUNCH_TYPE_WINDOW); + extensions::SetLaunchType(verifier()->GetExtensionService(), + extension_misc::kWebStoreAppId, + extensions::LAUNCH_TYPE_WINDOW); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); + + // Change the launch type to regular tab. + extensions::SetLaunchType(GetProfile(1)->GetExtensionService(), + extension_misc::kWebStoreAppId, + extensions::LAUNCH_TYPE_REGULAR); + ASSERT_FALSE(HasSameAppsAsVerifier(1)); + extensions::SetLaunchType(verifier()->GetExtensionService(), + extension_misc::kWebStoreAppId, + extensions::LAUNCH_TYPE_REGULAR); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); +} + +IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UnexpectedLaunchType) { + ASSERT_TRUE(SetupSync()); + ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); + + extensions::SetLaunchType(GetProfile(1)->GetExtensionService(), + extension_misc::kWebStoreAppId, + extensions::LAUNCH_TYPE_REGULAR); + extensions::SetLaunchType(verifier()->GetExtensionService(), + extension_misc::kWebStoreAppId, + extensions::LAUNCH_TYPE_REGULAR); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); + + const extensions::Extension* extension = + GetProfile(1)->GetExtensionService()-> + GetInstalledExtension(extension_misc::kWebStoreAppId); + ASSERT_TRUE(extension); + + ExtensionSyncService* extension_sync_service = + ExtensionSyncService::Get(GetProfile(1)); + + extensions::AppSyncData original_data( + extension_sync_service->GetAppSyncData(*extension)); + + // Create an invalid launch type and ensure it doesn't get down-synced. This + // simulates the case of a future launch type being added which old versions + // don't yet understand. + extensions::AppSyncData invalid_launch_type_data( + *extension, + original_data.extension_sync_data().enabled(), + original_data.extension_sync_data().incognito_enabled(), + original_data.app_launch_ordinal(), + original_data.page_ordinal(), + extensions::NUM_LAUNCH_TYPES); + extension_sync_service->ProcessAppSyncData(invalid_launch_type_data); + + // The launch type should remain the same. + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); +} + // TODO(akalin): Add tests exercising: // - Offline installation/uninstallation behavior // - App-specific properties |