OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/safe_browsing/download_feedback_service.h" | 5 #include "chrome/browser/safe_browsing/download_feedback_service.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 public: | 130 public: |
131 DownloadFeedbackServiceTest() | 131 DownloadFeedbackServiceTest() |
132 : file_task_runner_(content::BrowserThread::GetMessageLoopProxyForThread( | 132 : file_task_runner_(content::BrowserThread::GetMessageLoopProxyForThread( |
133 content::BrowserThread::FILE)), | 133 content::BrowserThread::FILE)), |
134 io_task_runner_(content::BrowserThread::GetMessageLoopProxyForThread( | 134 io_task_runner_(content::BrowserThread::GetMessageLoopProxyForThread( |
135 content::BrowserThread::IO)), | 135 content::BrowserThread::IO)), |
136 request_context_getter_( | 136 request_context_getter_( |
137 new net::TestURLRequestContextGetter(io_task_runner_)) { | 137 new net::TestURLRequestContextGetter(io_task_runner_)) { |
138 } | 138 } |
139 | 139 |
140 virtual void SetUp() override { | 140 void SetUp() override { |
141 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 141 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
142 DownloadFeedback::RegisterFactory(&download_feedback_factory_); | 142 DownloadFeedback::RegisterFactory(&download_feedback_factory_); |
143 } | 143 } |
144 | 144 |
145 virtual void TearDown() override { | 145 void TearDown() override { DownloadFeedback::RegisterFactory(NULL); } |
146 DownloadFeedback::RegisterFactory(NULL); | |
147 } | |
148 | 146 |
149 base::FilePath CreateTestFile(int n) const { | 147 base::FilePath CreateTestFile(int n) const { |
150 base::FilePath upload_file_path( | 148 base::FilePath upload_file_path( |
151 temp_dir_.path().AppendASCII("test file " + base::IntToString(n))); | 149 temp_dir_.path().AppendASCII("test file " + base::IntToString(n))); |
152 const std::string upload_file_data = "data"; | 150 const std::string upload_file_data = "data"; |
153 int wrote = base::WriteFile( | 151 int wrote = base::WriteFile( |
154 upload_file_path, upload_file_data.data(), upload_file_data.size()); | 152 upload_file_path, upload_file_data.data(), upload_file_data.size()); |
155 EXPECT_EQ(static_cast<int>(upload_file_data.size()), wrote); | 153 EXPECT_EQ(static_cast<int>(upload_file_data.size()), wrote); |
156 return upload_file_path; | 154 return upload_file_path; |
157 } | 155 } |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 // was deleted. | 362 // was deleted. |
365 EXPECT_FALSE(base::PathExists(file_path[2])); | 363 EXPECT_FALSE(base::PathExists(file_path[2])); |
366 | 364 |
367 // These files should still exist since the FakeDownloadFeedback does not | 365 // These files should still exist since the FakeDownloadFeedback does not |
368 // delete them. | 366 // delete them. |
369 EXPECT_TRUE(base::PathExists(file_path[0])); | 367 EXPECT_TRUE(base::PathExists(file_path[0])); |
370 EXPECT_TRUE(base::PathExists(file_path[1])); | 368 EXPECT_TRUE(base::PathExists(file_path[1])); |
371 } | 369 } |
372 | 370 |
373 } // namespace safe_browsing | 371 } // namespace safe_browsing |
OLD | NEW |