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

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

Issue 17038002: Separate the NTP app ordering from the app list app ordering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert lazy initialzation Created 7 years, 3 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 4ccc3c1e49b128319050d3606c38378a6f26b594..8382d57695d8f77c58d24550fcb94d05c4da3021 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -1239,7 +1239,6 @@ TEST_F(ExtensionServiceTest, LoadAllExtensionsFromDirectorySuccess) {
EXPECT_TRUE(service_->GetExtensionById(loaded_[0]->id(), false));
EXPECT_EQ(expected_num_extensions, service_->extensions()->size());
- ValidatePrefKeyCount(3);
ValidateIntegerPref(good0, "state", Extension::ENABLED);
ValidateIntegerPref(good0, "location", Manifest::INTERNAL);
ValidateIntegerPref(good1, "state", Extension::ENABLED);
@@ -1550,6 +1549,7 @@ TEST_F(ExtensionServiceTest, PendingImports) {
// them, throw away the key used and change the id's above.
TEST_F(ExtensionServiceTest, InstallExtension) {
InitializeEmptyExtensionService();
+ int pref_count = GetPrefKeyCount();
// Extensions not enabled.
set_extensions_enabled(false);
@@ -1557,14 +1557,13 @@ TEST_F(ExtensionServiceTest, InstallExtension) {
InstallCRX(path, INSTALL_FAILED);
set_extensions_enabled(true);
- ValidatePrefKeyCount(0);
+ ValidatePrefKeyCount(pref_count);
// A simple extension that should install without error.
path = data_dir_.AppendASCII("good.crx");
InstallCRX(path, INSTALL_NEW);
// TODO(erikkay): verify the contents of the installed extension.
- int pref_count = 0;
ValidatePrefKeyCount(++pref_count);
ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL);
@@ -1637,7 +1636,7 @@ struct MockInstallObserver : public extensions::InstallObserver {
last_extension_uninstalled = extension->id();
}
- virtual void OnAppsReordered() OVERRIDE {
+ virtual void OnAppListReordered() OVERRIDE {
}
virtual void OnAppInstalledToAppList(
@@ -2348,11 +2347,11 @@ TEST_F(ExtensionServiceTest, PackExtensionOpenSSLKey) {
TEST_F(ExtensionServiceTest, InstallTheme) {
InitializeEmptyExtensionService();
service_->Init();
+ int pref_count = GetPrefKeyCount();
// A theme.
base::FilePath path = data_dir_.AppendASCII("theme.crx");
InstallCRX(path, INSTALL_NEW);
- int pref_count = 0;
ValidatePrefKeyCount(++pref_count);
ValidateIntegerPref(theme_crx, "state", Extension::ENABLED);
ValidateIntegerPref(theme_crx, "location", Manifest::INTERNAL);
@@ -2516,11 +2515,11 @@ TEST_F(ExtensionServiceTest, InstallLocalizedTheme) {
TEST_F(ExtensionServiceTest, InstallApps) {
InitializeEmptyExtensionService();
+ int pref_count = GetPrefKeyCount();
// An empty app.
const Extension* app = PackAndInstallCRX(data_dir_.AppendASCII("app1"),
INSTALL_NEW);
- int pref_count = 0;
ValidatePrefKeyCount(++pref_count);
ASSERT_EQ(1u, service_->extensions()->size());
ValidateIntegerPref(app->id(), "state", Extension::ENABLED);
@@ -2617,7 +2616,7 @@ TEST_F(ExtensionServiceTest, InstallAppsWithUnlimitedStorage) {
InitializeEmptyExtensionService();
EXPECT_TRUE(service_->extensions()->is_empty());
- int pref_count = 0;
+ int pref_count = GetPrefKeyCount();
// Install app1 with unlimited storage.
const Extension* extension =
@@ -2668,7 +2667,7 @@ TEST_F(ExtensionServiceTest, InstallAppsAndCheckStorageProtection) {
InitializeEmptyExtensionService();
EXPECT_TRUE(service_->extensions()->is_empty());
- int pref_count = 0;
+ int pref_count = GetPrefKeyCount();
const Extension* extension =
PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW);
@@ -2707,19 +2706,20 @@ TEST_F(ExtensionServiceTest, InstallAppsAndCheckStorageProtection) {
// Test that when an extension version is reinstalled, nothing happens.
TEST_F(ExtensionServiceTest, Reinstall) {
InitializeEmptyExtensionService();
+ int pref_count = GetPrefKeyCount();
// A simple extension that should install without error.
base::FilePath path = data_dir_.AppendASCII("good.crx");
InstallCRX(path, INSTALL_NEW);
- ValidatePrefKeyCount(1);
+ ValidatePrefKeyCount(++pref_count);
ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL);
// Reinstall the same version, it should overwrite the previous one.
InstallCRX(path, INSTALL_UPDATED);
- ValidatePrefKeyCount(1);
+ ValidatePrefKeyCount(pref_count);
ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL);
}
@@ -2728,6 +2728,7 @@ TEST_F(ExtensionServiceTest, Reinstall) {
// Chrome web store.
TEST_F(ExtensionServiceTest, FromWebStore) {
InitializeEmptyExtensionService();
+ int pref_count = GetPrefKeyCount();
// A simple extension that should install without error.
base::FilePath path = data_dir_.AppendASCII("good.crx");
@@ -2735,14 +2736,14 @@ TEST_F(ExtensionServiceTest, FromWebStore) {
const Extension* extension = InstallCRX(path, INSTALL_NEW);
std::string id = extension->id();
- ValidatePrefKeyCount(1);
+ ValidatePrefKeyCount(++pref_count);
ValidateBooleanPref(good_crx, "from_webstore", false);
ASSERT_FALSE(extension->from_webstore());
// Test install from web store.
InstallCRXFromWebStore(path, INSTALL_UPDATED); // From web store.
- ValidatePrefKeyCount(1);
+ ValidatePrefKeyCount(pref_count);
ValidateBooleanPref(good_crx, "from_webstore", true);
// Reload so extension gets reinitialized with new value.
@@ -2753,7 +2754,7 @@ TEST_F(ExtensionServiceTest, FromWebStore) {
// Upgrade to version 2.0
path = data_dir_.AppendASCII("good2.crx");
UpdateExtension(good_crx, path, ENABLED);
- ValidatePrefKeyCount(1);
+ ValidatePrefKeyCount(pref_count);
ValidateBooleanPref(good_crx, "from_webstore", true);
}
@@ -4190,9 +4191,9 @@ TEST_F(ExtensionServiceTest, ClearExtensionData) {
// Verifies app state is removed upon uninstall.
TEST_F(ExtensionServiceTest, ClearAppData) {
InitializeEmptyExtensionService();
- ExtensionCookieCallback callback;
+ int pref_count = GetPrefKeyCount();
- int pref_count = 0;
+ ExtensionCookieCallback callback;
// Install app1 with unlimited storage.
const Extension* extension =
@@ -4324,6 +4325,7 @@ TEST_F(ExtensionServiceTest, ClearAppData) {
// Flaky crashes. http://crbug.com/231806
TEST_F(ExtensionServiceTest, DISABLED_LoadExtension) {
InitializeEmptyExtensionService();
+ int pref_count = GetPrefKeyCount();
koz (OOO until 15th September) 2013/09/04 00:26:05 nit: here and elsewhere this would be better named
base::FilePath ext1 = data_dir_
.AppendASCII("good")
@@ -4337,7 +4339,7 @@ TEST_F(ExtensionServiceTest, DISABLED_LoadExtension) {
EXPECT_EQ(Manifest::UNPACKED, loaded_[0]->location());
EXPECT_EQ(1u, service_->extensions()->size());
- ValidatePrefKeyCount(1);
+ ValidatePrefKeyCount(++pref_count);
base::FilePath no_manifest = data_dir_
.AppendASCII("bad")
@@ -4364,6 +4366,7 @@ TEST_F(ExtensionServiceTest, DISABLED_LoadExtension) {
// --load-extension.
TEST_F(ExtensionServiceTest, GenerateID) {
InitializeEmptyExtensionService();
+ int pref_count = GetPrefKeyCount();
base::FilePath no_id_ext = data_dir_.AppendASCII("no_id");
extensions::UnpackedInstaller::Create(service_)->Load(no_id_ext);
@@ -4373,7 +4376,7 @@ TEST_F(ExtensionServiceTest, GenerateID) {
ASSERT_TRUE(Extension::IdIsValid(loaded_[0]->id()));
EXPECT_EQ(loaded_[0]->location(), Manifest::UNPACKED);
- ValidatePrefKeyCount(1);
+ ValidatePrefKeyCount(++pref_count);
std::string previous_id = loaded_[0]->id();
@@ -4390,6 +4393,8 @@ void ExtensionServiceTest::TestExternalProvider(
service_->Init();
ASSERT_EQ(0u, loaded_.size());
+ int pref_count = GetPrefKeyCount();
+
provider->set_visit_count(0);
// Register a test extension externally using the mock registry provider.
@@ -4409,7 +4414,7 @@ void ExtensionServiceTest::TestExternalProvider(
ASSERT_EQ(1u, loaded_.size());
ASSERT_EQ(location, loaded_[0]->location());
ASSERT_EQ("1.0.0.0", loaded_[0]->version()->GetString());
- ValidatePrefKeyCount(1);
+ ValidatePrefKeyCount(++pref_count);
ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
ValidateIntegerPref(good_crx, "location", location);
@@ -4420,7 +4425,7 @@ void ExtensionServiceTest::TestExternalProvider(
base::RunLoop().RunUntilIdle();
ASSERT_EQ(0u, GetErrors().size());
ASSERT_EQ(1u, loaded_.size());
- ValidatePrefKeyCount(1);
+ ValidatePrefKeyCount(pref_count);
ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
ValidateIntegerPref(good_crx, "location", location);
@@ -4436,7 +4441,7 @@ void ExtensionServiceTest::TestExternalProvider(
ASSERT_EQ(0u, GetErrors().size());
ASSERT_EQ(1u, loaded_.size());
ASSERT_EQ("1.0.0.1", loaded_[0]->version()->GetString());
- ValidatePrefKeyCount(1);
+ ValidatePrefKeyCount(pref_count);
ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
ValidateIntegerPref(good_crx, "location", location);
@@ -4459,7 +4464,7 @@ void ExtensionServiceTest::TestExternalProvider(
service_->CheckForExternalUpdates();
base::RunLoop().RunUntilIdle();
ASSERT_EQ(0u, loaded_.size());
- ValidatePrefKeyCount(1);
+ ValidatePrefKeyCount(pref_count);
ValidateIntegerPref(good_crx, "state",
Extension::EXTERNAL_EXTENSION_UNINSTALLED);
ValidateIntegerPref(good_crx, "location", location);
@@ -4474,7 +4479,7 @@ void ExtensionServiceTest::TestExternalProvider(
content::NotificationService::AllSources()).Wait();
ASSERT_EQ(1u, loaded_.size());
}
- ValidatePrefKeyCount(1);
+ ValidatePrefKeyCount(pref_count);
ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
ValidateIntegerPref(good_crx, "location", location);
@@ -4489,7 +4494,7 @@ void ExtensionServiceTest::TestExternalProvider(
service_->OnExternalProviderReady(provider);
base::RunLoop().RunUntilIdle();
ASSERT_EQ(0u, loaded_.size());
- ValidatePrefKeyCount(0);
+ ValidatePrefKeyCount(--pref_count);
// The extension should also be gone from the install directory.
ASSERT_FALSE(base::PathExists(install_path));
@@ -4519,7 +4524,7 @@ void ExtensionServiceTest::TestExternalProvider(
extensions::InstalledLoader(service_).LoadAllExtensions();
base::RunLoop().RunUntilIdle();
ASSERT_EQ(0u, loaded_.size());
- ValidatePrefKeyCount(1);
+ ValidatePrefKeyCount(++pref_count);
EXPECT_EQ(5, provider->visit_count());
}
@@ -4622,6 +4627,7 @@ TEST_F(ExtensionServiceTest, ExternalUninstall) {
// keep the update from succeeding.
TEST_F(ExtensionServiceTest, MultipleExternalUpdateCheck) {
InitializeEmptyExtensionService();
+ int pref_count = GetPrefKeyCount();
MockExtensionProvider* provider =
new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF);
@@ -4659,7 +4665,7 @@ TEST_F(ExtensionServiceTest, MultipleExternalUpdateCheck) {
ASSERT_EQ(1u, loaded_.size());
ASSERT_EQ(Manifest::EXTERNAL_PREF, loaded_[0]->location());
ASSERT_EQ("1.0.0.0", loaded_[0]->version()->GetString());
- ValidatePrefKeyCount(1);
+ ValidatePrefKeyCount(++pref_count);
ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
ValidateIntegerPref(good_crx, "location", Manifest::EXTERNAL_PREF);
@@ -5039,6 +5045,7 @@ TEST_F(ExtensionServiceTest, StorageQuota) {
// Tests ComponentLoader::Add().
TEST_F(ExtensionServiceTest, ComponentExtensions) {
InitializeEmptyExtensionService();
+ int pref_count = GetPrefKeyCount();
// Component extensions should work even when extensions are disabled.
set_extensions_enabled(false);
@@ -5065,7 +5072,7 @@ TEST_F(ExtensionServiceTest, ComponentExtensions) {
EXPECT_EQ(1u, service_->extensions()->size());
// Component extensions get a prefs entry on first install.
- ValidatePrefKeyCount(1);
+ ValidatePrefKeyCount(++pref_count);
// Reload all extensions, and make sure it comes back.
std::string extension_id = (*service_->extensions()->begin())->id();
@@ -5735,10 +5742,11 @@ TEST_F(ExtensionServiceTest, ProcessSyncDataNotInstalled) {
TEST_F(ExtensionServiceTest, InstallPriorityExternalUpdateUrl) {
InitializeEmptyExtensionService();
+ int pref_count = GetPrefKeyCount();
base::FilePath path = data_dir_.AppendASCII("good.crx");
InstallCRX(path, INSTALL_NEW);
- ValidatePrefKeyCount(1u);
+ ValidatePrefKeyCount(++pref_count);
ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL);
@@ -5788,6 +5796,7 @@ TEST_F(ExtensionServiceTest, InstallPriorityExternalLocalFile) {
const bool kDontMarkAcknowledged = false;
InitializeEmptyExtensionService();
+ int pref_count = GetPrefKeyCount();
// The test below uses install source constants to test that
// priority is enforced. It assumes a specific ranking of install
@@ -5866,7 +5875,7 @@ TEST_F(ExtensionServiceTest, InstallPriorityExternalLocalFile) {
// Install the extension.
base::FilePath path = data_dir_.AppendASCII("good.crx");
const Extension* ext = InstallCRX(path, INSTALL_NEW);
- ValidatePrefKeyCount(1u);
+ ValidatePrefKeyCount(++pref_count);
ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL);

Powered by Google App Engine
This is Rietveld 408576698