OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 1807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1818 | 1818 |
1819 // A theme when extensions are disabled. Themes can be installed, even when | 1819 // A theme when extensions are disabled. Themes can be installed, even when |
1820 // extensions are disabled. | 1820 // extensions are disabled. |
1821 set_extensions_enabled(false); | 1821 set_extensions_enabled(false); |
1822 path = data_dir_.AppendASCII("theme2.crx"); | 1822 path = data_dir_.AppendASCII("theme2.crx"); |
1823 InstallCRX(path, INSTALL_NEW); | 1823 InstallCRX(path, INSTALL_NEW); |
1824 ValidatePrefKeyCount(++pref_count); | 1824 ValidatePrefKeyCount(++pref_count); |
1825 ValidateIntegerPref(theme2_crx, "state", Extension::ENABLED); | 1825 ValidateIntegerPref(theme2_crx, "state", Extension::ENABLED); |
1826 ValidateIntegerPref(theme2_crx, "location", Extension::INTERNAL); | 1826 ValidateIntegerPref(theme2_crx, "location", Extension::INTERNAL); |
1827 | 1827 |
1828 // A theme with extension elements. Themes cannot have extension elements so | 1828 // A theme with extension elements. Themes cannot have extension elements, |
1829 // this test should fail. | 1829 // so any such elements (like content scripts) should be ignored. |
1830 set_extensions_enabled(true); | 1830 set_extensions_enabled(true); |
1831 path = data_dir_.AppendASCII("theme_with_extension.crx"); | 1831 { |
1832 InstallCRX(path, INSTALL_FAILED); | 1832 path = data_dir_.AppendASCII("theme_with_extension.crx"); |
1833 ValidatePrefKeyCount(pref_count); | 1833 const Extension* extension = InstallCRX(path, INSTALL_NEW); |
| 1834 ValidatePrefKeyCount(++pref_count); |
| 1835 ASSERT_TRUE(extension); |
| 1836 EXPECT_TRUE(extension->is_theme()); |
| 1837 EXPECT_EQ(0u, extension->content_scripts().size()); |
| 1838 } |
1834 | 1839 |
1835 // A theme with image resources missing (misspelt path). | 1840 // A theme with image resources missing (misspelt path). |
1836 path = data_dir_.AppendASCII("theme_missing_image.crx"); | 1841 path = data_dir_.AppendASCII("theme_missing_image.crx"); |
1837 InstallCRX(path, INSTALL_FAILED); | 1842 InstallCRX(path, INSTALL_FAILED); |
1838 ValidatePrefKeyCount(pref_count); | 1843 ValidatePrefKeyCount(pref_count); |
1839 } | 1844 } |
1840 | 1845 |
1841 TEST_F(ExtensionServiceTest, LoadLocalizedTheme) { | 1846 TEST_F(ExtensionServiceTest, LoadLocalizedTheme) { |
1842 // Load. | 1847 // Load. |
1843 InitializeEmptyExtensionService(); | 1848 InitializeEmptyExtensionService(); |
(...skipping 3038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4882 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0", | 4887 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0", |
4883 data_dir_.AppendASCII("hosted_app.crx")); | 4888 data_dir_.AppendASCII("hosted_app.crx")); |
4884 | 4889 |
4885 service_->CheckForExternalUpdates(); | 4890 service_->CheckForExternalUpdates(); |
4886 loop_.RunAllPending(); | 4891 loop_.RunAllPending(); |
4887 | 4892 |
4888 ASSERT_TRUE(service_->PopulateExtensionGlobalError( | 4893 ASSERT_TRUE(service_->PopulateExtensionGlobalError( |
4889 extension_global_error.get())); | 4894 extension_global_error.get())); |
4890 ASSERT_EQ(1u, extension_global_error->get_external_extension_ids()->size()); | 4895 ASSERT_EQ(1u, extension_global_error->get_external_extension_ids()->size()); |
4891 } | 4896 } |
OLD | NEW |