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

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 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after
2339 2341
2340 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator()); 2342 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator());
2341 ASSERT_TRUE(creator->Run(input_directory, crx_path, privkey_path, 2343 ASSERT_TRUE(creator->Run(input_directory, crx_path, privkey_path,
2342 base::FilePath(), ExtensionCreator::kOverwriteCRX)); 2344 base::FilePath(), ExtensionCreator::kOverwriteCRX));
2343 2345
2344 InstallCRX(crx_path, INSTALL_NEW); 2346 InstallCRX(crx_path, INSTALL_NEW);
2345 } 2347 }
2346 2348
2347 TEST_F(ExtensionServiceTest, InstallTheme) { 2349 TEST_F(ExtensionServiceTest, InstallTheme) {
2348 InitializeEmptyExtensionService(); 2350 InitializeEmptyExtensionService();
2351 service_->Init();
2349 2352
2350 // A theme. 2353 // A theme.
2351 base::FilePath path = data_dir_.AppendASCII("theme.crx"); 2354 base::FilePath path = data_dir_.AppendASCII("theme.crx");
2352 InstallCRX(path, INSTALL_NEW); 2355 InstallCRX(path, INSTALL_NEW);
2353 int pref_count = 0; 2356 int pref_count = 0;
2354 ValidatePrefKeyCount(++pref_count); 2357 ValidatePrefKeyCount(++pref_count);
2355 ValidateIntegerPref(theme_crx, "state", Extension::ENABLED); 2358 ValidateIntegerPref(theme_crx, "state", Extension::ENABLED);
2356 ValidateIntegerPref(theme_crx, "location", Manifest::INTERNAL); 2359 ValidateIntegerPref(theme_crx, "location", Manifest::INTERNAL);
2357 2360
2358 // A theme when extensions are disabled. Themes can be installed, even when 2361 // A theme when extensions are disabled. Themes can be installed, even when
(...skipping 21 matching lines...) Expand all
2380 2383
2381 // A theme with image resources missing (misspelt path). 2384 // A theme with image resources missing (misspelt path).
2382 path = data_dir_.AppendASCII("theme_missing_image.crx"); 2385 path = data_dir_.AppendASCII("theme_missing_image.crx");
2383 InstallCRX(path, INSTALL_FAILED); 2386 InstallCRX(path, INSTALL_FAILED);
2384 ValidatePrefKeyCount(pref_count); 2387 ValidatePrefKeyCount(pref_count);
2385 } 2388 }
2386 2389
2387 TEST_F(ExtensionServiceTest, LoadLocalizedTheme) { 2390 TEST_F(ExtensionServiceTest, LoadLocalizedTheme) {
2388 // Load. 2391 // Load.
2389 InitializeEmptyExtensionService(); 2392 InitializeEmptyExtensionService();
2393 service_->Init();
2394
2390 base::FilePath extension_path = data_dir_ 2395 base::FilePath extension_path = data_dir_
2391 .AppendASCII("theme_i18n"); 2396 .AppendASCII("theme_i18n");
2392 2397
2393 extensions::UnpackedInstaller::Create(service_)->Load(extension_path); 2398 extensions::UnpackedInstaller::Create(service_)->Load(extension_path);
2394 loop_.RunUntilIdle(); 2399 loop_.RunUntilIdle();
2395 EXPECT_EQ(0u, GetErrors().size()); 2400 EXPECT_EQ(0u, GetErrors().size());
2396 ASSERT_EQ(1u, loaded_.size()); 2401 ASSERT_EQ(1u, loaded_.size());
2397 EXPECT_EQ(1u, service_->extensions()->size()); 2402 EXPECT_EQ(1u, service_->extensions()->size());
2398 const Extension* theme = service_->extensions()->begin()->get(); 2403 const Extension* theme = service_->extensions()->begin()->get();
2399 EXPECT_EQ("name", theme->name()); 2404 EXPECT_EQ("name", theme->name());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2480 loop_.RunUntilIdle(); 2485 loop_.RunUntilIdle();
2481 2486
2482 EXPECT_TRUE(GetErrors().empty()); 2487 EXPECT_TRUE(GetErrors().empty());
2483 ASSERT_EQ(1u, loaded_.size()); 2488 ASSERT_EQ(1u, loaded_.size());
2484 EXPECT_EQ(1u, service_->extensions()->size()); 2489 EXPECT_EQ(1u, service_->extensions()->size());
2485 } 2490 }
2486 #endif 2491 #endif
2487 2492
2488 TEST_F(ExtensionServiceTest, InstallLocalizedTheme) { 2493 TEST_F(ExtensionServiceTest, InstallLocalizedTheme) {
2489 InitializeEmptyExtensionService(); 2494 InitializeEmptyExtensionService();
2495 service_->Init();
2496
2490 base::FilePath theme_path = data_dir_ 2497 base::FilePath theme_path = data_dir_
2491 .AppendASCII("theme_i18n"); 2498 .AppendASCII("theme_i18n");
2492 2499
2493 const Extension* theme = PackAndInstallCRX(theme_path, INSTALL_NEW); 2500 const Extension* theme = PackAndInstallCRX(theme_path, INSTALL_NEW);
2494 2501
2495 EXPECT_EQ(0u, GetErrors().size()); 2502 EXPECT_EQ(0u, GetErrors().size());
2496 EXPECT_EQ(1u, service_->extensions()->size()); 2503 EXPECT_EQ(1u, service_->extensions()->size());
2497 EXPECT_EQ("name", theme->name()); 2504 EXPECT_EQ("name", theme->name());
2498 EXPECT_EQ("description", theme->description()); 2505 EXPECT_EQ("description", theme->description());
2499 } 2506 }
(...skipping 3832 matching lines...) Expand 10 before | Expand all | Expand 10 after
6332 provider->UpdateOrAddExtension(updates_from_webstore, "1", crx_path); 6339 provider->UpdateOrAddExtension(updates_from_webstore, "1", crx_path);
6333 6340
6334 service_->CheckForExternalUpdates(); 6341 service_->CheckForExternalUpdates();
6335 content::WindowedNotificationObserver( 6342 content::WindowedNotificationObserver(
6336 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 6343 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
6337 content::NotificationService::AllSources()).Wait(); 6344 content::NotificationService::AllSources()).Wait();
6338 EXPECT_TRUE(extensions::HasExternalInstallError(service_)); 6345 EXPECT_TRUE(extensions::HasExternalInstallError(service_));
6339 EXPECT_FALSE(extensions::HasExternalInstallBubble(service_)); 6346 EXPECT_FALSE(extensions::HasExternalInstallBubble(service_));
6340 EXPECT_FALSE(service_->IsExtensionEnabled(updates_from_webstore)); 6347 EXPECT_FALSE(service_->IsExtensionEnabled(updates_from_webstore));
6341 } 6348 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698