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

Side by Side Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 19462009: [DRAFT] Allow a user to revert to their previous theme without closing infobar (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/extension_service_unittest.h" 5 #include "chrome/browser/extensions/extension_service_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 << path.value(); 830 << path.value();
831 // If INSTALL_UPDATED, old_name_ should match the given string. 831 // If INSTALL_UPDATED, old_name_ should match the given string.
832 if (install_state == INSTALL_UPDATED && !expected_old_name.empty()) 832 if (install_state == INSTALL_UPDATED && !expected_old_name.empty())
833 EXPECT_EQ(expected_old_name, old_name_); 833 EXPECT_EQ(expected_old_name, old_name_);
834 EXPECT_EQ(0u, errors.size()) << path.value(); 834 EXPECT_EQ(0u, errors.size()) << path.value();
835 835
836 if (install_state == INSTALL_WITHOUT_LOAD) { 836 if (install_state == INSTALL_WITHOUT_LOAD) {
837 EXPECT_EQ(0u, loaded_.size()) << path.value(); 837 EXPECT_EQ(0u, loaded_.size()) << path.value();
838 } else { 838 } else {
839 EXPECT_EQ(1u, loaded_.size()) << path.value(); 839 EXPECT_EQ(1u, loaded_.size()) << path.value();
840 EXPECT_EQ(expected_extensions_count_, service_->extensions()->size()) << 840 size_t actual_extension_count = service_->extensions()->size() +
841 service_->disabled_extensions()->size();
842 EXPECT_EQ(expected_extensions_count_, actual_extension_count) <<
841 path.value(); 843 path.value();
842 extension = loaded_[0].get(); 844 extension = loaded_[0].get();
843 EXPECT_TRUE(service_->GetExtensionById(extension->id(), false)) 845 EXPECT_TRUE(service_->GetExtensionById(extension->id(), false))
844 << path.value(); 846 << path.value();
845 } 847 }
846 848
847 for (std::vector<string16>::iterator err = errors.begin(); 849 for (std::vector<string16>::iterator err = errors.begin();
848 err != errors.end(); ++err) { 850 err != errors.end(); ++err) {
849 LOG(ERROR) << *err; 851 LOG(ERROR) << *err;
850 } 852 }
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after
2350 2352
2351 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator()); 2353 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator());
2352 ASSERT_TRUE(creator->Run(input_directory, crx_path, privkey_path, 2354 ASSERT_TRUE(creator->Run(input_directory, crx_path, privkey_path,
2353 base::FilePath(), ExtensionCreator::kOverwriteCRX)); 2355 base::FilePath(), ExtensionCreator::kOverwriteCRX));
2354 2356
2355 InstallCRX(crx_path, INSTALL_NEW); 2357 InstallCRX(crx_path, INSTALL_NEW);
2356 } 2358 }
2357 2359
2358 TEST_F(ExtensionServiceTest, InstallTheme) { 2360 TEST_F(ExtensionServiceTest, InstallTheme) {
2359 InitializeEmptyExtensionService(); 2361 InitializeEmptyExtensionService();
2362 service_->Init();
2360 2363
2361 // A theme. 2364 // A theme.
2362 base::FilePath path = data_dir_.AppendASCII("theme.crx"); 2365 base::FilePath path = data_dir_.AppendASCII("theme.crx");
2363 InstallCRX(path, INSTALL_NEW); 2366 InstallCRX(path, INSTALL_NEW);
2364 int pref_count = 0; 2367 int pref_count = 0;
2365 ValidatePrefKeyCount(++pref_count); 2368 ValidatePrefKeyCount(++pref_count);
2366 ValidateIntegerPref(theme_crx, "state", Extension::ENABLED); 2369 ValidateIntegerPref(theme_crx, "state", Extension::ENABLED);
2367 ValidateIntegerPref(theme_crx, "location", Manifest::INTERNAL); 2370 ValidateIntegerPref(theme_crx, "location", Manifest::INTERNAL);
2368 2371
2369 // A theme when extensions are disabled. Themes can be installed, even when 2372 // A theme when extensions are disabled. Themes can be installed, even when
(...skipping 21 matching lines...) Expand all
2391 2394
2392 // A theme with image resources missing (misspelt path). 2395 // A theme with image resources missing (misspelt path).
2393 path = data_dir_.AppendASCII("theme_missing_image.crx"); 2396 path = data_dir_.AppendASCII("theme_missing_image.crx");
2394 InstallCRX(path, INSTALL_FAILED); 2397 InstallCRX(path, INSTALL_FAILED);
2395 ValidatePrefKeyCount(pref_count); 2398 ValidatePrefKeyCount(pref_count);
2396 } 2399 }
2397 2400
2398 TEST_F(ExtensionServiceTest, LoadLocalizedTheme) { 2401 TEST_F(ExtensionServiceTest, LoadLocalizedTheme) {
2399 // Load. 2402 // Load.
2400 InitializeEmptyExtensionService(); 2403 InitializeEmptyExtensionService();
2404 service_->Init();
2405
2401 base::FilePath extension_path = data_dir_ 2406 base::FilePath extension_path = data_dir_
2402 .AppendASCII("theme_i18n"); 2407 .AppendASCII("theme_i18n");
2403 2408
2404 extensions::UnpackedInstaller::Create(service_)->Load(extension_path); 2409 extensions::UnpackedInstaller::Create(service_)->Load(extension_path);
2405 loop_.RunUntilIdle(); 2410 loop_.RunUntilIdle();
2406 EXPECT_EQ(0u, GetErrors().size()); 2411 EXPECT_EQ(0u, GetErrors().size());
2407 ASSERT_EQ(1u, loaded_.size()); 2412 ASSERT_EQ(1u, loaded_.size());
2408 EXPECT_EQ(1u, service_->extensions()->size()); 2413 EXPECT_EQ(1u, service_->extensions()->size());
2409 const Extension* theme = service_->extensions()->begin()->get(); 2414 const Extension* theme = service_->extensions()->begin()->get();
2410 EXPECT_EQ("name", theme->name()); 2415 EXPECT_EQ("name", theme->name());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2491 loop_.RunUntilIdle(); 2496 loop_.RunUntilIdle();
2492 2497
2493 EXPECT_TRUE(GetErrors().empty()); 2498 EXPECT_TRUE(GetErrors().empty());
2494 ASSERT_EQ(1u, loaded_.size()); 2499 ASSERT_EQ(1u, loaded_.size());
2495 EXPECT_EQ(1u, service_->extensions()->size()); 2500 EXPECT_EQ(1u, service_->extensions()->size());
2496 } 2501 }
2497 #endif 2502 #endif
2498 2503
2499 TEST_F(ExtensionServiceTest, InstallLocalizedTheme) { 2504 TEST_F(ExtensionServiceTest, InstallLocalizedTheme) {
2500 InitializeEmptyExtensionService(); 2505 InitializeEmptyExtensionService();
2506 service_->Init();
2507
2501 base::FilePath theme_path = data_dir_ 2508 base::FilePath theme_path = data_dir_
2502 .AppendASCII("theme_i18n"); 2509 .AppendASCII("theme_i18n");
2503 2510
2504 const Extension* theme = PackAndInstallCRX(theme_path, INSTALL_NEW); 2511 const Extension* theme = PackAndInstallCRX(theme_path, INSTALL_NEW);
2505 2512
2506 EXPECT_EQ(0u, GetErrors().size()); 2513 EXPECT_EQ(0u, GetErrors().size());
2507 EXPECT_EQ(1u, service_->extensions()->size()); 2514 EXPECT_EQ(1u, service_->extensions()->size());
2508 EXPECT_EQ("name", theme->name()); 2515 EXPECT_EQ("name", theme->name());
2509 EXPECT_EQ("description", theme->description()); 2516 EXPECT_EQ("description", theme->description());
2510 } 2517 }
(...skipping 3873 matching lines...) Expand 10 before | Expand all | Expand 10 after
6384 EXPECT_TRUE(notifications.CheckNotifications( 6391 EXPECT_TRUE(notifications.CheckNotifications(
6385 chrome::NOTIFICATION_EXTENSION_INSTALLED)); 6392 chrome::NOTIFICATION_EXTENSION_INSTALLED));
6386 6393
6387 EXPECT_TRUE(service_->GetInstalledExtension(id)); 6394 EXPECT_TRUE(service_->GetInstalledExtension(id));
6388 EXPECT_FALSE(service_->extensions()->Contains(id)); 6395 EXPECT_FALSE(service_->extensions()->Contains(id));
6389 EXPECT_TRUE(service_->blacklisted_extensions()->Contains(id)); 6396 EXPECT_TRUE(service_->blacklisted_extensions()->Contains(id));
6390 EXPECT_TRUE(service_->extension_prefs()->IsExtensionBlacklisted(id)); 6397 EXPECT_TRUE(service_->extension_prefs()->IsExtensionBlacklisted(id));
6391 EXPECT_TRUE( 6398 EXPECT_TRUE(
6392 service_->extension_prefs()->IsBlacklistedExtensionAcknowledged(id)); 6399 service_->extension_prefs()->IsBlacklistedExtensionAcknowledged(id));
6393 } 6400 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698