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

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

Issue 14335017: content: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « content/browser/download/download_browsertest.cc ('k') | content/browser/download/download_id_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698