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

Side by Side Diff: ui/base/text/text_elider_unittest.cc

Issue 12217101: Replace FilePath with base::FilePath in some more top level directories. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | « ui/base/text/text_elider.cc ('k') | ui/base/ui_base_paths.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) 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 // Unit tests for eliding and formatting utility functions. 5 // Unit tests for eliding and formatting utility functions.
6 6
7 #include "ui/base/text/text_elider.h" 7 #include "ui/base/text/text_elider.h"
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "ui/gfx/font.h" 16 #include "ui/gfx/font.h"
17 17
18 namespace ui { 18 namespace ui {
19 19
20 namespace { 20 namespace {
21 21
22 struct Testcase { 22 struct Testcase {
23 const std::string input; 23 const std::string input;
24 const std::string output; 24 const std::string output;
25 }; 25 };
26 26
27 struct FileTestcase { 27 struct FileTestcase {
28 const FilePath::StringType input; 28 const base::FilePath::StringType input;
29 const std::string output; 29 const std::string output;
30 }; 30 };
31 31
32 struct UTF16Testcase { 32 struct UTF16Testcase {
33 const string16 input; 33 const string16 input;
34 const string16 output; 34 const string16 output;
35 }; 35 };
36 36
37 struct TestData { 37 struct TestData {
38 const std::string a; 38 const std::string a;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 256
257 // TODO(ios): Complex eliding is off by one for some of those tests on iOS. 257 // TODO(ios): Complex eliding is off by one for some of those tests on iOS.
258 // See crbug.com/154019 258 // See crbug.com/154019
259 #if defined(OS_IOS) 259 #if defined(OS_IOS)
260 #define MAYBE_TestFilenameEliding DISABLED_TestFilenameEliding 260 #define MAYBE_TestFilenameEliding DISABLED_TestFilenameEliding
261 #else 261 #else
262 #define MAYBE_TestFilenameEliding TestFilenameEliding 262 #define MAYBE_TestFilenameEliding TestFilenameEliding
263 #endif 263 #endif
264 TEST(TextEliderTest, MAYBE_TestFilenameEliding) { 264 TEST(TextEliderTest, MAYBE_TestFilenameEliding) {
265 const std::string kEllipsisStr(kEllipsis); 265 const std::string kEllipsisStr(kEllipsis);
266 const FilePath::StringType kPathSeparator = 266 const base::FilePath::StringType kPathSeparator =
267 FilePath::StringType().append(1, FilePath::kSeparators[0]); 267 base::FilePath::StringType().append(1, base::FilePath::kSeparators[0]);
268 268
269 FileTestcase testcases[] = { 269 FileTestcase testcases[] = {
270 {FILE_PATH_LITERAL(""), ""}, 270 {FILE_PATH_LITERAL(""), ""},
271 {FILE_PATH_LITERAL("."), "."}, 271 {FILE_PATH_LITERAL("."), "."},
272 {FILE_PATH_LITERAL("filename.exe"), "filename.exe"}, 272 {FILE_PATH_LITERAL("filename.exe"), "filename.exe"},
273 {FILE_PATH_LITERAL(".longext"), ".longext"}, 273 {FILE_PATH_LITERAL(".longext"), ".longext"},
274 {FILE_PATH_LITERAL("pie"), "pie"}, 274 {FILE_PATH_LITERAL("pie"), "pie"},
275 {FILE_PATH_LITERAL("c:") + kPathSeparator + FILE_PATH_LITERAL("path") + 275 {FILE_PATH_LITERAL("c:") + kPathSeparator + FILE_PATH_LITERAL("path") +
276 kPathSeparator + FILE_PATH_LITERAL("filename.pie"), 276 kPathSeparator + FILE_PATH_LITERAL("filename.pie"),
277 "filename.pie"}, 277 "filename.pie"},
(...skipping 17 matching lines...) Expand all
295 {FILE_PATH_LITERAL("filename.superduperextremelylongext"), 295 {FILE_PATH_LITERAL("filename.superduperextremelylongext"),
296 "filename.sup" + kEllipsisStr + "emelylongext"}, 296 "filename.sup" + kEllipsisStr + "emelylongext"},
297 {FILE_PATH_LITERAL("filenamereallylongtext.superduperextremelylongext"), 297 {FILE_PATH_LITERAL("filenamereallylongtext.superduperextremelylongext"),
298 "filenamereall" + kEllipsisStr + "emelylongext"}, 298 "filenamereall" + kEllipsisStr + "emelylongext"},
299 {FILE_PATH_LITERAL("file.name.really.long.text.superduperextremelylongext"), 299 {FILE_PATH_LITERAL("file.name.really.long.text.superduperextremelylongext"),
300 "file.name.re" + kEllipsisStr + "emelylongext"} 300 "file.name.re" + kEllipsisStr + "emelylongext"}
301 }; 301 };
302 302
303 static const gfx::Font font; 303 static const gfx::Font font;
304 for (size_t i = 0; i < arraysize(testcases); ++i) { 304 for (size_t i = 0; i < arraysize(testcases); ++i) {
305 FilePath filepath(testcases[i].input); 305 base::FilePath filepath(testcases[i].input);
306 string16 expected = UTF8ToUTF16(testcases[i].output); 306 string16 expected = UTF8ToUTF16(testcases[i].output);
307 expected = base::i18n::GetDisplayStringInLTRDirectionality(expected); 307 expected = base::i18n::GetDisplayStringInLTRDirectionality(expected);
308 EXPECT_EQ(expected, ElideFilename(filepath, 308 EXPECT_EQ(expected, ElideFilename(filepath,
309 font, 309 font,
310 font.GetStringWidth(UTF8ToUTF16(testcases[i].output)))); 310 font.GetStringWidth(UTF8ToUTF16(testcases[i].output))));
311 } 311 }
312 } 312 }
313 313
314 TEST(TextEliderTest, ElideTextTruncate) { 314 TEST(TextEliderTest, ElideTextTruncate) {
315 const gfx::Font font; 315 const gfx::Font font;
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 889
890 // Test adds ... at right spot when there is not enough room to break at a 890 // Test adds ... at right spot when there is not enough room to break at a
891 // word boundary. 891 // word boundary.
892 EXPECT_EQ(L"foooooey\x2026", UTF16ToWide(TruncateString(string, 11))); 892 EXPECT_EQ(L"foooooey\x2026", UTF16ToWide(TruncateString(string, 11)));
893 893
894 // Test completely truncates string if break is on initial whitespace. 894 // Test completely truncates string if break is on initial whitespace.
895 EXPECT_EQ(L"\x2026", UTF16ToWide(TruncateString(ASCIIToUTF16(" "), 2))); 895 EXPECT_EQ(L"\x2026", UTF16ToWide(TruncateString(ASCIIToUTF16(" "), 2)));
896 } 896 }
897 897
898 } // namespace ui 898 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/text/text_elider.cc ('k') | ui/base/ui_base_paths.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698