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

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

Issue 256022: Loads local resources from current locale subtree if available, if not it fal... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 "app/l10n_util.h"
7 #include "base/file_path.h" 8 #include "base/file_path.h"
8 #include "base/file_util.h" 9 #include "base/file_util.h"
9 #include "base/path_service.h" 10 #include "base/path_service.h"
10 #include "base/scoped_ptr.h" 11 #include "base/scoped_ptr.h"
11 #include "base/scoped_temp_dir.h" 12 #include "base/scoped_temp_dir.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "chrome/common/chrome_paths.h" 14 #include "chrome/common/chrome_paths.h"
14 #include "chrome/common/extensions/extension.h" 15 #include "chrome/common/extensions/extension.h"
15 #include "chrome/common/extensions/extension_constants.h" 16 #include "chrome/common/extensions/extension_constants.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // pair at the end. 137 // pair at the end.
137 scoped_ptr<ExtensionMessageBundle> message_bundle( 138 scoped_ptr<ExtensionMessageBundle> message_bundle(
138 extension_l10n_util::LoadMessageCatalogs(src_path, 139 extension_l10n_util::LoadMessageCatalogs(src_path,
139 "en-US", 140 "en-US",
140 "sr", 141 "sr",
141 &error)); 142 &error));
142 EXPECT_TRUE(NULL != message_bundle.get()); 143 EXPECT_TRUE(NULL != message_bundle.get());
143 EXPECT_TRUE(error.empty()); 144 EXPECT_TRUE(error.empty());
144 } 145 }
145 146
147 bool PathsAreEqual(const FilePath& path1, const FilePath& path2) {
148 FilePath::StringType path1_str = path1.value();
149 std::replace(path1_str.begin(), path1_str.end(), '\\', '/');
150
151 FilePath::StringType path2_str = path2.value();
152 std::replace(path2_str.begin(), path2_str.end(), '\\', '/');
153
154 if (path1_str == path2_str) {
155 return true;
156 } else {
157 return false;
158 }
159 }
160
161 TEST(ExtensionL10nUtil, GetL10nRelativePath) {
162 static std::string current_locale = l10n_util::GetApplicationLocale(L"");
163 std::replace(current_locale.begin(), current_locale.end(), '-', '_');
164
165 FilePath locale_path;
166 locale_path = locale_path
167 .AppendASCII(Extension::kLocaleFolder)
168 .AppendASCII(current_locale)
169 .AppendASCII("foo")
170 .AppendASCII("bar.js");
171
172 FilePath result = extension_l10n_util::GetL10nRelativePath(
173 FilePath(FILE_PATH_LITERAL("foo/bar.js")));
174 EXPECT_TRUE(PathsAreEqual(locale_path, result));
175 }
176
146 } // namespace 177 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_l10n_util.cc ('k') | chrome/browser/extensions/extension_protocols.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698