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

Side by Side Diff: chrome/browser/safe_browsing/path_sanitizer_unittest.cc

Issue 323953002: Support for recording registered LSPs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@grt
Patch Set: Sync and resolve conflic with trunk Created 6 years, 6 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
« no previous file with comments | « chrome/browser/safe_browsing/path_sanitizer.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/safe_browsing/path_sanitizer.h"
6
7 #include <vector>
8
9 #include "base/logging.h"
10 #include "base/path_service.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace {
14
15 // Returns the root directory with a trailing separator. Works on all platforms.
16 base::FilePath GetRootDirectory() {
17 base::FilePath dir_temp;
18 if (!PathService::Get(base::DIR_TEMP, &dir_temp))
19 NOTREACHED();
20
21 std::vector<base::FilePath::StringType> components;
22 dir_temp.GetComponents(&components);
23
24 return base::FilePath(components[0]).AsEndingWithSeparator();
25 }
26
27 } // namespace
28
29 TEST(SafeBrowsingPathSanitizerTest, HomeDirectoryIsNotEmpty) {
30 safe_browsing::PathSanitizer path_sanitizer;
31
32 ASSERT_FALSE(path_sanitizer.GetHomeDirectory().empty());
33 }
34
35 TEST(SafeBrowsingPathSanitizerTest, DontStripHomeDirectoryTest) {
36 // Test with path not in home directory.
37 base::FilePath path =
38 GetRootDirectory().Append(FILE_PATH_LITERAL("not_in_home_directory.ext"));
39 base::FilePath path_expected = path;
40
41 safe_browsing::PathSanitizer path_sanitizer;
42 path_sanitizer.StripHomeDirectory(&path);
43
44 ASSERT_EQ(path.value(), path_expected.value());
45 }
46
47 TEST(SafeBrowsingPathSanitizerTest, DoStripHomeDirectoryTest) {
48 // Test with path in home directory.
49 safe_browsing::PathSanitizer path_sanitizer;
50
51 base::FilePath path = path_sanitizer.GetHomeDirectory().Append(
52 FILE_PATH_LITERAL("in_home_directory.ext"));
53 base::FilePath path_expected = base::FilePath(FILE_PATH_LITERAL("~")).Append(
54 FILE_PATH_LITERAL("in_home_directory.ext"));
55
56 path_sanitizer.StripHomeDirectory(&path);
57
58 ASSERT_EQ(path.value(), path_expected.value());
59 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/path_sanitizer.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698