| 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.h" | 5 #include "chrome/browser/safe_browsing/download_feedback.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 "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 : file_task_runner_(content::BrowserThread::GetMessageLoopProxyForThread( | 103 : file_task_runner_(content::BrowserThread::GetMessageLoopProxyForThread( |
| 104 content::BrowserThread::FILE)), | 104 content::BrowserThread::FILE)), |
| 105 io_task_runner_(content::BrowserThread::GetMessageLoopProxyForThread( | 105 io_task_runner_(content::BrowserThread::GetMessageLoopProxyForThread( |
| 106 content::BrowserThread::IO)), | 106 content::BrowserThread::IO)), |
| 107 url_request_context_getter_( | 107 url_request_context_getter_( |
| 108 new net::TestURLRequestContextGetter(io_task_runner_)), | 108 new net::TestURLRequestContextGetter(io_task_runner_)), |
| 109 feedback_finish_called_(false) { | 109 feedback_finish_called_(false) { |
| 110 EXPECT_NE(io_task_runner_, file_task_runner_); | 110 EXPECT_NE(io_task_runner_, file_task_runner_); |
| 111 } | 111 } |
| 112 | 112 |
| 113 virtual void SetUp() override { | 113 void SetUp() override { |
| 114 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 114 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 115 upload_file_path_ = temp_dir_.path().AppendASCII("test file"); | 115 upload_file_path_ = temp_dir_.path().AppendASCII("test file"); |
| 116 upload_file_data_ = "data"; | 116 upload_file_data_ = "data"; |
| 117 ASSERT_EQ(static_cast<int>(upload_file_data_.size()), | 117 ASSERT_EQ(static_cast<int>(upload_file_data_.size()), |
| 118 base::WriteFile(upload_file_path_, upload_file_data_.data(), | 118 base::WriteFile(upload_file_path_, upload_file_data_.data(), |
| 119 upload_file_data_.size())); | 119 upload_file_data_.size())); |
| 120 TwoPhaseUploader::RegisterFactory(&two_phase_uploader_factory_); | 120 TwoPhaseUploader::RegisterFactory(&two_phase_uploader_factory_); |
| 121 } | 121 } |
| 122 | 122 |
| 123 virtual void TearDown() override { | 123 void TearDown() override { TwoPhaseUploader::RegisterFactory(NULL); } |
| 124 TwoPhaseUploader::RegisterFactory(NULL); | |
| 125 } | |
| 126 | 124 |
| 127 FakeUploader* uploader() const { | 125 FakeUploader* uploader() const { |
| 128 return two_phase_uploader_factory_.uploader_; | 126 return two_phase_uploader_factory_.uploader_; |
| 129 } | 127 } |
| 130 | 128 |
| 131 void FinishCallback(DownloadFeedback* feedback) { | 129 void FinishCallback(DownloadFeedback* feedback) { |
| 132 EXPECT_FALSE(feedback_finish_called_); | 130 EXPECT_FALSE(feedback_finish_called_); |
| 133 feedback_finish_called_ = true; | 131 feedback_finish_called_ = true; |
| 134 delete feedback; | 132 delete feedback; |
| 135 } | 133 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 EXPECT_TRUE(base::PathExists(upload_file_path_)); | 223 EXPECT_TRUE(base::PathExists(upload_file_path_)); |
| 226 | 224 |
| 227 delete feedback; | 225 delete feedback; |
| 228 EXPECT_FALSE(feedback_finish_called_); | 226 EXPECT_FALSE(feedback_finish_called_); |
| 229 | 227 |
| 230 base::RunLoop().RunUntilIdle(); | 228 base::RunLoop().RunUntilIdle(); |
| 231 EXPECT_FALSE(base::PathExists(upload_file_path_)); | 229 EXPECT_FALSE(base::PathExists(upload_file_path_)); |
| 232 } | 230 } |
| 233 | 231 |
| 234 } // namespace safe_browsing | 232 } // namespace safe_browsing |
| OLD | NEW |