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

Unified Diff: chrome/browser/profile_resetter/profile_resetter_unittest.cc

Issue 21779002: Don't disable packaged / hosted Apps on profile_reset (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit Created 7 years, 5 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/profile_resetter/profile_resetter_unittest.cc
diff --git a/chrome/browser/profile_resetter/profile_resetter_unittest.cc b/chrome/browser/profile_resetter/profile_resetter_unittest.cc
index b427be9c0dce3376fc277e9ee83f1d2225257fc5..f11ff26a9f309850e320fc52e89e883559d2110f 100644
--- a/chrome/browser/profile_resetter/profile_resetter_unittest.cc
+++ b/chrome/browser/profile_resetter/profile_resetter_unittest.cc
@@ -228,13 +228,23 @@ scoped_ptr<net::FakeURLFetcher> ConfigParserTest::CreateFakeURLFetcher(
scoped_refptr<Extension> CreateExtension(const std::string& name,
const base::FilePath& path,
Manifest::Location location,
- bool theme) {
+ extensions::Manifest::Type type) {
DictionaryValue manifest;
manifest.SetString(extension_manifest_keys::kVersion, "1.0.0.0");
manifest.SetString(extension_manifest_keys::kName, name);
- manifest.SetString("app.launch.web_url", "http://www.google.com");
- if (theme)
- manifest.Set(extension_manifest_keys::kTheme, new DictionaryValue);
+ switch (type) {
+ case extensions::Manifest::TYPE_THEME:
+ manifest.Set(extension_manifest_keys::kTheme, new DictionaryValue);
+ break;
+ case extensions::Manifest::TYPE_HOSTED_APP:
+ manifest.SetString("app.launch.web_url", "http://www.google.com");
+ break;
+ case extensions::Manifest::TYPE_EXTENSION:
+ // do nothing
+ break;
+ default:
+ NOTREACHED();
+ }
manifest.SetString(extension_manifest_keys::kOmniboxKeyword, name);
std::string error;
scoped_refptr<Extension> extension = Extension::Create(
@@ -270,7 +280,7 @@ TEST_F(ProfileResetterTest, ResetDefaultSearchEngine) {
"xxx",
base::FilePath(FILE_PATH_LITERAL("//nonexistent")),
Manifest::COMPONENT,
- false);
+ extensions::Manifest::TYPE_EXTENSION);
service_->AddExtension(extension.get());
ResetAndWait(ProfileResetter::DEFAULT_SEARCH_ENGINE);
@@ -432,9 +442,11 @@ TEST_F(ProfileResetterTest, ResetExtensionsByDisabling) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- scoped_refptr<Extension> theme = CreateExtension("example1", temp_dir.path(),
- Manifest::INVALID_LOCATION,
- true);
+ scoped_refptr<Extension> theme =
+ CreateExtension("example1",
+ temp_dir.path(),
+ Manifest::INVALID_LOCATION,
+ extensions::Manifest::TYPE_THEME);
service_->FinishInstallationForTest(theme.get());
// Let ThemeService finish creating the theme pack.
base::MessageLoop::current()->RunUntilIdle();
@@ -448,26 +460,27 @@ TEST_F(ProfileResetterTest, ResetExtensionsByDisabling) {
"example2",
base::FilePath(FILE_PATH_LITERAL("//nonexistent")),
Manifest::INVALID_LOCATION,
- false);
+ extensions::Manifest::TYPE_EXTENSION);
service_->AddExtension(ext2.get());
// Components and external policy extensions shouldn't be deleted.
scoped_refptr<Extension> ext3 = CreateExtension(
"example3",
base::FilePath(FILE_PATH_LITERAL("//nonexistent2")),
Manifest::COMPONENT,
- false);
+ extensions::Manifest::TYPE_EXTENSION);
service_->AddExtension(ext3.get());
scoped_refptr<Extension> ext4 =
CreateExtension("example4",
base::FilePath(FILE_PATH_LITERAL("//nonexistent3")),
Manifest::EXTERNAL_POLICY_DOWNLOAD,
- false);
+ extensions::Manifest::TYPE_EXTENSION);
service_->AddExtension(ext4.get());
EXPECT_EQ(4u, service_->extensions()->size());
ResetAndWait(ProfileResetter::EXTENSIONS);
-
EXPECT_EQ(2u, service_->extensions()->size());
+ EXPECT_FALSE(service_->extensions()->Contains(theme->id()));
+ EXPECT_FALSE(service_->extensions()->Contains(ext2->id()));
EXPECT_TRUE(service_->extensions()->Contains(ext3->id()));
EXPECT_TRUE(service_->extensions()->Contains(ext4->id()));
EXPECT_TRUE(theme_service->UsingDefaultTheme());
@@ -478,14 +491,14 @@ TEST_F(ProfileResetterTest, ResetExtensionsByDisablingNonOrganic) {
"example2",
base::FilePath(FILE_PATH_LITERAL("//nonexistent")),
Manifest::INVALID_LOCATION,
- false);
+ extensions::Manifest::TYPE_EXTENSION);
service_->AddExtension(ext2.get());
// Components and external policy extensions shouldn't be deleted.
scoped_refptr<Extension> ext3 = CreateExtension(
"example3",
base::FilePath(FILE_PATH_LITERAL("//nonexistent2")),
Manifest::INVALID_LOCATION,
- false);
+ extensions::Manifest::TYPE_EXTENSION);
service_->AddExtension(ext3.get());
EXPECT_EQ(2u, service_->extensions()->size());
@@ -498,6 +511,48 @@ TEST_F(ProfileResetterTest, ResetExtensionsByDisablingNonOrganic) {
EXPECT_TRUE(service_->extensions()->Contains(ext3->id()));
}
+TEST_F(ProfileResetterTest, ResetExtensionsCheckTypeFilter) {
+ base::ScopedTempDir temp_dir;
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+
+ scoped_refptr<Extension> ext1 =
+ CreateExtension("example1",
+ temp_dir.path(),
+ Manifest::INVALID_LOCATION,
+ extensions::Manifest::TYPE_THEME);
+ service_->FinishInstallationForTest(ext1.get());
+ // Let ThemeService finish creating the theme pack.
+ base::MessageLoop::current()->RunUntilIdle();
+
+ // ThemeService isn't compiled for Android.
+ ThemeService* theme_service =
+ ThemeServiceFactory::GetForProfile(profile());
+ EXPECT_FALSE(theme_service->UsingDefaultTheme());
+
+ scoped_refptr<Extension> ext2 =
+ CreateExtension("example2",
+ base::FilePath(FILE_PATH_LITERAL("//nonexistent2")),
+ Manifest::INVALID_LOCATION,
+ extensions::Manifest::TYPE_EXTENSION);
+ service_->AddExtension(ext2.get());
+
+ scoped_refptr<Extension> ext3 =
+ CreateExtension("example2",
+ base::FilePath(FILE_PATH_LITERAL("//nonexistent3")),
+ Manifest::INVALID_LOCATION,
+ extensions::Manifest::TYPE_HOSTED_APP);
+ service_->AddExtension(ext3.get());
+ EXPECT_EQ(3u, service_->extensions()->size());
+
+ ResetAndWait(ProfileResetter::EXTENSIONS);
+
+ EXPECT_EQ(1u, service_->extensions()->size());
+ EXPECT_FALSE(service_->extensions()->Contains(ext1->id()));
+ EXPECT_FALSE(service_->extensions()->Contains(ext2->id()));
+ EXPECT_TRUE(service_->extensions()->Contains(ext3->id()));
+ EXPECT_TRUE(theme_service->UsingDefaultTheme());
+}
+
TEST_F(ProfileResetterTest, ResetStartPage) {
PrefService* prefs = profile()->GetPrefs();
DCHECK(prefs);
@@ -534,7 +589,7 @@ TEST_F(PinnedTabsResetTest, ResetPinnedTabs) {
"hello!",
base::FilePath(FILE_PATH_LITERAL("//nonexistent")),
Manifest::INVALID_LOCATION,
- false);
+ extensions::Manifest::TYPE_HOSTED_APP);
scoped_ptr<content::WebContents> contents1(CreateWebContents());
extensions::TabHelper::CreateForWebContents(contents1.get());
extensions::TabHelper::FromWebContents(contents1.get())->

Powered by Google App Engine
This is Rietveld 408576698