Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1320)

Unified Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 264763002: Support remote installation of extensions and apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_service_unittest.cc
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index bbbff27cd49548bf7c9fbfc000b7342a6c604ee7..88e5afa924597d563947f72a90cd9e4cc5997cb7 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -1269,7 +1269,7 @@ class ExtensionServiceTest
scoped_refptr<CrxInstaller> installer(CrxInstaller::CreateSilent(service_));
installer->set_creation_flags(creation_flags);
if (!(creation_flags & Extension::WAS_INSTALLED_BY_DEFAULT))
- installer->set_allow_silent_install(true);
+ installer->set_allow_silent_install(CrxInstaller::GRANT_SILENTLY);
content::WindowedNotificationObserver observer(
chrome::NOTIFICATION_CRX_INSTALLER_DONE,
@@ -1841,7 +1841,7 @@ TEST_F(ExtensionServiceTest, InstallUserScript) {
ASSERT_TRUE(base::PathExists(path));
scoped_refptr<CrxInstaller> installer(CrxInstaller::CreateSilent(service_));
- installer->set_allow_silent_install(true);
+ installer->set_allow_silent_install(CrxInstaller::GRANT_SILENTLY);
installer->InstallUserScript(
path,
GURL("http://www.aaronboodman.com/scripts/user_script_basic.user.js"));
@@ -1871,7 +1871,7 @@ TEST_F(ExtensionServiceTest, InstallExtensionDuringShutdown) {
base::FilePath path = data_dir_.AppendASCII("good.crx");
scoped_refptr<CrxInstaller> installer(CrxInstaller::CreateSilent(service_));
- installer->set_allow_silent_install(true);
+ installer->set_allow_silent_install(CrxInstaller::GRANT_SILENTLY);
installer->InstallCrx(path);
base::RunLoop().RunUntilIdle();
@@ -3021,10 +3021,14 @@ TEST_F(ExtensionServiceTest, AddPendingExtensionFromSync) {
const std::string kFakeId(all_zero);
const GURL kFakeUpdateURL("http:://fake.update/url");
const bool kFakeInstallSilently(true);
+ const bool kFakeRemoteInstall(false);
- EXPECT_TRUE(service_->pending_extension_manager()->AddFromSync(
- kFakeId, kFakeUpdateURL, &IsExtension,
- kFakeInstallSilently));
+ EXPECT_TRUE(
+ service_->pending_extension_manager()->AddFromSync(kFakeId,
+ kFakeUpdateURL,
+ &IsExtension,
+ kFakeInstallSilently,
+ kFakeRemoteInstall));
const extensions::PendingExtensionInfo* pending_extension_info;
ASSERT_TRUE((pending_extension_info = service_->pending_extension_manager()->
@@ -3032,6 +3036,7 @@ TEST_F(ExtensionServiceTest, AddPendingExtensionFromSync) {
EXPECT_EQ(kFakeUpdateURL, pending_extension_info->update_url());
EXPECT_EQ(&IsExtension, pending_extension_info->should_allow_install_);
EXPECT_EQ(kFakeInstallSilently, pending_extension_info->install_silently());
+ EXPECT_EQ(kFakeRemoteInstall, pending_extension_info->remote_install());
}
namespace {
@@ -3039,14 +3044,18 @@ const char kGoodId[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf";
const char kGoodUpdateURL[] = "http://good.update/url";
const bool kGoodIsFromSync = true;
const bool kGoodInstallSilently = true;
+const bool kGoodRemoteInstall = false;
} // namespace
// Test updating a pending extension.
TEST_F(ExtensionServiceTest, UpdatePendingExtension) {
InitializeEmptyExtensionService();
- EXPECT_TRUE(service_->pending_extension_manager()->AddFromSync(
- kGoodId, GURL(kGoodUpdateURL), &IsExtension,
- kGoodInstallSilently));
+ EXPECT_TRUE(
+ service_->pending_extension_manager()->AddFromSync(kGoodId,
+ GURL(kGoodUpdateURL),
+ &IsExtension,
+ kGoodInstallSilently,
+ kGoodRemoteInstall));
EXPECT_TRUE(service_->pending_extension_manager()->IsIdPending(kGoodId));
base::FilePath path = data_dir_.AppendASCII("good.crx");
@@ -3071,7 +3080,7 @@ bool IsTheme(const Extension* extension) {
TEST_F(ExtensionServiceTest, DISABLED_UpdatePendingTheme) {
InitializeEmptyExtensionService();
EXPECT_TRUE(service_->pending_extension_manager()->AddFromSync(
- theme_crx, GURL(), &IsTheme, false));
+ theme_crx, GURL(), &IsTheme, false, false));
EXPECT_TRUE(service_->pending_extension_manager()->IsIdPending(theme_crx));
base::FilePath path = data_dir_.AppendASCII("theme.crx");
@@ -3130,9 +3139,12 @@ TEST_F(ExtensionServiceTest, UpdatePendingExternalCrxWinsOverSync) {
InitializeEmptyExtensionService();
// Add a crx to be installed from the update mechanism.
- EXPECT_TRUE(service_->pending_extension_manager()->AddFromSync(
- kGoodId, GURL(kGoodUpdateURL), &IsExtension,
- kGoodInstallSilently));
+ EXPECT_TRUE(
+ service_->pending_extension_manager()->AddFromSync(kGoodId,
+ GURL(kGoodUpdateURL),
+ &IsExtension,
+ kGoodInstallSilently,
+ kGoodRemoteInstall));
// Check that there is a pending crx, with is_from_sync set to true.
const extensions::PendingExtensionInfo* pending_extension_info;
@@ -3157,9 +3169,12 @@ TEST_F(ExtensionServiceTest, UpdatePendingExternalCrxWinsOverSync) {
pending_extension_info->install_source());
// Add a crx to be installed from the update mechanism.
- EXPECT_FALSE(service_->pending_extension_manager()->AddFromSync(
- kGoodId, GURL(kGoodUpdateURL), &IsExtension,
- kGoodInstallSilently));
+ EXPECT_FALSE(
+ service_->pending_extension_manager()->AddFromSync(kGoodId,
+ GURL(kGoodUpdateURL),
+ &IsExtension,
+ kGoodInstallSilently,
+ kGoodRemoteInstall));
// Check that the external, non-sync update was not overridden.
ASSERT_TRUE((pending_extension_info = service_->pending_extension_manager()->
@@ -3174,7 +3189,7 @@ TEST_F(ExtensionServiceTest, UpdatePendingExternalCrxWinsOverSync) {
TEST_F(ExtensionServiceTest, UpdatePendingCrxThemeMismatch) {
InitializeEmptyExtensionService();
EXPECT_TRUE(service_->pending_extension_manager()->AddFromSync(
- theme_crx, GURL(), &IsExtension, true));
+ theme_crx, GURL(), &IsExtension, true, false));
EXPECT_TRUE(service_->pending_extension_manager()->IsIdPending(theme_crx));
@@ -3195,8 +3210,12 @@ TEST_F(ExtensionServiceTest, UpdatePendingCrxThemeMismatch) {
TEST_F(ExtensionServiceTest, UpdatePendingExtensionFailedShouldInstallTest) {
InitializeEmptyExtensionService();
// Add pending extension with a flipped is_theme.
- EXPECT_TRUE(service_->pending_extension_manager()->AddFromSync(
- kGoodId, GURL(kGoodUpdateURL), &IsTheme, kGoodInstallSilently));
+ EXPECT_TRUE(
+ service_->pending_extension_manager()->AddFromSync(kGoodId,
+ GURL(kGoodUpdateURL),
+ &IsTheme,
+ kGoodInstallSilently,
+ kGoodRemoteInstall));
EXPECT_TRUE(service_->pending_extension_manager()->IsIdPending(kGoodId));
base::FilePath path = data_dir_.AppendASCII("good.crx");
@@ -3243,7 +3262,8 @@ TEST_F(ExtensionServiceTest, UpdatePendingExtensionAlreadyInstalled) {
kGoodInstallSilently,
Manifest::INTERNAL,
Extension::NO_FLAGS,
- false);
+ false,
+ kGoodRemoteInstall);
UpdateExtension(good->id(), path, ENABLED);
EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(kGoodId));
@@ -5451,7 +5471,8 @@ TEST_F(ExtensionServiceTest, DisableExtensionFromSync) {
const Extension* extension = service_->GetExtensionById(good0, true);
ASSERT_TRUE(extension);
ASSERT_TRUE(service_->IsExtensionEnabled(good0));
- extensions::ExtensionSyncData disable_good_crx(*extension, false, false);
+ extensions::ExtensionSyncData disable_good_crx(
+ *extension, false, false, false);
// Then sync data arrives telling us to disable |good0|.
syncer::SyncDataList sync_data;
@@ -5498,7 +5519,8 @@ TEST_F(ExtensionServiceTest, DontDisableExtensionWithPendingEnableFromSync) {
// Now sync data comes in that says to disable good0. This should be
// ignored.
- extensions::ExtensionSyncData disable_good_crx(*extension, false, false);
+ extensions::ExtensionSyncData disable_good_crx(
+ *extension, false, false, false);
syncer::SyncDataList sync_data;
sync_data.push_back(disable_good_crx.GetSyncData());
extension_sync_service_->MergeDataAndStartSyncing(
@@ -6498,7 +6520,11 @@ class ExtensionSourcePriorityTest : public ExtensionServiceTest {
// Fake a request from sync to install an extension.
bool AddPendingSyncInstall() {
return service_->pending_extension_manager()->AddFromSync(
- crx_id_, GURL(kGoodUpdateURL), &IsExtension, kGoodInstallSilently);
+ crx_id_,
+ GURL(kGoodUpdateURL),
+ &IsExtension,
+ kGoodInstallSilently,
+ kGoodRemoteInstall);
}
// Fake a policy install.

Powered by Google App Engine
This is Rietveld 408576698