Chromium Code Reviews| Index: chrome/browser/extensions/extension_path_util_unittest.cc |
| diff --git a/chrome/browser/extensions/extension_path_util_unittest.cc b/chrome/browser/extensions/extension_path_util_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1c6417149443a856c7a8806845d38caab18045e3 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/extension_path_util_unittest.cc |
| @@ -0,0 +1,46 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/extensions/path_util.h" |
| + |
| +#include "base/file_util.h" |
| +#include "base/files/file_path.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +using base::FilePath; |
| + |
| +namespace extensions { |
| + |
| +// Basic unittest for path_util::PrettifyPath in |
| +// chrome/browser/extensions/path_util.cc. |
| +// For legacy reasons, it's tested more in |
| +// FileSystemApiTest.FileSystemApiGetDisplayPathPrettify. |
| +TEST(ExtensionPathUtilTest, BasicPrettifyPathTest) { |
| + // Test prettifying empty path. |
| + 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.
|
| + FilePath prettified = path_util::PrettifyPath(actual); |
| + 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.
|
| + |
| + // Test home directory ("~"). |
| + actual = base::GetHomeDir(); |
| + prettified = path_util::PrettifyPath(actual); |
| + ASSERT_NE(actual, prettified); |
| + 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.
|
| + |
| + // Test with one layer ("~/foo"). |
| + actual = actual.AppendASCII("foo"); |
| + prettified = path_util::PrettifyPath(actual); |
| + ASSERT_NE(actual, prettified); |
| + ASSERT_EQ(FilePath(FILE_PATH_LITERAL("~")).AppendASCII("foo"), prettified); |
| + |
| + // Test with two layers ("~/foo/bar"). |
| + actual = actual.AppendASCII("bar"); |
| + prettified = path_util::PrettifyPath(actual); |
| + ASSERT_NE(actual, prettified); |
| + ASSERT_EQ( |
| + FilePath(FILE_PATH_LITERAL("~")).AppendASCII("foo").AppendASCII("bar"), |
| + prettified); |
| +} |
| + |
| +} // namespace extensions |