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

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: Enhanced test 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..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
« 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