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

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: 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 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 << path.value(); 827 << path.value();
828 // If INSTALL_UPDATED, old_name_ should match the given string. 828 // If INSTALL_UPDATED, old_name_ should match the given string.
829 if (install_state == INSTALL_UPDATED && !expected_old_name.empty()) 829 if (install_state == INSTALL_UPDATED && !expected_old_name.empty())
830 EXPECT_EQ(expected_old_name, old_name_); 830 EXPECT_EQ(expected_old_name, old_name_);
831 EXPECT_EQ(0u, errors.size()) << path.value(); 831 EXPECT_EQ(0u, errors.size()) << path.value();
832 832
833 if (install_state == INSTALL_WITHOUT_LOAD) { 833 if (install_state == INSTALL_WITHOUT_LOAD) {
834 EXPECT_EQ(0u, loaded_.size()) << path.value(); 834 EXPECT_EQ(0u, loaded_.size()) << path.value();
835 } else { 835 } else {
836 EXPECT_EQ(1u, loaded_.size()) << path.value(); 836 EXPECT_EQ(1u, loaded_.size()) << path.value();
837 EXPECT_EQ(expected_extensions_count_, service_->extensions()->size()) << 837 size_t actual_extension_count = service_->extensions()->size() +
838 service_->disabled_extensions()->size();
839 EXPECT_EQ(expected_extensions_count_, actual_extension_count) <<
838 path.value(); 840 path.value();
839 extension = loaded_[0].get(); 841 extension = loaded_[0].get();
840 EXPECT_TRUE(service_->GetExtensionById(extension->id(), false)) 842 EXPECT_TRUE(service_->GetExtensionById(extension->id(), false))
841 << path.value(); 843 << path.value();
842 } 844 }
843 845
844 for (std::vector<string16>::iterator err = errors.begin(); 846 for (std::vector<string16>::iterator err = errors.begin();
845 err != errors.end(); ++err) { 847 err != errors.end(); ++err) {
846 LOG(ERROR) << *err; 848 LOG(ERROR) << *err;
847 } 849 }
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after
2347 2349
2348 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator()); 2350 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator());
2349 ASSERT_TRUE(creator->Run(input_directory, crx_path, privkey_path, 2351 ASSERT_TRUE(creator->Run(input_directory, crx_path, privkey_path,
2350 base::FilePath(), ExtensionCreator::kOverwriteCRX)); 2352 base::FilePath(), ExtensionCreator::kOverwriteCRX));
2351 2353
2352 InstallCRX(crx_path, INSTALL_NEW); 2354 InstallCRX(crx_path, INSTALL_NEW);
2353 } 2355 }
2354 2356
2355 TEST_F(ExtensionServiceTest, InstallTheme) { 2357 TEST_F(ExtensionServiceTest, InstallTheme) {
2356 InitializeEmptyExtensionService(); 2358 InitializeEmptyExtensionService();
2359 service_->Init();
2357 2360
2358 // A theme. 2361 // A theme.
2359 base::FilePath path = data_dir_.AppendASCII("theme.crx"); 2362 base::FilePath path = data_dir_.AppendASCII("theme.crx");
2360 InstallCRX(path, INSTALL_NEW); 2363 InstallCRX(path, INSTALL_NEW);
2361 int pref_count = 0; 2364 int pref_count = 0;
2362 ValidatePrefKeyCount(++pref_count); 2365 ValidatePrefKeyCount(++pref_count);
2363 ValidateIntegerPref(theme_crx, "state", Extension::ENABLED); 2366 ValidateIntegerPref(theme_crx, "state", Extension::ENABLED);
2364 ValidateIntegerPref(theme_crx, "location", Manifest::INTERNAL); 2367 ValidateIntegerPref(theme_crx, "location", Manifest::INTERNAL);
2365 2368
2366 // A theme when extensions are disabled. Themes can be installed, even when 2369 // A theme when extensions are disabled. Themes can be installed, even when
(...skipping 21 matching lines...) Expand all
2388 2391
2389 // A theme with image resources missing (misspelt path). 2392 // A theme with image resources missing (misspelt path).
2390 path = data_dir_.AppendASCII("theme_missing_image.crx"); 2393 path = data_dir_.AppendASCII("theme_missing_image.crx");
2391 InstallCRX(path, INSTALL_FAILED); 2394 InstallCRX(path, INSTALL_FAILED);
2392 ValidatePrefKeyCount(pref_count); 2395 ValidatePrefKeyCount(pref_count);
2393 } 2396 }
2394 2397
2395 TEST_F(ExtensionServiceTest, LoadLocalizedTheme) { 2398 TEST_F(ExtensionServiceTest, LoadLocalizedTheme) {
2396 // Load. 2399 // Load.
2397 InitializeEmptyExtensionService(); 2400 InitializeEmptyExtensionService();
2401 service_->Init();
2402
2398 base::FilePath extension_path = data_dir_ 2403 base::FilePath extension_path = data_dir_
2399 .AppendASCII("theme_i18n"); 2404 .AppendASCII("theme_i18n");
2400 2405
2401 extensions::UnpackedInstaller::Create(service_)->Load(extension_path); 2406 extensions::UnpackedInstaller::Create(service_)->Load(extension_path);
2402 loop_.RunUntilIdle(); 2407 loop_.RunUntilIdle();
2403 EXPECT_EQ(0u, GetErrors().size()); 2408 EXPECT_EQ(0u, GetErrors().size());
2404 ASSERT_EQ(1u, loaded_.size()); 2409 ASSERT_EQ(1u, loaded_.size());
2405 EXPECT_EQ(1u, service_->extensions()->size()); 2410 EXPECT_EQ(1u, service_->extensions()->size());
2406 const Extension* theme = service_->extensions()->begin()->get(); 2411 const Extension* theme = service_->extensions()->begin()->get();
2407 EXPECT_EQ("name", theme->name()); 2412 EXPECT_EQ("name", theme->name());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2488 loop_.RunUntilIdle(); 2493 loop_.RunUntilIdle();
2489 2494
2490 EXPECT_TRUE(GetErrors().empty()); 2495 EXPECT_TRUE(GetErrors().empty());
2491 ASSERT_EQ(1u, loaded_.size()); 2496 ASSERT_EQ(1u, loaded_.size());
2492 EXPECT_EQ(1u, service_->extensions()->size()); 2497 EXPECT_EQ(1u, service_->extensions()->size());
2493 } 2498 }
2494 #endif 2499 #endif
2495 2500
2496 TEST_F(ExtensionServiceTest, InstallLocalizedTheme) { 2501 TEST_F(ExtensionServiceTest, InstallLocalizedTheme) {
2497 InitializeEmptyExtensionService(); 2502 InitializeEmptyExtensionService();
2503 service_->Init();
2504
2498 base::FilePath theme_path = data_dir_ 2505 base::FilePath theme_path = data_dir_
2499 .AppendASCII("theme_i18n"); 2506 .AppendASCII("theme_i18n");
2500 2507
2501 const Extension* theme = PackAndInstallCRX(theme_path, INSTALL_NEW); 2508 const Extension* theme = PackAndInstallCRX(theme_path, INSTALL_NEW);
2502 2509
2503 EXPECT_EQ(0u, GetErrors().size()); 2510 EXPECT_EQ(0u, GetErrors().size());
2504 EXPECT_EQ(1u, service_->extensions()->size()); 2511 EXPECT_EQ(1u, service_->extensions()->size());
2505 EXPECT_EQ("name", theme->name()); 2512 EXPECT_EQ("name", theme->name());
2506 EXPECT_EQ("description", theme->description()); 2513 EXPECT_EQ("description", theme->description());
2507 } 2514 }
(...skipping 3832 matching lines...) Expand 10 before | Expand all | Expand 10 after
6340 provider->UpdateOrAddExtension(updates_from_webstore, "1", crx_path); 6347 provider->UpdateOrAddExtension(updates_from_webstore, "1", crx_path);
6341 6348
6342 service_->CheckForExternalUpdates(); 6349 service_->CheckForExternalUpdates();
6343 content::WindowedNotificationObserver( 6350 content::WindowedNotificationObserver(
6344 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 6351 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
6345 content::NotificationService::AllSources()).Wait(); 6352 content::NotificationService::AllSources()).Wait();
6346 EXPECT_TRUE(extensions::HasExternalInstallError(service_)); 6353 EXPECT_TRUE(extensions::HasExternalInstallError(service_));
6347 EXPECT_FALSE(extensions::HasExternalInstallBubble(service_)); 6354 EXPECT_FALSE(extensions::HasExternalInstallBubble(service_));
6348 EXPECT_FALSE(service_->IsExtensionEnabled(updates_from_webstore)); 6355 EXPECT_FALSE(service_->IsExtensionEnabled(updates_from_webstore));
6349 } 6356 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698