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

Side by Side Diff: app/text_elider_unittest.cc

Issue 1073005: Move RTL related functions from app/l10n_util to base/i18n/rtl... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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 | Annotate | Revision Log
« no previous file with comments | « app/text_elider.cc ('k') | app/win_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "app/gfx/font.h" 5 #include "app/gfx/font.h"
6 #include "app/text_elider.h" 6 #include "app/text_elider.h"
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/i18n/rtl.h"
9 #include "base/string_util.h" 10 #include "base/string_util.h"
10 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace { 14 namespace {
14 15
15 const wchar_t kEllipsis[] = L"\x2026"; 16 const wchar_t kEllipsis[] = L"\x2026";
16 17
17 struct Testcase { 18 struct Testcase {
18 const std::string input; 19 const std::string input;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 {FILE_PATH_LITERAL("filename.longext"), 172 {FILE_PATH_LITERAL("filename.longext"),
172 L"file" + kEllipsisStr + L".longext"}, 173 L"file" + kEllipsisStr + L".longext"},
173 {FILE_PATH_LITERAL("filename.middleext.longext"), 174 {FILE_PATH_LITERAL("filename.middleext.longext"),
174 L"filename.mid" + kEllipsisStr + L".longext"} 175 L"filename.mid" + kEllipsisStr + L".longext"}
175 }; 176 };
176 177
177 static const gfx::Font font; 178 static const gfx::Font font;
178 for (size_t i = 0; i < arraysize(testcases); ++i) { 179 for (size_t i = 0; i < arraysize(testcases); ++i) {
179 FilePath filepath(testcases[i].input); 180 FilePath filepath(testcases[i].input);
180 std::wstring expected = testcases[i].output; 181 std::wstring expected = testcases[i].output;
181 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) 182 if (base::i18n::IsRTL())
182 l10n_util::WrapStringWithLTRFormatting(&expected); 183 base::i18n::WrapStringWithLTRFormatting(&expected);
183 EXPECT_EQ(expected, ElideFilename(filepath, 184 EXPECT_EQ(expected, ElideFilename(filepath,
184 font, 185 font,
185 font.GetStringWidth(testcases[i].output))); 186 font.GetStringWidth(testcases[i].output)));
186 } 187 }
187 } 188 }
188 189
189 TEST(TextEliderTest, ElideTextLongStrings) { 190 TEST(TextEliderTest, ElideTextLongStrings) {
190 const std::wstring kEllipsisStr(kEllipsis); 191 const std::wstring kEllipsisStr(kEllipsis);
191 std::wstring data_scheme(L"data:text/plain,"); 192 std::wstring data_scheme(L"data:text/plain,");
192 193
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 { "http://www.a/", "http://b/", -1 }, 262 { "http://www.a/", "http://b/", -1 },
262 }; 263 };
263 264
264 for (size_t i = 0; i < arraysize(tests); ++i) { 265 for (size_t i = 0; i < arraysize(tests); ++i) {
265 gfx::SortedDisplayURL url1(GURL(tests[i].a), std::wstring()); 266 gfx::SortedDisplayURL url1(GURL(tests[i].a), std::wstring());
266 gfx::SortedDisplayURL url2(GURL(tests[i].b), std::wstring()); 267 gfx::SortedDisplayURL url2(GURL(tests[i].b), std::wstring());
267 EXPECT_EQ(tests[i].compare_result, url1.Compare(url2, collator.get())); 268 EXPECT_EQ(tests[i].compare_result, url1.Compare(url2, collator.get()));
268 EXPECT_EQ(-tests[i].compare_result, url2.Compare(url1, collator.get())); 269 EXPECT_EQ(-tests[i].compare_result, url2.Compare(url1, collator.get()));
269 } 270 }
270 } 271 }
OLDNEW
« no previous file with comments | « app/text_elider.cc ('k') | app/win_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698