summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/sync/test/integration/apps_helper.cc10
-rw-r--r--chrome/browser/sync/test/integration/apps_helper.h14
-rw-r--r--chrome/browser/sync/test/integration/extensions_helper.cc3
-rw-r--r--chrome/browser/sync/test/integration/single_client_apps_sync_test.cc57
-rw-r--r--chrome/browser/sync/test/integration/sync_extension_helper.cc28
-rw-r--r--chrome/browser/sync/test/integration/sync_extension_helper.h5
-rw-r--r--chrome/browser/sync/test/integration/sync_test.cc3
-rw-r--r--chrome/browser/sync/test/integration/two_client_apps_sync_test.cc8
-rw-r--r--chrome/common/extensions/extension.cc1
9 files changed, 112 insertions, 17 deletions
diff --git a/chrome/browser/sync/test/integration/apps_helper.cc b/chrome/browser/sync/test/integration/apps_helper.cc
index faf0add..fe9a379 100644
--- a/chrome/browser/sync/test/integration/apps_helper.cc
+++ b/chrome/browser/sync/test/integration/apps_helper.cc
@@ -47,6 +47,13 @@ std::string InstallApp(Profile* profile, int index) {
extensions::Extension::TYPE_HOSTED_APP);
}
+std::string InstallPlatformApp(Profile* profile, int index) {
+ return SyncExtensionHelper::GetInstance()->InstallExtension(
+ profile,
+ CreateFakeAppName(index),
+ extensions::Extension::TYPE_PLATFORM_APP);
+}
+
std::string InstallAppForAllProfiles(int index) {
for (int i = 0; i < test()->num_clients(); ++i)
InstallApp(test()->GetProfile(i), index);
@@ -79,8 +86,7 @@ void IncognitoDisableApp(Profile* profile, int index) {
}
void InstallAppsPendingForSync(Profile* profile) {
- SyncExtensionHelper::GetInstance()->InstallExtensionsPendingForSync(
- profile, extensions::Extension::TYPE_HOSTED_APP);
+ SyncExtensionHelper::GetInstance()->InstallExtensionsPendingForSync(profile);
}
syncer::StringOrdinal GetPageOrdinalForApp(Profile* profile,
diff --git a/chrome/browser/sync/test/integration/apps_helper.h b/chrome/browser/sync/test/integration/apps_helper.h
index bd6a968..70d3ec4 100644
--- a/chrome/browser/sync/test/integration/apps_helper.h
+++ b/chrome/browser/sync/test/integration/apps_helper.h
@@ -14,17 +14,23 @@ class Profile;
namespace apps_helper {
-// Returns true iff the profile with index |index| has the same apps as the
-// verifier.
+// Returns true iff the profile with index |index| has the same apps (hosted,
+// legacy packaged and platform) as the verifier.
bool HasSameAppsAsVerifier(int index) WARN_UNUSED_RESULT;
-// Returns true iff all existing profiles have the same apps as the verifier.
+// Returns true iff all existing profiles have the same apps (hosted,
+// legacy packaged and platform) as the verifier.
bool AllProfilesHaveSameAppsAsVerifier() WARN_UNUSED_RESULT;
// Installs the app for the given index to |profile|, and returns the extension
// ID of the new app.
std::string InstallApp(Profile* profile, int index);
+// Installs the platform app for the given index to |profile|, and returns the
+// extension ID of the new app. Indices passed to this method should be distinct
+// from indices passed to InstallApp.
+std::string InstallPlatformApp(Profile* profile, int index);
+
// Installs the app for the given index to all profiles (including the
// verifier), and returns the extension ID of the new app.
std::string InstallAppForAllProfiles(int index);
@@ -39,7 +45,7 @@ void InstallAppsPendingForSync(Profile* profile);
// Enables the app for the given index on |profile|.
void EnableApp(Profile* profile, int index);
-// Disables the appfor the given index on |profile|.
+// Disables the app for the given index on |profile|.
void DisableApp(Profile* profile, int index);
// Enables the app for the given index in incognito mode on |profile|.
diff --git a/chrome/browser/sync/test/integration/extensions_helper.cc b/chrome/browser/sync/test/integration/extensions_helper.cc
index 66fd789..c6a91c4 100644
--- a/chrome/browser/sync/test/integration/extensions_helper.cc
+++ b/chrome/browser/sync/test/integration/extensions_helper.cc
@@ -112,8 +112,7 @@ bool IsIncognitoEnabled(Profile* profile, int index) {
}
void InstallExtensionsPendingForSync(Profile* profile) {
- SyncExtensionHelper::GetInstance()->InstallExtensionsPendingForSync(
- profile, extensions::Extension::TYPE_EXTENSION);
+ SyncExtensionHelper::GetInstance()->InstallExtensionsPendingForSync(profile);
}
std::string CreateFakeExtensionName(int index) {
diff --git a/chrome/browser/sync/test/integration/single_client_apps_sync_test.cc b/chrome/browser/sync/test/integration/single_client_apps_sync_test.cc
index cff03fa..320b4a2 100644
--- a/chrome/browser/sync/test/integration/single_client_apps_sync_test.cc
+++ b/chrome/browser/sync/test/integration/single_client_apps_sync_test.cc
@@ -9,6 +9,7 @@
using apps_helper::AllProfilesHaveSameAppsAsVerifier;
using apps_helper::InstallApp;
+using apps_helper::InstallPlatformApp;
class SingleClientAppsSyncTest : public SyncTest {
public:
@@ -26,7 +27,7 @@ IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, StartWithNoApps) {
ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
}
-IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, StartWithSomeApps) {
+IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, StartWithSomeLegacyApps) {
ASSERT_TRUE(SetupClients());
const int kNumApps = 5;
@@ -40,7 +41,21 @@ IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, StartWithSomeApps) {
ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
}
-IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, InstallSomeApps) {
+IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, StartWithSomePlatformApps) {
+ ASSERT_TRUE(SetupClients());
+
+ const int kNumApps = 5;
+ for (int i = 0; i < kNumApps; ++i) {
+ InstallPlatformApp(GetProfile(0), i);
+ InstallPlatformApp(verifier(), i);
+ }
+
+ ASSERT_TRUE(SetupSync());
+
+ ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
+}
+
+IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, InstallSomeLegacyApps) {
ASSERT_TRUE(SetupSync());
const int kNumApps = 5;
@@ -54,3 +69,41 @@ IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, InstallSomeApps) {
ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
}
+
+IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, InstallSomePlatformApps) {
+ ASSERT_TRUE(SetupSync());
+
+ const int kNumApps = 5;
+ for (int i = 0; i < kNumApps; ++i) {
+ InstallPlatformApp(GetProfile(0), i);
+ InstallPlatformApp(verifier(), i);
+ }
+
+ ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion(
+ "Waiting for app changes."));
+
+ ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
+}
+
+IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, InstallSomeApps) {
+ ASSERT_TRUE(SetupSync());
+
+ int i = 0;
+
+ const int kNumApps = 5;
+ for (int j = 0; j < kNumApps; ++i, ++j) {
+ InstallApp(GetProfile(0), i);
+ InstallApp(verifier(), i);
+ }
+
+ const int kNumPlatformApps = 5;
+ for (int j = 0; j < kNumPlatformApps; ++i, ++j) {
+ InstallPlatformApp(GetProfile(0), i);
+ InstallPlatformApp(verifier(), i);
+ }
+
+ ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion(
+ "Waiting for app changes."));
+
+ ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
+}
diff --git a/chrome/browser/sync/test/integration/sync_extension_helper.cc b/chrome/browser/sync/test/integration/sync_extension_helper.cc
index a4ce607..1b0143a 100644
--- a/chrome/browser/sync/test/integration/sync_extension_helper.cc
+++ b/chrome/browser/sync/test/integration/sync_extension_helper.cc
@@ -140,8 +140,7 @@ bool SyncExtensionHelper::IsExtensionPendingInstallForSync(
return info->is_from_sync();
}
-void SyncExtensionHelper::InstallExtensionsPendingForSync(
- Profile* profile, Extension::Type type) {
+void SyncExtensionHelper::InstallExtensionsPendingForSync(Profile* profile) {
// TODO(akalin): Mock out the servers that the extensions auto-update
// mechanism talk to so as to more closely match what actually happens.
// Background networking will need to be re-enabled for extensions tests.
@@ -167,7 +166,12 @@ void SyncExtensionHelper::InstallExtensionsPendingForSync(
<< " (profile = " << profile->GetDebugName() << ")";
continue;
}
- InstallExtension(profile, iter2->second, type);
+ TypeMap::const_iterator iter3 = id_to_type_.find(*iter);
+ if (iter3 == id_to_type_.end()) {
+ ADD_FAILURE() << "Could not get type for id " << *iter
+ << " (profile = " << profile->GetDebugName() << ")";
+ }
+ InstallExtension(profile, iter2->second, iter3->second);
}
}
@@ -282,6 +286,16 @@ scoped_refptr<Extension> CreateExtension(
source.SetString(extension_manifest_keys::kLaunchWebURL,
"http://www.example.com");
break;
+ case Extension::TYPE_PLATFORM_APP: {
+ source.Set(extension_manifest_keys::kApp, new DictionaryValue());
+ source.Set(extension_manifest_keys::kPlatformAppBackground,
+ new DictionaryValue());
+ ListValue* scripts = new ListValue();
+ scripts->AppendString("main.js");
+ source.Set(extension_manifest_keys::kPlatformAppBackgroundScripts,
+ scripts);
+ break;
+ }
default:
ADD_FAILURE();
return NULL;
@@ -289,8 +303,11 @@ scoped_refptr<Extension> CreateExtension(
const FilePath sub_dir = FilePath().AppendASCII(name);
FilePath extension_dir;
if (!file_util::PathExists(base_dir) &&
- !file_util::CreateDirectory(base_dir) &&
- !file_util::CreateTemporaryDirInDir(
+ !file_util::CreateDirectory(base_dir)) {
+ ADD_FAILURE();
+ return NULL;
+ }
+ if (!file_util::CreateTemporaryDirInDir(
base_dir, sub_dir.value(), &extension_dir)) {
ADD_FAILURE();
return NULL;
@@ -353,5 +370,6 @@ scoped_refptr<Extension> SyncExtensionHelper::GetExtension(
<< name << ", id = " << expected_id;
(it->second)[name] = extension;
id_to_name_[expected_id] = name;
+ id_to_type_[expected_id] = type;
return extension;
}
diff --git a/chrome/browser/sync/test/integration/sync_extension_helper.h b/chrome/browser/sync/test/integration/sync_extension_helper.h
index f754de5..6cdca7d 100644
--- a/chrome/browser/sync/test/integration/sync_extension_helper.h
+++ b/chrome/browser/sync/test/integration/sync_extension_helper.h
@@ -72,8 +72,7 @@ class SyncExtensionHelper {
// Installs all extensions pending sync in |profile| of the given
// type.
- void InstallExtensionsPendingForSync(Profile* profile,
- extensions::Extension::Type type);
+ void InstallExtensionsPendingForSync(Profile* profile);
// Returns true iff |profile1| and |profile2| have the same extensions and
// they are all in the same state.
@@ -96,6 +95,7 @@ class SyncExtensionHelper {
ExtensionNameMap;
typedef std::map<Profile*, ExtensionNameMap> ProfileExtensionNameMap;
typedef std::map<std::string, std::string> StringMap;
+ typedef std::map<std::string, extensions::Extension::Type> TypeMap;
friend struct DefaultSingletonTraits<SyncExtensionHelper>;
@@ -118,6 +118,7 @@ class SyncExtensionHelper {
ProfileExtensionNameMap profile_extensions_;
StringMap id_to_name_;
+ TypeMap id_to_type_;
bool setup_completed_;
DISALLOW_COPY_AND_ASSIGN(SyncExtensionHelper);
diff --git a/chrome/browser/sync/test/integration/sync_test.cc b/chrome/browser/sync/test/integration/sync_test.cc
index d64411c..911d580 100644
--- a/chrome/browser/sync/test/integration/sync_test.cc
+++ b/chrome/browser/sync/test/integration/sync_test.cc
@@ -360,6 +360,9 @@ bool SyncTest::SetupSync() {
}
void SyncTest::CleanUpOnMainThread() {
+ // Some of the pending messages might rely on browser windows still being
+ // around, so run messages both before and after closing all browsers.
+ content::RunAllPendingInMessageLoop();
// Close all browser windows.
browser::CloseAllBrowsers();
content::RunAllPendingInMessageLoop();
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 d20443b..782a635 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
@@ -23,6 +23,7 @@ using apps_helper::IncognitoDisableApp;
using apps_helper::IncognitoEnableApp;
using apps_helper::InstallApp;
using apps_helper::InstallAppsPendingForSync;
+using apps_helper::InstallPlatformApp;
using apps_helper::SetAppLaunchOrdinalForApp;
using apps_helper::SetPageOrdinalForApp;
using apps_helper::UninstallApp;
@@ -89,6 +90,13 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, StartWithDifferentApps) {
CopyNTPOrdinals(GetProfile(1), verifier(), i);
}
+ const int kNumPlatformApps = 5;
+ for (int j = 0; j < kNumPlatformApps; ++i, ++j) {
+ InstallPlatformApp(GetProfile(1), i);
+ InstallPlatformApp(verifier(), i);
+ CopyNTPOrdinals(GetProfile(1), verifier(), i);
+ }
+
FixNTPOrdinalCollisions(verifier());
ASSERT_TRUE(SetupSync());
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index b7eb089..2ed5e3d 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -3858,6 +3858,7 @@ Extension::SyncType Extension::GetSyncType() const {
case Extension::TYPE_HOSTED_APP:
case Extension::TYPE_LEGACY_PACKAGED_APP:
+ case Extension::TYPE_PLATFORM_APP:
return SYNC_TYPE_APP;
default: