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

Side by Side Diff: chrome/browser/extensions/extension_l10n_util_unittest.cc

Issue 196029: Simple fix of extension_l10n_util that allows folders in form ".some_name" to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_l10n_util.h" 5 #include "chrome/browser/extensions/extension_l10n_util.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h"
9 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
10 #include "base/scoped_temp_dir.h" 11 #include "base/scoped_temp_dir.h"
11 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/common/chrome_paths.h"
12 #include "chrome/common/extensions/extension.h" 14 #include "chrome/common/extensions/extension.h"
13 #include "chrome/common/extensions/extension_constants.h" 15 #include "chrome/common/extensions/extension_constants.h"
14 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
15 17
16 namespace keys = extension_manifest_keys; 18 namespace keys = extension_manifest_keys;
17 19
18 namespace { 20 namespace {
19 21
20 Extension* CreateMinimalExtension(const std::string& default_locale) { 22 TEST(ExtensionL10nUtil, LoadGoodExtensionFromSVNTree) {
23 FilePath install_dir;
24 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir));
25 install_dir = install_dir.AppendASCII("extensions")
26 .AppendASCII("good")
27 .AppendASCII("Extensions")
28 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
29 .AppendASCII("1.0.0.0");
30
31 FilePath locale_path = install_dir.AppendASCII(Extension::kLocaleFolder);
32 ASSERT_TRUE(file_util::PathExists(locale_path));
33
34 scoped_ptr<Extension> extension(new Extension(install_dir));
35 std::string error;
36 EXPECT_TRUE(extension_l10n_util::AddValidLocales(
37 locale_path, extension.get(), &error));
38 const std::set<std::string>& supported_locales =
39 extension->supported_locales();
40 EXPECT_EQ(2U, supported_locales.size());
41 EXPECT_TRUE(supported_locales.find("en-US") != supported_locales.end());
42 EXPECT_TRUE(supported_locales.find("sr") != supported_locales.end());
43 }
44
45 Extension* CreateMinimalExtension(const std::string& default_locale) {
21 #if defined(OS_WIN) 46 #if defined(OS_WIN)
22 FilePath path(FILE_PATH_LITERAL("C:\\foo")); 47 FilePath path(FILE_PATH_LITERAL("C:\\foo"));
23 #elif defined(OS_POSIX) 48 #elif defined(OS_POSIX)
24 FilePath path(FILE_PATH_LITERAL("/foo")); 49 FilePath path(FILE_PATH_LITERAL("/foo"));
25 #endif 50 #endif
26 Extension* extension = new Extension(path); 51 Extension* extension = new Extension(path);
27 std::string error; 52 std::string error;
28 DictionaryValue input_value; 53 DictionaryValue input_value;
29 54
30 // Test minimal extension 55 // Test minimal extension
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 151
127 TEST(ExtensionL10nUtil, SetDefaultLocaleWrongDefaultLocaleInManifest) { 152 TEST(ExtensionL10nUtil, SetDefaultLocaleWrongDefaultLocaleInManifest) {
128 scoped_ptr<Extension> extension(CreateMinimalExtension("ko")); 153 scoped_ptr<Extension> extension(CreateMinimalExtension("ko"));
129 extension->AddSupportedLocale("sr"); 154 extension->AddSupportedLocale("sr");
130 extension->AddSupportedLocale("en-US"); 155 extension->AddSupportedLocale("en-US");
131 156
132 EXPECT_FALSE(extension_l10n_util::ValidateDefaultLocale(extension.get())); 157 EXPECT_FALSE(extension_l10n_util::ValidateDefaultLocale(extension.get()));
133 } 158 }
134 159
135 } // namespace 160 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698