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

Side by Side 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 unified diff | Download patch
OLDNEW
(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 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
21
22 // Test prettifying empty path.
23 FilePath unprettified;
24 FilePath prettified = path_util::PrettifyPath(unprettified);
25 EXPECT_EQ(unprettified, prettified);
26
27 // Test home directory ("~").
28 unprettified = base::GetHomeDir();
29 prettified = path_util::PrettifyPath(unprettified);
30 EXPECT_NE(unprettified, prettified);
31 EXPECT_EQ(FilePath(kHomeShortcut), prettified);
32
33 // Test with one layer ("~/foo").
34 unprettified = unprettified.AppendASCII("foo");
35 prettified = path_util::PrettifyPath(unprettified);
36 EXPECT_NE(unprettified, prettified);
37 EXPECT_EQ(FilePath(kHomeShortcut).AppendASCII("foo"), prettified);
38
39 // Test with two layers ("~/foo/bar").
40 unprettified = unprettified.AppendASCII("bar");
41 prettified = path_util::PrettifyPath(unprettified);
42 EXPECT_NE(unprettified, prettified);
43 EXPECT_EQ(
44 FilePath(kHomeShortcut).AppendASCII("foo").AppendASCII("bar"),
45 prettified);
46 }
47
48 } // namespace extensions
OLDNEW
« 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