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

Side by Side Diff: chrome/browser/download/download_manager_unittest.cc

Issue 7646025: Detect file system errors during downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed illegal include from content. Created 9 years, 3 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
« no previous file with comments | « no previous file | content/browser/download/base_file.h » ('j') | net/base/mock_file_stream.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 5 #include <string>
6 #include <set> 6 #include <set>
7 7
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/i18n/number_formatting.h" 9 #include "base/i18n/number_formatting.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/test/base/testing_profile.h" 24 #include "chrome/test/base/testing_profile.h"
25 #include "content/browser/browser_thread.h" 25 #include "content/browser/browser_thread.h"
26 #include "content/browser/download/download_create_info.h" 26 #include "content/browser/download/download_create_info.h"
27 #include "content/browser/download/download_file.h" 27 #include "content/browser/download/download_file.h"
28 #include "content/browser/download/download_file_manager.h" 28 #include "content/browser/download/download_file_manager.h"
29 #include "content/browser/download/download_item.h" 29 #include "content/browser/download/download_item.h"
30 #include "content/browser/download/download_manager.h" 30 #include "content/browser/download/download_manager.h"
31 #include "content/browser/download/download_status_updater.h" 31 #include "content/browser/download/download_status_updater.h"
32 #include "content/browser/download/mock_download_manager.h" 32 #include "content/browser/download/mock_download_manager.h"
33 #include "grit/generated_resources.h" 33 #include "grit/generated_resources.h"
34 #include "net/base/io_buffer.h"
35 #include "net/base/mock_file_stream.h"
34 #include "testing/gmock/include/gmock/gmock.h" 36 #include "testing/gmock/include/gmock/gmock.h"
35 #include "testing/gmock_mutant.h" 37 #include "testing/gmock_mutant.h"
36 #include "testing/gtest/include/gtest/gtest.h" 38 #include "testing/gtest/include/gtest/gtest.h"
37 #include "ui/base/l10n/l10n_util.h" 39 #include "ui/base/l10n/l10n_util.h"
38 #include "ui/base/text/bytes_formatting.h" 40 #include "ui/base/text/bytes_formatting.h"
39 41
40 class DownloadManagerTest : public TestingBrowserProcessTest { 42 class DownloadManagerTest : public TestingBrowserProcessTest {
41 public: 43 public:
42 static const char* kTestData; 44 static const char* kTestData;
43 static const size_t kTestDataLen; 45 static const size_t kTestDataLen;
(...skipping 17 matching lines...) Expand all
61 download_manager_ = NULL; 63 download_manager_ = NULL;
62 download_manager_delegate_ = NULL; 64 download_manager_delegate_ = NULL;
63 profile_.reset(NULL); 65 profile_.reset(NULL);
64 message_loop_.RunAllPending(); 66 message_loop_.RunAllPending();
65 } 67 }
66 68
67 void AddDownloadToFileManager(int id, DownloadFile* download_file) { 69 void AddDownloadToFileManager(int id, DownloadFile* download_file) {
68 file_manager()->downloads_[id] = download_file; 70 file_manager()->downloads_[id] = download_file;
69 } 71 }
70 72
71 void OnAllDataSaved(int32 download_id, int64 size, const std::string& hash) { 73 void OnResponseCompleted(int32 download_id, int64 size,
72 download_manager_->OnAllDataSaved(download_id, size, hash); 74 const std::string& hash) {
75 download_manager_->OnResponseCompleted(download_id, size, hash);
73 } 76 }
74 77
75 void FileSelected(const FilePath& path, void* params) { 78 void FileSelected(const FilePath& path, void* params) {
76 download_manager_->FileSelected(path, params); 79 download_manager_->FileSelected(path, params);
77 } 80 }
78 81
79 void ContinueDownloadWithPath(DownloadItem* download, const FilePath& path) { 82 void ContinueDownloadWithPath(DownloadItem* download, const FilePath& path) {
80 download_manager_->ContinueDownloadWithPath(download, path); 83 download_manager_->ContinueDownloadWithPath(download, path);
81 } 84 }
82 85
86 void UpdateData(int32 id, const void* data, size_t length) {
87 // We are passing ownership of this buffer to the download file manager.
88 net::IOBuffer* io_buffer = new net::IOBuffer(length);
89 // We need |AddRef()| because io_buffer is not a |scoped_refptr|, and we
90 // will do a |Release()| in |UpdateDownload()|.
91 io_buffer->AddRef();
92 memcpy(io_buffer->data(), data, length);
93
94 {
95 base::AutoLock auto_lock(download_buffer_.lock);
96
97 download_buffer_.contents.push_back(
98 std::make_pair(io_buffer, length));
99 }
100
101 BrowserThread::PostTask(
102 BrowserThread::FILE, FROM_HERE,
103 NewRunnableMethod(file_manager_.get(),
104 &DownloadFileManager::UpdateDownload,
105 id,
106 &download_buffer_));
107
108 message_loop_.RunAllPending();
109 }
110
83 void OnDownloadError(int32 download_id, int64 size, int os_error) { 111 void OnDownloadError(int32 download_id, int64 size, int os_error) {
84 download_manager_->OnDownloadError(download_id, size, os_error); 112 download_manager_->OnDownloadError(download_id, size, os_error);
85 } 113 }
86 114
87 // Get the download item with ID |id|. 115 // Get the download item with ID |id|.
88 DownloadItem* GetActiveDownloadItem(int32 id) { 116 DownloadItem* GetActiveDownloadItem(int32 id) {
89 if (ContainsKey(download_manager_->active_downloads_, id)) 117 if (ContainsKey(download_manager_->active_downloads_, id))
90 return download_manager_->active_downloads_[id]; 118 return download_manager_->active_downloads_[id];
91 return NULL; 119 return NULL;
92 } 120 }
93 121
94 protected: 122 protected:
95 DownloadStatusUpdater download_status_updater_; 123 DownloadStatusUpdater download_status_updater_;
96 scoped_ptr<TestingProfile> profile_; 124 scoped_ptr<TestingProfile> profile_;
97 scoped_refptr<ChromeDownloadManagerDelegate> download_manager_delegate_; 125 scoped_refptr<ChromeDownloadManagerDelegate> download_manager_delegate_;
98 scoped_refptr<DownloadManager> download_manager_; 126 scoped_refptr<DownloadManager> download_manager_;
99 scoped_refptr<DownloadFileManager> file_manager_; 127 scoped_refptr<DownloadFileManager> file_manager_;
100 MessageLoopForUI message_loop_; 128 MessageLoopForUI message_loop_;
101 BrowserThread ui_thread_; 129 BrowserThread ui_thread_;
102 BrowserThread file_thread_; 130 BrowserThread file_thread_;
131 DownloadBuffer download_buffer_;
103 132
104 DownloadFileManager* file_manager() { 133 DownloadFileManager* file_manager() {
105 if (!file_manager_) { 134 if (!file_manager_) {
106 file_manager_ = new DownloadFileManager(NULL); 135 file_manager_ = new DownloadFileManager(NULL);
107 download_manager_->file_manager_ = file_manager_; 136 download_manager_->file_manager_ = file_manager_;
108 } 137 }
109 return file_manager_; 138 return file_manager_;
110 } 139 }
111 140
112 // Make sure download item |id| was set with correct safety state for 141 // Make sure download item |id| was set with correct safety state for
113 // given |is_dangerous_file| and |is_dangerous_url|. 142 // given |is_dangerous_file| and |is_dangerous_url|.
114 bool VerifySafetyState(bool is_dangerous_file, 143 bool VerifySafetyState(bool is_dangerous_file,
115 bool is_dangerous_url, 144 bool is_dangerous_url,
116 int id) { 145 int id) {
117 DownloadItem::SafetyState safety_state = 146 DownloadItem::SafetyState safety_state =
118 download_manager_->GetDownloadItem(id)->safety_state(); 147 download_manager_->GetDownloadItem(id)->safety_state();
119 return (is_dangerous_file || is_dangerous_url) ? 148 return (is_dangerous_file || is_dangerous_url) ?
120 safety_state != DownloadItem::SAFE : safety_state == DownloadItem::SAFE; 149 safety_state != DownloadItem::SAFE : safety_state == DownloadItem::SAFE;
121 } 150 }
122 151
123 DISALLOW_COPY_AND_ASSIGN(DownloadManagerTest); 152 DISALLOW_COPY_AND_ASSIGN(DownloadManagerTest);
124 }; 153 };
125 154
126 const char* DownloadManagerTest::kTestData = "a;sdlfalsdfjalsdkfjad"; 155 const char* DownloadManagerTest::kTestData = "a;sdlfalsdfjalsdkfjad";
127 const size_t DownloadManagerTest::kTestDataLen = 156 const size_t DownloadManagerTest::kTestDataLen =
128 strlen(DownloadManagerTest::kTestData); 157 strlen(DownloadManagerTest::kTestData);
129 158
159 // A DownloadFile that we can inject errors into. Uses MockFileStream.
160 // Note: This can't be in an anonymous namespace because it must be declared
161 // as a friend of |DownloadFile| in order to access its private members.
162 class DownloadFileWithMockStream : public DownloadFile {
163 public:
164 DownloadFileWithMockStream(DownloadCreateInfo* info, DownloadManager* manager)
165 : DownloadFile(info, manager) {
166 }
167 virtual ~DownloadFileWithMockStream() {
168 }
169
170 void SetForcedError(int error)
171 {
172 testing::MockFileStream* mock_stream =
173 static_cast<testing::MockFileStream *>(file_stream_.get());
174 mock_stream->set_forced_error(error);
175 }
176
177 protected:
178 // This version creates a |MockFileStream| instead of a |FileStream|.
179 virtual void CreateFileStream() {
180 file_stream_.reset(new testing::MockFileStream);
181 }
182 };
183
130 namespace { 184 namespace {
131 185
132 const struct { 186 const struct {
133 const char* url; 187 const char* url;
134 const char* mime_type; 188 const char* mime_type;
135 bool save_as; 189 bool save_as;
136 bool prompt_for_download; 190 bool prompt_for_download;
137 bool expected_save_as; 191 bool expected_save_as;
138 } kStartDownloadCases[] = { 192 } kStartDownloadCases[] = {
139 { "http://www.foo.com/dont-open.html", 193 { "http://www.foo.com/dont-open.html",
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 DownloadItem* download = GetActiveDownloadItem(i); 432 DownloadItem* download = GetActiveDownloadItem(i);
379 ASSERT_TRUE(download != NULL); 433 ASSERT_TRUE(download != NULL);
380 if (kDownloadRenameCases[i].is_dangerous_file) 434 if (kDownloadRenameCases[i].is_dangerous_file)
381 download->MarkFileDangerous(); 435 download->MarkFileDangerous();
382 if (kDownloadRenameCases[i].is_dangerous_url) 436 if (kDownloadRenameCases[i].is_dangerous_url)
383 download->MarkUrlDangerous(); 437 download->MarkUrlDangerous();
384 438
385 int32* id_ptr = new int32; 439 int32* id_ptr = new int32;
386 *id_ptr = i; // Deleted in FileSelected(). 440 *id_ptr = i; // Deleted in FileSelected().
387 if (kDownloadRenameCases[i].finish_before_rename) { 441 if (kDownloadRenameCases[i].finish_before_rename) {
388 OnAllDataSaved(i, 1024, std::string("fake_hash")); 442 OnResponseCompleted(i, 1024, std::string("fake_hash"));
389 message_loop_.RunAllPending(); 443 message_loop_.RunAllPending();
390 FileSelected(new_path, id_ptr); 444 FileSelected(new_path, id_ptr);
391 } else { 445 } else {
392 FileSelected(new_path, id_ptr); 446 FileSelected(new_path, id_ptr);
393 message_loop_.RunAllPending(); 447 message_loop_.RunAllPending();
394 OnAllDataSaved(i, 1024, std::string("fake_hash")); 448 OnResponseCompleted(i, 1024, std::string("fake_hash"));
395 } 449 }
396 450
397 message_loop_.RunAllPending(); 451 message_loop_.RunAllPending();
398 EXPECT_TRUE(VerifySafetyState(kDownloadRenameCases[i].is_dangerous_file, 452 EXPECT_TRUE(VerifySafetyState(kDownloadRenameCases[i].is_dangerous_file,
399 kDownloadRenameCases[i].is_dangerous_url, 453 kDownloadRenameCases[i].is_dangerous_url,
400 i)); 454 i));
401 } 455 }
402 } 456 }
403 457
404 TEST_F(DownloadManagerTest, DownloadInterruptTest) { 458 TEST_F(DownloadManagerTest, DownloadInterruptTest) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 EXPECT_FALSE(observer->hit_state(DownloadItem::CANCELLED)); 530 EXPECT_FALSE(observer->hit_state(DownloadItem::CANCELLED));
477 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING)); 531 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING));
478 EXPECT_TRUE(observer->was_updated()); 532 EXPECT_TRUE(observer->was_updated());
479 EXPECT_FALSE(observer->was_opened()); 533 EXPECT_FALSE(observer->was_opened());
480 EXPECT_FALSE(download->file_externally_removed()); 534 EXPECT_FALSE(download->file_externally_removed());
481 EXPECT_EQ(DownloadItem::INTERRUPTED, download->state()); 535 EXPECT_EQ(DownloadItem::INTERRUPTED, download->state());
482 EXPECT_EQ(download->received_bytes(), error_size); 536 EXPECT_EQ(download->received_bytes(), error_size);
483 EXPECT_EQ(download->total_bytes(), static_cast<int64>(kTestDataLen)); 537 EXPECT_EQ(download->total_bytes(), static_cast<int64>(kTestDataLen));
484 } 538 }
485 539
540 TEST_F(DownloadManagerTest, DownloadFileErrorTest) {
541 using ::testing::_;
542 using ::testing::CreateFunctor;
543 using ::testing::Invoke;
544 using ::testing::Return;
545
546 // Normally, the download system takes ownership of info, and is
547 // responsible for deleting it. In these unit tests, however, we
548 // don't call the function that deletes it, so we do so ourselves.
549 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo);
550 int32 id = 0;
551 info->download_id = id;
552 info->prompt_user_for_save_location = false;
553 info->url_chain.push_back(GURL());
554 info->total_bytes = static_cast<int64>(kTestDataLen * 3);
555 FilePath path;
556 ASSERT_TRUE(file_util::CreateTemporaryFile(&path));
557 testing::MockFileStream* mock_stream = new testing::MockFileStream;
558 linked_ptr<net::FileStream> stream(mock_stream);
559 ASSERT_EQ(0, mock_stream->Open(
560 path,
561 base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE));
562 info->save_info.file_path = path;
563 info->save_info.file_stream = stream;
564
565 DownloadFileWithMockStream* download_file(new DownloadFileWithMockStream(
566 info.get(), download_manager_));
567 AddDownloadToFileManager(id, download_file);
568
569 // |download_file| is owned by DownloadFileManager.
570 ::testing::Mock::AllowLeak(download_file);
571 download_manager_->CreateDownloadItem(info.get());
572
573 DownloadItem* download = GetActiveDownloadItem(0);
574 ASSERT_TRUE(download != NULL);
575 scoped_ptr<DownloadItemModel> download_item_model(
576 new DownloadItemModel(download));
577
578 EXPECT_EQ(DownloadItem::IN_PROGRESS, download->state());
579 scoped_ptr<ItemObserver> observer(new ItemObserver(download));
580
581 UpdateData(id, kTestData, kTestDataLen);
582
583 ContinueDownloadWithPath(download, path);
584 message_loop_.RunAllPending();
585 EXPECT_TRUE(GetActiveDownloadItem(0) != NULL);
586
587 UpdateData(id, kTestData, kTestDataLen);
588
589 download_file->SetForcedError(net::ERR_FAILED);
590 UpdateData(id, kTestData, kTestDataLen);
591
592 EXPECT_TRUE(GetActiveDownloadItem(0) == NULL);
593 EXPECT_TRUE(observer->hit_state(DownloadItem::IN_PROGRESS));
594 EXPECT_TRUE(observer->hit_state(DownloadItem::INTERRUPTED));
595 EXPECT_FALSE(observer->hit_state(DownloadItem::COMPLETE));
596 EXPECT_FALSE(observer->hit_state(DownloadItem::CANCELLED));
597 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING));
598 EXPECT_TRUE(observer->was_updated());
599 EXPECT_FALSE(observer->was_opened());
600 EXPECT_FALSE(download->file_externally_removed());
601 EXPECT_EQ(DownloadItem::INTERRUPTED, download->state());
602
603 size_t error_size = kTestDataLen * 3;
604 ui::DataUnits amount_units = ui::GetByteDisplayUnits(kTestDataLen);
605 string16 simple_size =
606 ui::FormatBytesWithUnits(error_size, amount_units, false);
607 string16 simple_total = base::i18n::GetDisplayStringInLTRDirectionality(
608 ui::FormatBytesWithUnits(error_size, amount_units, true));
609 EXPECT_EQ(l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_INTERRUPTED,
610 simple_size,
611 simple_total),
612 download_item_model->GetStatusText());
613
614 download->Cancel(true);
615
616 EXPECT_TRUE(observer->hit_state(DownloadItem::IN_PROGRESS));
617 EXPECT_TRUE(observer->hit_state(DownloadItem::INTERRUPTED));
618 EXPECT_FALSE(observer->hit_state(DownloadItem::COMPLETE));
619 EXPECT_FALSE(observer->hit_state(DownloadItem::CANCELLED));
620 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING));
621 EXPECT_TRUE(observer->was_updated());
622 EXPECT_FALSE(observer->was_opened());
623 EXPECT_FALSE(download->file_externally_removed());
624 EXPECT_EQ(DownloadItem::INTERRUPTED, download->state());
625 EXPECT_EQ(static_cast<int64>(error_size), download->received_bytes());
626 EXPECT_EQ(static_cast<int64>(kTestDataLen) * 3, download->total_bytes());
627 }
628
486 TEST_F(DownloadManagerTest, DownloadCancelTest) { 629 TEST_F(DownloadManagerTest, DownloadCancelTest) {
487 using ::testing::_; 630 using ::testing::_;
488 using ::testing::CreateFunctor; 631 using ::testing::CreateFunctor;
489 using ::testing::Invoke; 632 using ::testing::Invoke;
490 using ::testing::Return; 633 using ::testing::Return;
491 634
492 // Normally, the download system takes ownership of info, and is 635 // Normally, the download system takes ownership of info, and is
493 // responsible for deleting it. In these unit tests, however, we 636 // responsible for deleting it. In these unit tests, however, we
494 // don't call the function that deletes it, so we do so ourselves. 637 // don't call the function that deletes it, so we do so ourselves.
495 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo); 638 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 // |download_file| is owned by DownloadFileManager. 746 // |download_file| is owned by DownloadFileManager.
604 AddDownloadToFileManager(info->download_id, download_file); 747 AddDownloadToFileManager(info->download_id, download_file);
605 748
606 ContinueDownloadWithPath(download, new_path); 749 ContinueDownloadWithPath(download, new_path);
607 message_loop_.RunAllPending(); 750 message_loop_.RunAllPending();
608 EXPECT_TRUE(GetActiveDownloadItem(0) != NULL); 751 EXPECT_TRUE(GetActiveDownloadItem(0) != NULL);
609 752
610 download_file->AppendDataToFile(kTestData, kTestDataLen); 753 download_file->AppendDataToFile(kTestData, kTestDataLen);
611 754
612 // Finish the download. 755 // Finish the download.
613 OnAllDataSaved(0, kTestDataLen, ""); 756 OnResponseCompleted(0, kTestDataLen, "");
614 message_loop_.RunAllPending(); 757 message_loop_.RunAllPending();
615 758
616 // Download is complete. 759 // Download is complete.
617 EXPECT_TRUE(GetActiveDownloadItem(0) == NULL); 760 EXPECT_TRUE(GetActiveDownloadItem(0) == NULL);
618 EXPECT_TRUE(observer->hit_state(DownloadItem::IN_PROGRESS)); 761 EXPECT_TRUE(observer->hit_state(DownloadItem::IN_PROGRESS));
619 EXPECT_FALSE(observer->hit_state(DownloadItem::CANCELLED)); 762 EXPECT_FALSE(observer->hit_state(DownloadItem::CANCELLED));
620 EXPECT_FALSE(observer->hit_state(DownloadItem::INTERRUPTED)); 763 EXPECT_FALSE(observer->hit_state(DownloadItem::INTERRUPTED));
621 EXPECT_TRUE(observer->hit_state(DownloadItem::COMPLETE)); 764 EXPECT_TRUE(observer->hit_state(DownloadItem::COMPLETE));
622 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING)); 765 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING));
623 EXPECT_TRUE(observer->was_updated()); 766 EXPECT_TRUE(observer->was_updated());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 // |download_file| is owned by DownloadFileManager. 822 // |download_file| is owned by DownloadFileManager.
680 AddDownloadToFileManager(info->download_id, download_file); 823 AddDownloadToFileManager(info->download_id, download_file);
681 824
682 ContinueDownloadWithPath(download, new_path); 825 ContinueDownloadWithPath(download, new_path);
683 message_loop_.RunAllPending(); 826 message_loop_.RunAllPending();
684 EXPECT_TRUE(GetActiveDownloadItem(0) != NULL); 827 EXPECT_TRUE(GetActiveDownloadItem(0) != NULL);
685 828
686 download_file->AppendDataToFile(kTestData, kTestDataLen); 829 download_file->AppendDataToFile(kTestData, kTestDataLen);
687 830
688 // Finish the download. 831 // Finish the download.
689 OnAllDataSaved(0, kTestDataLen, ""); 832 OnResponseCompleted(0, kTestDataLen, "");
690 message_loop_.RunAllPending(); 833 message_loop_.RunAllPending();
691 834
692 // Download is complete. 835 // Download is complete.
693 EXPECT_TRUE(GetActiveDownloadItem(0) == NULL); 836 EXPECT_TRUE(GetActiveDownloadItem(0) == NULL);
694 EXPECT_TRUE(observer->hit_state(DownloadItem::IN_PROGRESS)); 837 EXPECT_TRUE(observer->hit_state(DownloadItem::IN_PROGRESS));
695 EXPECT_FALSE(observer->hit_state(DownloadItem::CANCELLED)); 838 EXPECT_FALSE(observer->hit_state(DownloadItem::CANCELLED));
696 EXPECT_FALSE(observer->hit_state(DownloadItem::INTERRUPTED)); 839 EXPECT_FALSE(observer->hit_state(DownloadItem::INTERRUPTED));
697 EXPECT_TRUE(observer->hit_state(DownloadItem::COMPLETE)); 840 EXPECT_TRUE(observer->hit_state(DownloadItem::COMPLETE));
698 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING)); 841 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING));
699 EXPECT_TRUE(observer->was_updated()); 842 EXPECT_TRUE(observer->was_updated());
(...skipping 18 matching lines...) Expand all
718 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING)); 861 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING));
719 EXPECT_TRUE(observer->was_updated()); 862 EXPECT_TRUE(observer->was_updated());
720 EXPECT_FALSE(observer->was_opened()); 863 EXPECT_FALSE(observer->was_opened());
721 EXPECT_TRUE(download->file_externally_removed()); 864 EXPECT_TRUE(download->file_externally_removed());
722 EXPECT_EQ(DownloadItem::COMPLETE, download->state()); 865 EXPECT_EQ(DownloadItem::COMPLETE, download->state());
723 EXPECT_EQ(download_item_model->GetStatusText(), 866 EXPECT_EQ(download_item_model->GetStatusText(),
724 l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_REMOVED)); 867 l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_REMOVED));
725 868
726 EXPECT_FALSE(file_util::PathExists(new_path)); 869 EXPECT_FALSE(file_util::PathExists(new_path));
727 } 870 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/base_file.h » ('j') | net/base/mock_file_stream.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698