diff options
author | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 00:26:22 +0000 |
---|---|---|
committer | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 00:26:22 +0000 |
commit | 7210a1ecead3139538f3ef172c872c412b5b1b63 (patch) | |
tree | 44d082b68fc744326f510a82271488b69f0dc5c9 | |
parent | f364231fe56b96e0a14dcd5cce99d1ca3b9e6a94 (diff) | |
download | chromium_src-7210a1ecead3139538f3ef172c872c412b5b1b63.zip chromium_src-7210a1ecead3139538f3ef172c872c412b5b1b63.tar.gz chromium_src-7210a1ecead3139538f3ef172c872c412b5b1b63.tar.bz2 |
New P0 sync integration tests for Apps and Extensions
This patch adds a bunch of P0 sync integration tests for apps and
extensions that were previously blocked due to missing hooks in the
integration test harness.
Tests added:
TwoClientLiveAppsSyncTest.Add
TwoClientLiveAppsSyncTest.Uninstall
TwoClientLiveExtensionsSyncTest.Add
TwoClientLiveExtensionsSyncTest.Uninstall
Note: Do not commit before http://codereview.chromium.org/6995011 is landed.
BUG=82195
TEST=sync_integration_tests
Review URL: http://codereview.chromium.org/7008001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85222 0039d316-1c4b-4281-b951-d872f2087c98
8 files changed, 115 insertions, 8 deletions
diff --git a/chrome/test/live_sync/live_apps_sync_test.cc b/chrome/test/live_sync/live_apps_sync_test.cc index 3f2037c..885949a 100644 --- a/chrome/test/live_sync/live_apps_sync_test.cc +++ b/chrome/test/live_sync/live_apps_sync_test.cc @@ -9,6 +9,14 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/common/extensions/extension.h" +namespace { + +std::string CreateFakeAppName(int index) { + return "fakeapp" + base::IntToString(index); +} + +} // namespace + LiveAppsSyncTest::LiveAppsSyncTest(TestType test_type) : LiveSyncTest(test_type) {} @@ -46,9 +54,14 @@ bool LiveAppsSyncTest::AllProfilesHaveSameAppsAsVerifier() { } void LiveAppsSyncTest::InstallApp(Profile* profile, int index) { - std::string name = "fakeapp" + base::IntToString(index); - return extension_helper_.InstallExtension( - profile, name, Extension::TYPE_HOSTED_APP); + return extension_helper_.InstallExtension(profile, + CreateFakeAppName(index), + Extension::TYPE_HOSTED_APP); +} + +void LiveAppsSyncTest::UninstallApp(Profile* profile, int index) { + return extension_helper_.UninstallExtension(profile, + CreateFakeAppName(index)); } void LiveAppsSyncTest::InstallAppsPendingForSync( diff --git a/chrome/test/live_sync/live_apps_sync_test.h b/chrome/test/live_sync/live_apps_sync_test.h index 84d0a01..78dda33 100644 --- a/chrome/test/live_sync/live_apps_sync_test.h +++ b/chrome/test/live_sync/live_apps_sync_test.h @@ -34,6 +34,10 @@ class LiveAppsSyncTest : public LiveSyncTest { // Installs the app for the given index to |profile|. void InstallApp(Profile* profile, int index); + // Uninstalls the app for the given index from |profile|. Assumes that it was + // previously installed. + void UninstallApp(Profile* profile, int index); + // Installs all pending synced apps for |profile|. void InstallAppsPendingForSync(Profile* profile); diff --git a/chrome/test/live_sync/live_extensions_sync_test.cc b/chrome/test/live_sync/live_extensions_sync_test.cc index a3cfaa9..9b4f92b 100644 --- a/chrome/test/live_sync/live_extensions_sync_test.cc +++ b/chrome/test/live_sync/live_extensions_sync_test.cc @@ -9,6 +9,14 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/common/extensions/extension.h" +namespace { + +std::string CreateFakeExtensionName(int index) { + return "fakeextension" + base::IntToString(index); +} + +} // namespace + LiveExtensionsSyncTest::LiveExtensionsSyncTest(TestType test_type) : LiveSyncTest(test_type) {} @@ -44,9 +52,14 @@ bool LiveExtensionsSyncTest::AllProfilesHaveSameExtensionsAsVerifier() { } void LiveExtensionsSyncTest::InstallExtension(Profile* profile, int index) { - std::string name = "fakeextension" + base::IntToString(index); - return extension_helper_.InstallExtension( - profile, name, Extension::TYPE_EXTENSION); + return extension_helper_.InstallExtension(profile, + CreateFakeExtensionName(index), + Extension::TYPE_EXTENSION); +} + +void LiveExtensionsSyncTest::UninstallExtension(Profile* profile, int index) { + return extension_helper_.UninstallExtension(profile, + CreateFakeExtensionName(index)); } void LiveExtensionsSyncTest::InstallExtensionsPendingForSync( diff --git a/chrome/test/live_sync/live_extensions_sync_test.h b/chrome/test/live_sync/live_extensions_sync_test.h index c8a989f..ce038fa 100644 --- a/chrome/test/live_sync/live_extensions_sync_test.h +++ b/chrome/test/live_sync/live_extensions_sync_test.h @@ -34,6 +34,10 @@ class LiveExtensionsSyncTest : public LiveSyncTest { // Installs the extension for the given index to |profile|. void InstallExtension(Profile* profile, int index); + // Uninstalls the extension for the given index from |profile|. Assumes that + // it was previously installed. + void UninstallExtension(Profile* profile, int index); + // Installs all pending synced extensions for |profile|. void InstallExtensionsPendingForSync(Profile* profile); diff --git a/chrome/test/live_sync/live_sync_extension_helper.cc b/chrome/test/live_sync/live_sync_extension_helper.cc index 30e0988..a3e3fc7 100644 --- a/chrome/test/live_sync/live_sync_extension_helper.cc +++ b/chrome/test/live_sync/live_sync_extension_helper.cc @@ -52,6 +52,12 @@ void LiveSyncExtensionHelper::InstallExtension( profile->GetExtensionService()->OnExtensionInstalled(extension); } +void LiveSyncExtensionHelper::UninstallExtension( + Profile* profile, const std::string& name) { + ExtensionService::UninstallExtensionHelper(profile->GetExtensionService(), + NameToId(name)); +} + bool LiveSyncExtensionHelper::IsExtensionPendingInstallForSync( Profile* profile, const std::string& id) const { const PendingExtensionManager* pending_extension_manager = diff --git a/chrome/test/live_sync/live_sync_extension_helper.h b/chrome/test/live_sync/live_sync_extension_helper.h index bb1663f..188d9b3 100644 --- a/chrome/test/live_sync/live_sync_extension_helper.h +++ b/chrome/test/live_sync/live_sync_extension_helper.h @@ -38,6 +38,9 @@ class LiveSyncExtensionHelper { void InstallExtension( Profile* profile, const std::string& name, Extension::Type type); + // Uninstalls the extension with the given name from |profile|. + void UninstallExtension(Profile* profile, const std::string& name); + // Returns true iff the extension with the given id is pending // install in |profile|. bool IsExtensionPendingInstallForSync( diff --git a/chrome/test/live_sync/two_client_live_apps_sync_test.cc b/chrome/test/live_sync/two_client_live_apps_sync_test.cc index 2e369f1..5f119fc 100644 --- a/chrome/test/live_sync/two_client_live_apps_sync_test.cc +++ b/chrome/test/live_sync/two_client_live_apps_sync_test.cc @@ -114,6 +114,39 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAppsSyncTest, ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); } +// TCM ID - 3711279. +IN_PROC_BROWSER_TEST_F(TwoClientLiveAppsSyncTest, Add) { + ASSERT_TRUE(SetupSync()); + ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); + + InstallApp(GetProfile(0), 0); + InstallApp(verifier(), 0); + ASSERT_TRUE(AwaitQuiescence()); + + InstallAppsPendingForSync(GetProfile(0)); + InstallAppsPendingForSync(GetProfile(1)); + ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); +} + +// TCM ID - 3706267. +IN_PROC_BROWSER_TEST_F(TwoClientLiveAppsSyncTest, Uninstall) { + ASSERT_TRUE(SetupSync()); + ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); + + InstallApp(GetProfile(0), 0); + InstallApp(verifier(), 0); + ASSERT_TRUE(AwaitQuiescence()); + + InstallAppsPendingForSync(GetProfile(0)); + InstallAppsPendingForSync(GetProfile(1)); + ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); + + UninstallApp(GetProfile(0), 0); + UninstallApp(verifier(), 0); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); +} + // TCM ID - 3718276. IN_PROC_BROWSER_TEST_F(TwoClientLiveAppsSyncTest, DisableApps) { ASSERT_TRUE(SetupSync()); @@ -155,6 +188,5 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveAppsSyncTest, DisableSync) { } // TODO(akalin): Add tests exercising: -// - App uninstallation // - Offline installation/uninstallation behavior // - App-specific properties diff --git a/chrome/test/live_sync/two_client_live_extensions_sync_test.cc b/chrome/test/live_sync/two_client_live_extensions_sync_test.cc index 0df61f7..6c72e67 100644 --- a/chrome/test/live_sync/two_client_live_extensions_sync_test.cc +++ b/chrome/test/live_sync/two_client_live_extensions_sync_test.cc @@ -114,6 +114,39 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveExtensionsSyncTest, ASSERT_TRUE(AllProfilesHaveSameExtensionsAsVerifier()); } +// TCM ID - 3637311. +IN_PROC_BROWSER_TEST_F(TwoClientLiveExtensionsSyncTest, Add) { + ASSERT_TRUE(SetupSync()); + ASSERT_TRUE(AllProfilesHaveSameExtensionsAsVerifier()); + + InstallExtension(GetProfile(0), 0); + InstallExtension(verifier(), 0); + ASSERT_TRUE(AwaitQuiescence()); + + InstallExtensionsPendingForSync(GetProfile(0)); + InstallExtensionsPendingForSync(GetProfile(1)); + ASSERT_TRUE(AllProfilesHaveSameExtensionsAsVerifier()); +} + +// TCM ID - 3724281. +IN_PROC_BROWSER_TEST_F(TwoClientLiveExtensionsSyncTest, Uninstall) { + ASSERT_TRUE(SetupSync()); + ASSERT_TRUE(AllProfilesHaveSameExtensionsAsVerifier()); + + InstallExtension(GetProfile(0), 0); + InstallExtension(verifier(), 0); + ASSERT_TRUE(AwaitQuiescence()); + + InstallExtensionsPendingForSync(GetProfile(0)); + InstallExtensionsPendingForSync(GetProfile(1)); + ASSERT_TRUE(AllProfilesHaveSameExtensionsAsVerifier()); + + UninstallExtension(GetProfile(0), 0); + UninstallExtension(verifier(), 0); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllProfilesHaveSameExtensionsAsVerifier()); +} + // TCM ID - 3732278. IN_PROC_BROWSER_TEST_F(TwoClientLiveExtensionsSyncTest, DisableExtensions) { ASSERT_TRUE(SetupSync()); @@ -155,5 +188,4 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveExtensionsSyncTest, DisableSync) { } // TODO(akalin): Add tests exercising: -// - Extension uninstallation // - Offline installation/uninstallation behavior |