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

Unified Diff: chrome/browser/extensions/extension_path_util_unittest.cc

Issue 439873002: Check for empty paths in path_util (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor changes Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/path_util.h » ('j') | chrome/browser/extensions/path_util.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | chrome/browser/extensions/path_util.h » ('j') | chrome/browser/extensions/path_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698