Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/extensions/path_util.h" | |
| 6 | |
| 7 #include "base/file_util.h" | |
| 8 #include "base/files/file_path.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 | |
| 11 using base::FilePath; | |
| 12 | |
| 13 namespace extensions { | |
| 14 | |
| 15 // Basic unittest for path_util::PrettifyPath in | |
| 16 // chrome/browser/extensions/path_util.cc. | |
| 17 // For legacy reasons, it's tested more in | |
| 18 // FileSystemApiTest.FileSystemApiGetDisplayPathPrettify. | |
| 19 TEST(ExtensionPathUtilTest, BasicPrettifyPathTest) { | |
| 20 // Test prettifying empty path. | |
| 21 FilePath actual; | |
|
Devlin
2014/08/06 23:35:56
"actual" is a bit misleading, since they are both
gpdavis
2014/08/07 01:20:06
Done.
| |
| 22 FilePath prettified = path_util::PrettifyPath(actual); | |
| 23 ASSERT_EQ(actual, prettified); | |
|
Devlin
2014/08/06 23:35:56
This can be an EXPECT, as can all of the others.
gpdavis
2014/08/07 01:20:06
Done.
| |
| 24 | |
| 25 // Test home directory ("~"). | |
| 26 actual = base::GetHomeDir(); | |
| 27 prettified = path_util::PrettifyPath(actual); | |
| 28 ASSERT_NE(actual, prettified); | |
| 29 ASSERT_EQ(FilePath(FILE_PATH_LITERAL("~")), prettified); | |
|
Devlin
2014/08/06 23:35:55
Save the FILE_PATH_LITERAL.
gpdavis
2014/08/07 01:20:06
Done.
| |
| 30 | |
| 31 // Test with one layer ("~/foo"). | |
| 32 actual = actual.AppendASCII("foo"); | |
| 33 prettified = path_util::PrettifyPath(actual); | |
| 34 ASSERT_NE(actual, prettified); | |
| 35 ASSERT_EQ(FilePath(FILE_PATH_LITERAL("~")).AppendASCII("foo"), prettified); | |
| 36 | |
| 37 // Test with two layers ("~/foo/bar"). | |
| 38 actual = actual.AppendASCII("bar"); | |
| 39 prettified = path_util::PrettifyPath(actual); | |
| 40 ASSERT_NE(actual, prettified); | |
| 41 ASSERT_EQ( | |
| 42 FilePath(FILE_PATH_LITERAL("~")).AppendASCII("foo").AppendASCII("bar"), | |
| 43 prettified); | |
| 44 } | |
| 45 | |
| 46 } // namespace extensions | |
| OLD | NEW |