diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-24 02:59:14 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-24 02:59:14 +0000 |
commit | c4eaca55f090aa2d3b5b61b604f456b7dbcfd99e (patch) | |
tree | 6ed8985fe2c88d2892d5e3088212736072085cf0 /chrome/common/gfx/text_elider_unittest.cc | |
parent | 40ecd8a10372b6be9a2cb830dd1fe004b51ca2ec (diff) | |
download | chromium_src-c4eaca55f090aa2d3b5b61b604f456b7dbcfd99e.zip chromium_src-c4eaca55f090aa2d3b5b61b604f456b7dbcfd99e.tar.gz chromium_src-c4eaca55f090aa2d3b5b61b604f456b7dbcfd99e.tar.bz2 |
Remove deprecated file_util::GetFilenameWithoutExtensionFromPath(), also convert ElideFilename() to take a FilePath.
Review URL: http://codereview.chromium.org/92060
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14409 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/gfx/text_elider_unittest.cc')
-rw-r--r-- | chrome/common/gfx/text_elider_unittest.cc | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/chrome/common/gfx/text_elider_unittest.cc b/chrome/common/gfx/text_elider_unittest.cc index 06b9755..c47e0bd 100644 --- a/chrome/common/gfx/text_elider_unittest.cc +++ b/chrome/common/gfx/text_elider_unittest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/file_path.h" #include "base/string_util.h" #include "chrome/common/gfx/chrome_font.h" #include "chrome/common/gfx/text_elider.h" @@ -19,6 +20,11 @@ struct Testcase { const std::wstring output; }; +struct FileTestcase { + const FilePath::StringType input; + const std::wstring output; +}; + struct WideTestcase { const std::wstring input; const std::wstring output; @@ -138,41 +144,41 @@ TEST(TextEliderTest, TestFileURLEliding) { TEST(TextEliderTest, TestFilenameEliding) { const std::wstring kEllipsisStr(kEllipsis); -// TODO(port): this should probably use FilePath::kPathSeparators[0], but we -// will change this unit test after porting text elider to string16/FilePath, -// so it's not worth using FilePath stuff at the moment. -#if defined(OS_POSIX) - const std::wstring kPathSeparator(L"/"); -#elif defined(OS_WIN) - const std::wstring kPathSeparator(L"\\"); -#endif - - WideTestcase testcases[] = { - {L"", L""}, - {L".", L"."}, - {L"filename.exe", L"filename.exe"}, - {L".longext", L".longext"}, - {L"pie", L"pie"}, - {L"c:" + kPathSeparator + L"path" + kPathSeparator + L"filename.pie", - L"filename.pie"}, - {L"c:" + kPathSeparator + L"path" + kPathSeparator + L"longfilename.pie", - L"long" + kEllipsisStr + L".pie"}, - {L"http://path.com/filename.pie", L"filename.pie"}, - {L"http://path.com/longfilename.pie", L"long" + kEllipsisStr + L".pie"}, - {L"piesmashingtacularpants", L"pie" + kEllipsisStr}, - {L".piesmashingtacularpants", L".pie" + kEllipsisStr}, - {L"cheese.", L"cheese."}, - {L"file name.longext", L"file" + kEllipsisStr + L".longext"}, - {L"fil ename.longext", L"fil " + kEllipsisStr + L".longext"}, - {L"filename.longext", L"file" + kEllipsisStr + L".longext"}, - {L"filename.middleext.longext", - L"filename.mid" + kEllipsisStr + L".longext"} + const FilePath::StringType kPathSeparator = + FilePath::StringType().append(1, FilePath::kSeparators[0]); + + FileTestcase testcases[] = { + {FILE_PATH_LITERAL(""), L""}, + {FILE_PATH_LITERAL("."), L"."}, + {FILE_PATH_LITERAL("filename.exe"), L"filename.exe"}, + {FILE_PATH_LITERAL(".longext"), L".longext"}, + {FILE_PATH_LITERAL("pie"), L"pie"}, + {FILE_PATH_LITERAL("c:") + kPathSeparator + FILE_PATH_LITERAL("path") + + kPathSeparator + FILE_PATH_LITERAL("filename.pie"), + L"filename.pie"}, + {FILE_PATH_LITERAL("c:") + kPathSeparator + FILE_PATH_LITERAL("path") + + kPathSeparator + FILE_PATH_LITERAL("longfilename.pie"), + L"long" + kEllipsisStr + L".pie"}, + {FILE_PATH_LITERAL("http://path.com/filename.pie"), L"filename.pie"}, + {FILE_PATH_LITERAL("http://path.com/longfilename.pie"), + L"long" + kEllipsisStr + L".pie"}, + {FILE_PATH_LITERAL("piesmashingtacularpants"), L"pie" + kEllipsisStr}, + {FILE_PATH_LITERAL(".piesmashingtacularpants"), L".pie" + kEllipsisStr}, + {FILE_PATH_LITERAL("cheese."), L"cheese."}, + {FILE_PATH_LITERAL("file name.longext"), + L"file" + kEllipsisStr + L".longext"}, + {FILE_PATH_LITERAL("fil ename.longext"), + L"fil " + kEllipsisStr + L".longext"}, + {FILE_PATH_LITERAL("filename.longext"), + L"file" + kEllipsisStr + L".longext"}, + {FILE_PATH_LITERAL("filename.middleext.longext"), + L"filename.mid" + kEllipsisStr + L".longext"} }; static const ChromeFont font; for (size_t i = 0; i < arraysize(testcases); ++i) { - const std::wstring filename(testcases[i].input); - EXPECT_EQ(testcases[i].output, ElideFilename(filename, + FilePath filepath(testcases[i].input); + EXPECT_EQ(testcases[i].output, ElideFilename(filepath, font, font.GetStringWidth(testcases[i].output))); } |