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..a4fd75eb128e8a8f9541c0a27b0cd2f0d84eb6e1 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/extension_path_util_unittest.cc |
| @@ -0,0 +1,48 @@ |
| +// 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) { |
| + const FilePath::CharType kHomeShortcut[] = FILE_PATH_LITERAL("~"); |
|
gpdavis
2014/08/07 01:20:06
Is this okay to put here, or should it go up in an
Devlin
2014/08/07 15:53:45
It's fine here, but it doesn't really need to be a
|
| + |
| + // Test prettifying empty path. |
| + FilePath unprettified; |
| + FilePath prettified = path_util::PrettifyPath(unprettified); |
| + EXPECT_EQ(unprettified, prettified); |
| + |
| + // Test home directory ("~"). |
| + unprettified = base::GetHomeDir(); |
| + prettified = path_util::PrettifyPath(unprettified); |
| + EXPECT_NE(unprettified, prettified); |
| + EXPECT_EQ(FilePath(kHomeShortcut), prettified); |
| + |
| + // Test with one layer ("~/foo"). |
| + unprettified = unprettified.AppendASCII("foo"); |
| + prettified = path_util::PrettifyPath(unprettified); |
| + EXPECT_NE(unprettified, prettified); |
| + EXPECT_EQ(FilePath(kHomeShortcut).AppendASCII("foo"), prettified); |
| + |
| + // Test with two layers ("~/foo/bar"). |
| + unprettified = unprettified.AppendASCII("bar"); |
| + prettified = path_util::PrettifyPath(unprettified); |
| + EXPECT_NE(unprettified, prettified); |
| + EXPECT_EQ( |
| + FilePath(kHomeShortcut).AppendASCII("foo").AppendASCII("bar"), |
| + prettified); |
| +} |
| + |
| +} // namespace extensions |