Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 "testing/gtest/include/gtest/gtest.h" | |
| 8 | |
| 9 TEST(SafeBrowsingPathSanitizerTest, HomeDirectoryIsNotEmpty) { | |
| 10 safe_browsing::PathSanitizer path_sanitizer; | |
| 11 | |
| 12 ASSERT_FALSE(path_sanitizer.GetHomeDirectory().empty()); | |
| 13 } | |
| 14 | |
| 15 TEST(SafeBrowsingPathSanitizerTest, DontStripHomeDirectoryTest) { | |
| 16 // Test with path not in home directory | |
| 17 safe_browsing::PathSanitizer path_sanitizer; | |
| 18 | |
| 19 base::FilePath path( | |
| 20 FILE_PATH_LITERAL("C:\\path\\not\\in\\home\\directory\\test.dll")); | |
| 21 | |
| 22 path_sanitizer.StripHomeDirectory(&path); | |
| 23 | |
| 24 ASSERT_EQ(path.value(), | |
| 25 FILE_PATH_LITERAL("C:\\path\\not\\in\\home\\directory\\test.dll")); | |
| 26 } | |
| 27 | |
| 28 TEST(SafeBrowsingPathSanitizerTest, DoStripHomeDirectoryTest) { | |
| 29 // Test with path in home directory | |
| 30 safe_browsing::PathSanitizer path_sanitizer; | |
| 31 | |
| 32 base::FilePath path = path_sanitizer.GetHomeDirectory().Append( | |
| 33 FILE_PATH_LITERAL("\\path\\in\\home\\directory\\test.dll")); | |
|
mattm
2014/06/17 01:28:18
hm, why is the leading \ on the appended path ok?
pmonette_google.com
2014/06/17 17:48:22
Removed.
| |
| 34 | |
| 35 path_sanitizer.StripHomeDirectory(&path); | |
| 36 | |
| 37 ASSERT_EQ(path.value(), | |
| 38 FILE_PATH_LITERAL("~\\path\\in\\home\\directory\\test.dll")); | |
| 39 } | |
| OLD | NEW |