OLD | NEW |
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 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 << path.value(); | 819 << path.value(); |
820 // If INSTALL_UPDATED, old_name_ should match the given string. | 820 // If INSTALL_UPDATED, old_name_ should match the given string. |
821 if (install_state == INSTALL_UPDATED && !expected_old_name.empty()) | 821 if (install_state == INSTALL_UPDATED && !expected_old_name.empty()) |
822 EXPECT_EQ(expected_old_name, old_name_); | 822 EXPECT_EQ(expected_old_name, old_name_); |
823 EXPECT_EQ(0u, errors.size()) << path.value(); | 823 EXPECT_EQ(0u, errors.size()) << path.value(); |
824 | 824 |
825 if (install_state == INSTALL_WITHOUT_LOAD) { | 825 if (install_state == INSTALL_WITHOUT_LOAD) { |
826 EXPECT_EQ(0u, loaded_.size()) << path.value(); | 826 EXPECT_EQ(0u, loaded_.size()) << path.value(); |
827 } else { | 827 } else { |
828 EXPECT_EQ(1u, loaded_.size()) << path.value(); | 828 EXPECT_EQ(1u, loaded_.size()) << path.value(); |
829 EXPECT_EQ(expected_extensions_count_, service_->extensions()->size()) << | 829 size_t actual_extension_count = service_->extensions()->size() + |
| 830 service_->disabled_extensions()->size(); |
| 831 EXPECT_EQ(expected_extensions_count_, actual_extension_count) << |
830 path.value(); | 832 path.value(); |
831 extension = loaded_[0].get(); | 833 extension = loaded_[0].get(); |
832 EXPECT_TRUE(service_->GetExtensionById(extension->id(), false)) | 834 EXPECT_TRUE(service_->GetExtensionById(extension->id(), false)) |
833 << path.value(); | 835 << path.value(); |
834 } | 836 } |
835 | 837 |
836 for (std::vector<string16>::iterator err = errors.begin(); | 838 for (std::vector<string16>::iterator err = errors.begin(); |
837 err != errors.end(); ++err) { | 839 err != errors.end(); ++err) { |
838 LOG(ERROR) << *err; | 840 LOG(ERROR) << *err; |
839 } | 841 } |
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 base::RunLoop().RunUntilIdle(); | 2399 base::RunLoop().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 Loading... |
2480 base::RunLoop().RunUntilIdle(); | 2485 base::RunLoop().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 3871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6371 EXPECT_TRUE(notifications.CheckNotifications( | 6378 EXPECT_TRUE(notifications.CheckNotifications( |
6372 chrome::NOTIFICATION_EXTENSION_INSTALLED)); | 6379 chrome::NOTIFICATION_EXTENSION_INSTALLED)); |
6373 | 6380 |
6374 EXPECT_TRUE(service_->GetInstalledExtension(id)); | 6381 EXPECT_TRUE(service_->GetInstalledExtension(id)); |
6375 EXPECT_FALSE(service_->extensions()->Contains(id)); | 6382 EXPECT_FALSE(service_->extensions()->Contains(id)); |
6376 EXPECT_TRUE(service_->blacklisted_extensions()->Contains(id)); | 6383 EXPECT_TRUE(service_->blacklisted_extensions()->Contains(id)); |
6377 EXPECT_TRUE(service_->extension_prefs()->IsExtensionBlacklisted(id)); | 6384 EXPECT_TRUE(service_->extension_prefs()->IsExtensionBlacklisted(id)); |
6378 EXPECT_TRUE( | 6385 EXPECT_TRUE( |
6379 service_->extension_prefs()->IsBlacklistedExtensionAcknowledged(id)); | 6386 service_->extension_prefs()->IsBlacklistedExtensionAcknowledged(id)); |
6380 } | 6387 } |
OLD | NEW |