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

Side by Side Diff: chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc

Issue 11786003: Move Icons out of Extension class (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_unref_browser_action
Patch Set: Created 7 years, 9 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
OLDNEW
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 "base/i18n/rtl.h" 5 #include "base/i18n/rtl.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/common/chrome_paths.h" 8 #include "chrome/common/chrome_paths.h"
9 #include "chrome/common/extensions/api/extension_action/page_action_handler.h" 9 #include "chrome/common/extensions/api/extension_action/page_action_handler.h"
10 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" 10 #include "chrome/common/extensions/api/i18n/default_locale_handler.h"
11 #include "chrome/common/extensions/api/icons/icons_handler.h"
11 #include "chrome/common/extensions/extension.h" 12 #include "chrome/common/extensions/extension.h"
12 #include "chrome/common/extensions/extension_manifest_constants.h" 13 #include "chrome/common/extensions/extension_manifest_constants.h"
14 #include "chrome/common/extensions/manifest_handler.h"
13 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" 15 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
14 #include "chrome/common/extensions/manifest_url_handler.h" 16 #include "chrome/common/extensions/manifest_url_handler.h"
15 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
16 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
17 19
18 #if defined(TOOLKIT_GTK) 20 #if defined(TOOLKIT_GTK)
19 #include <gtk/gtk.h> 21 #include <gtk/gtk.h>
20 #endif 22 #endif
21 23
22 namespace errors = extension_manifest_errors; 24 namespace errors = extension_manifest_errors;
23 namespace keys = extension_manifest_keys; 25 namespace keys = extension_manifest_keys;
24 26
27 namespace extensions {
28
25 class InitValueManifestTest : public ExtensionManifestTest { 29 class InitValueManifestTest : public ExtensionManifestTest {
30 protected:
26 virtual void SetUp() OVERRIDE { 31 virtual void SetUp() OVERRIDE {
27 ExtensionManifestTest::SetUp(); 32 ExtensionManifestTest::SetUp();
33 ManifestHandler::Register(extension_manifest_keys::kIcons,
34 make_linked_ptr(new IconsHandler));
28 extensions::ManifestHandler::Register( 35 extensions::ManifestHandler::Register(
29 keys::kOptionsPage, 36 keys::kOptionsPage,
30 make_linked_ptr(new extensions::OptionsPageHandler)); 37 make_linked_ptr(new extensions::OptionsPageHandler));
31 extensions::ManifestHandler::Register( 38 extensions::ManifestHandler::Register(
32 keys::kDefaultLocale, 39 keys::kDefaultLocale,
33 make_linked_ptr(new extensions::DefaultLocaleHandler)); 40 make_linked_ptr(new extensions::DefaultLocaleHandler));
34 linked_ptr<extensions::PageActionHandler> page_action_handler( 41 linked_ptr<extensions::PageActionHandler> page_action_handler(
35 new extensions::PageActionHandler); 42 new extensions::PageActionHandler);
36 extensions::ManifestHandler::Register(keys::kPageAction, page_action_handler); 43 extensions::ManifestHandler::Register(keys::kPageAction, page_action_handler);
37 extensions::ManifestHandler::Register( 44 extensions::ManifestHandler::Register(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 errors::kInvalidMinimumChromeVersion), 92 errors::kInvalidMinimumChromeVersion),
86 Testcase("init_invalid_chrome_version_too_low.json", 93 Testcase("init_invalid_chrome_version_too_low.json",
87 errors::kChromeVersionTooLow), 94 errors::kChromeVersionTooLow),
88 }; 95 };
89 96
90 RunTestcases(testcases, arraysize(testcases), 97 RunTestcases(testcases, arraysize(testcases),
91 EXPECT_TYPE_ERROR); 98 EXPECT_TYPE_ERROR);
92 } 99 }
93 100
94 TEST_F(InitValueManifestTest, InitFromValueValid) { 101 TEST_F(InitValueManifestTest, InitFromValueValid) {
95 scoped_refptr<extensions::Extension> extension(LoadAndExpectSuccess( 102 scoped_refptr<Extension> extension(LoadAndExpectSuccess(
96 "init_valid_minimal.json")); 103 "init_valid_minimal.json"));
97 104
98 base::FilePath path; 105 base::FilePath path;
99 PathService::Get(chrome::DIR_TEST_DATA, &path); 106 PathService::Get(chrome::DIR_TEST_DATA, &path);
100 path = path.AppendASCII("extensions"); 107 path = path.AppendASCII("extensions");
101 108
102 EXPECT_TRUE(extensions::Extension::IdIsValid(extension->id())); 109 EXPECT_TRUE(Extension::IdIsValid(extension->id()));
103 EXPECT_EQ("1.0.0.0", extension->VersionString()); 110 EXPECT_EQ("1.0.0.0", extension->VersionString());
104 EXPECT_EQ("my extension", extension->name()); 111 EXPECT_EQ("my extension", extension->name());
105 EXPECT_EQ(extension->id(), extension->url().host()); 112 EXPECT_EQ(extension->id(), extension->url().host());
106 EXPECT_EQ(extension->path(), path); 113 EXPECT_EQ(extension->path(), path);
107 EXPECT_EQ(path, extension->path()); 114 EXPECT_EQ(path, extension->path());
108 115
109 // Test permissions scheme. 116 // Test permissions scheme.
110 // We allow unknown API permissions, so this will be valid until we better 117 // We allow unknown API permissions, so this will be valid until we better
111 // distinguish between API and host permissions. 118 // distinguish between API and host permissions.
112 LoadAndExpectSuccess("init_valid_permissions.json"); 119 LoadAndExpectSuccess("init_valid_permissions.json");
113 120
114 // Test with an options page. 121 // Test with an options page.
115 extension = LoadAndExpectSuccess("init_valid_options.json"); 122 extension = LoadAndExpectSuccess("init_valid_options.json");
116 EXPECT_EQ("chrome-extension", 123 EXPECT_EQ("chrome-extension",
117 extensions::ManifestURL::GetOptionsPage(extension).scheme()); 124 ManifestURL::GetOptionsPage(extension).scheme());
118 EXPECT_EQ("/options.html", 125 EXPECT_EQ("/options.html",
119 extensions::ManifestURL::GetOptionsPage(extension).path()); 126 ManifestURL::GetOptionsPage(extension).path());
120 127
121 Testcase testcases[] = { 128 Testcase testcases[] = {
122 // Test that an empty list of page actions does not stop a browser action 129 // Test that an empty list of page actions does not stop a browser action
123 // from being loaded. 130 // from being loaded.
124 Testcase("init_valid_empty_page_actions.json"), 131 Testcase("init_valid_empty_page_actions.json"),
125 132
126 // Test with a minimum_chrome_version. 133 // Test with a minimum_chrome_version.
127 Testcase("init_valid_minimum_chrome.json"), 134 Testcase("init_valid_minimum_chrome.json"),
128 135
129 // Test a hosted app with a minimum_chrome_version. 136 // Test a hosted app with a minimum_chrome_version.
(...skipping 17 matching lines...) Expand all
147 TEST_F(InitValueManifestTest, InitFromValueValidNameInRTL) { 154 TEST_F(InitValueManifestTest, InitFromValueValidNameInRTL) {
148 #if defined(TOOLKIT_GTK) 155 #if defined(TOOLKIT_GTK)
149 GtkTextDirection gtk_dir = gtk_widget_get_default_direction(); 156 GtkTextDirection gtk_dir = gtk_widget_get_default_direction();
150 gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL); 157 gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL);
151 #else 158 #else
152 std::string locale = l10n_util::GetApplicationLocale(""); 159 std::string locale = l10n_util::GetApplicationLocale("");
153 base::i18n::SetICUDefaultLocale("he"); 160 base::i18n::SetICUDefaultLocale("he");
154 #endif 161 #endif
155 162
156 // No strong RTL characters in name. 163 // No strong RTL characters in name.
157 scoped_refptr<extensions::Extension> extension(LoadAndExpectSuccess( 164 scoped_refptr<Extension> extension(LoadAndExpectSuccess(
158 "init_valid_name_no_rtl.json")); 165 "init_valid_name_no_rtl.json"));
159 166
160 string16 localized_name(ASCIIToUTF16("Dictionary (by Google)")); 167 string16 localized_name(ASCIIToUTF16("Dictionary (by Google)"));
161 base::i18n::AdjustStringForLocaleDirection(&localized_name); 168 base::i18n::AdjustStringForLocaleDirection(&localized_name);
162 EXPECT_EQ(localized_name, UTF8ToUTF16(extension->name())); 169 EXPECT_EQ(localized_name, UTF8ToUTF16(extension->name()));
163 170
164 // Strong RTL characters in name. 171 // Strong RTL characters in name.
165 extension = LoadAndExpectSuccess("init_valid_name_strong_rtl.json"); 172 extension = LoadAndExpectSuccess("init_valid_name_strong_rtl.json");
166 173
167 localized_name = WideToUTF16(L"Dictionary (\x05D1\x05D2"L" Google)"); 174 localized_name = WideToUTF16(L"Dictionary (\x05D1\x05D2"L" Google)");
168 base::i18n::AdjustStringForLocaleDirection(&localized_name); 175 base::i18n::AdjustStringForLocaleDirection(&localized_name);
169 EXPECT_EQ(localized_name, UTF8ToUTF16(extension->name())); 176 EXPECT_EQ(localized_name, UTF8ToUTF16(extension->name()));
170 177
171 // Reset locale. 178 // Reset locale.
172 #if defined(TOOLKIT_GTK) 179 #if defined(TOOLKIT_GTK)
173 gtk_widget_set_default_direction(gtk_dir); 180 gtk_widget_set_default_direction(gtk_dir);
174 #else 181 #else
175 base::i18n::SetICUDefaultLocale(locale); 182 base::i18n::SetICUDefaultLocale(locale);
176 #endif 183 #endif
177 } 184 }
185
186 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698