OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/test/test_file_util.h" | 8 #include "base/test/test_file_util.h" |
9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
10 #include "content/browser/byte_stream.h" | 10 #include "content/browser/byte_stream.h" |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 StrictMock<MockByteStreamReader>* input_stream_; | 295 StrictMock<MockByteStreamReader>* input_stream_; |
296 | 296 |
297 // Sink callback data for stream. | 297 // Sink callback data for stream. |
298 base::Closure sink_callback_; | 298 base::Closure sink_callback_; |
299 | 299 |
300 // Latest update sent to the observer. | 300 // Latest update sent to the observer. |
301 int64 bytes_; | 301 int64 bytes_; |
302 int64 bytes_per_sec_; | 302 int64 bytes_per_sec_; |
303 std::string hash_state_; | 303 std::string hash_state_; |
304 | 304 |
305 MessageLoop loop_; | 305 base::MessageLoop loop_; |
306 | 306 |
307 private: | 307 private: |
308 void SetRenameResult(bool* called_p, | 308 void SetRenameResult(bool* called_p, |
309 DownloadInterruptReason* reason_p, | 309 DownloadInterruptReason* reason_p, |
310 base::FilePath* result_path_p, | 310 base::FilePath* result_path_p, |
311 DownloadInterruptReason reason, | 311 DownloadInterruptReason reason, |
312 const base::FilePath& result_path) { | 312 const base::FilePath& result_path) { |
313 if (called_p) | 313 if (called_p) |
314 *called_p = true; | 314 *called_p = true; |
315 if (reason_p) | 315 if (reason_p) |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 | 585 |
586 // Send some data, wait 3/4s of a second, run the message loop, and | 586 // Send some data, wait 3/4s of a second, run the message loop, and |
587 // confirm the values the observer received are correct. | 587 // confirm the values the observer received are correct. |
588 TEST_F(DownloadFileTest, ConfirmUpdate) { | 588 TEST_F(DownloadFileTest, ConfirmUpdate) { |
589 CreateDownloadFile(0, true); | 589 CreateDownloadFile(0, true); |
590 | 590 |
591 const char* chunks1[] = { kTestData1, kTestData2 }; | 591 const char* chunks1[] = { kTestData1, kTestData2 }; |
592 AppendDataToFile(chunks1, 2); | 592 AppendDataToFile(chunks1, 2); |
593 | 593 |
594 // Run the message loops for 750ms and check for results. | 594 // Run the message loops for 750ms and check for results. |
595 loop_.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), | 595 loop_.PostDelayedTask(FROM_HERE, |
596 base::TimeDelta::FromMilliseconds(750)); | 596 base::MessageLoop::QuitClosure(), |
| 597 base::TimeDelta::FromMilliseconds(750)); |
597 loop_.Run(); | 598 loop_.Run(); |
598 | 599 |
599 EXPECT_EQ(static_cast<int64>(strlen(kTestData1) + strlen(kTestData2)), | 600 EXPECT_EQ(static_cast<int64>(strlen(kTestData1) + strlen(kTestData2)), |
600 bytes_); | 601 bytes_); |
601 EXPECT_EQ(download_file_->GetHashState(), hash_state_); | 602 EXPECT_EQ(download_file_->GetHashState(), hash_state_); |
602 | 603 |
603 FinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, true); | 604 FinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, true); |
604 DestroyDownloadFile(0); | 605 DestroyDownloadFile(0); |
605 } | 606 } |
606 | 607 |
607 } // namespace content | 608 } // namespace content |
OLD | NEW |