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

Side by Side Diff: content/browser/download/base_file_win_unittest.cc

Issue 2381293002: misc files: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | content/browser/download/quarantine_win_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/download/base_file.h" 5 #include "content/browser/download/base_file.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "content/public/browser/download_interrupt_reasons.h" 9 #include "content/public/browser/download_interrupt_reasons.h"
10 #include "content/public/test/test_browser_thread_bundle.h" 10 #include "content/public/test/test_browser_thread_bundle.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 {"", "http://localhost/foo", false}, 42 {"", "http://localhost/foo", false},
43 {"file:///exists.txt", "", false}, 43 {"file:///exists.txt", "", false},
44 {"file:///exists.txt", "http://example.com", false}, 44 {"file:///exists.txt", "http://example.com", false},
45 {"file:///does-not-exist.txt", "", false}, 45 {"file:///does-not-exist.txt", "", false},
46 }; 46 };
47 47
48 content::TestBrowserThreadBundle threads; 48 content::TestBrowserThreadBundle threads;
49 base::ScopedTempDir target_directory; 49 base::ScopedTempDir target_directory;
50 ASSERT_TRUE(target_directory.CreateUniqueTempDir()); 50 ASSERT_TRUE(target_directory.CreateUniqueTempDir());
51 51
52 ASSERT_EQ(6, 52 ASSERT_EQ(
53 base::WriteFile(target_directory.path().AppendASCII("exists.txt"), 53 6, base::WriteFile(target_directory.GetPath().AppendASCII("exists.txt"),
54 "Exists", 6)); 54 "Exists", 6));
55 55
56 for (const auto& test_case : kTestCases) { 56 for (const auto& test_case : kTestCases) {
57 GURL url(test_case.url); 57 GURL url(test_case.url);
58 GURL referrer(test_case.referrer); 58 GURL referrer(test_case.referrer);
59 59
60 // Resolve file:// URLs relative to our temp directory. 60 // Resolve file:// URLs relative to our temp directory.
61 if (url.SchemeIsFile()) { 61 if (url.SchemeIsFile()) {
62 base::FilePath relative_path = 62 base::FilePath relative_path =
63 base::FilePath().AppendASCII(url.path().substr(1)); 63 base::FilePath().AppendASCII(url.path().substr(1));
64 url = 64 url = net::FilePathToFileURL(
65 net::FilePathToFileURL(target_directory.path().Append(relative_path)); 65 target_directory.GetPath().Append(relative_path));
66 } 66 }
67 67
68 SCOPED_TRACE(::testing::Message() << "Source URL: " << url.spec() 68 SCOPED_TRACE(::testing::Message() << "Source URL: " << url.spec()
69 << " Referrer: " << test_case.referrer); 69 << " Referrer: " << test_case.referrer);
70 70
71 BaseFile base_file((net::NetLogWithSource())); 71 BaseFile base_file((net::NetLogWithSource()));
72 ASSERT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE, 72 ASSERT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE,
73 base_file.Initialize(base::FilePath(), target_directory.path(), 73 base_file.Initialize(base::FilePath(), target_directory.GetPath(),
74 base::File(), 0, std::string(), 74 base::File(), 0, std::string(),
75 std::unique_ptr<crypto::SecureHash>())); 75 std::unique_ptr<crypto::SecureHash>()));
76 ASSERT_FALSE(base_file.full_path().empty()); 76 ASSERT_FALSE(base_file.full_path().empty());
77 ASSERT_EQ( 77 ASSERT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE,
78 DOWNLOAD_INTERRUPT_REASON_NONE, 78 base_file.Rename(
79 base_file.Rename(target_directory.path().AppendASCII("test_file.doc"))); 79 target_directory.GetPath().AppendASCII("test_file.doc")));
80 ASSERT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE, 80 ASSERT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE,
81 base_file.AnnotateWithSourceInformation( 81 base_file.AnnotateWithSourceInformation(
82 "7B2CEE7C-DC81-4160-86F1-9C968597118F", url, referrer)); 82 "7B2CEE7C-DC81-4160-86F1-9C968597118F", url, referrer));
83 base_file.Detach(); 83 base_file.Detach();
84 base_file.Finish(); 84 base_file.Finish();
85 85
86 base::FilePath path = base_file.full_path(); 86 base::FilePath path = base_file.full_path();
87 base::FilePath zone_identifier_stream(path.value() + 87 base::FilePath zone_identifier_stream(path.value() +
88 kZoneIdentifierStreamName); 88 kZoneIdentifierStreamName);
89 89
(...skipping 16 matching lines...) Expand all
106 << " Referrer:" << test_case.referrer 106 << " Referrer:" << test_case.referrer
107 << " Annotation:" << std::endl 107 << " Annotation:" << std::endl
108 << zone_identifier; 108 << zone_identifier;
109 } 109 }
110 } 110 }
111 base::DeleteFile(path, false); 111 base::DeleteFile(path, false);
112 } 112 }
113 } 113 }
114 114
115 } // namespace content 115 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/quarantine_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698