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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/memory/weak_ptr.h" | 6 #include "base/memory/weak_ptr.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "chrome/browser/download/download_status_updater.h" | 9 #include "chrome/browser/download/download_status_updater.h" |
10 #include "content/public/test/mock_download_item.h" | 10 #include "content/public/test/mock_download_item.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 DCHECK_GT(managers_.size(), static_cast<size_t>(manager_index)); | 96 DCHECK_GT(managers_.size(), static_cast<size_t>(manager_index)); |
97 content::MockDownloadManager* manager = managers_[manager_index].get(); | 97 content::MockDownloadManager* manager = managers_[manager_index].get(); |
98 | 98 |
99 if (manager_items_.size() <= static_cast<size_t>(manager_index)) | 99 if (manager_items_.size() <= static_cast<size_t>(manager_index)) |
100 manager_items_.resize(manager_index+1); | 100 manager_items_.resize(manager_index+1); |
101 | 101 |
102 std::vector<content::DownloadItem*> item_list; | 102 std::vector<content::DownloadItem*> item_list; |
103 for (int i = 0; i < item_count; ++i) { | 103 for (int i = 0; i < item_count; ++i) { |
104 content::MockDownloadItem* item = | 104 content::MockDownloadItem* item = |
105 new StrictMock<content::MockDownloadItem>; | 105 new StrictMock<content::MockDownloadItem>; |
| 106 EXPECT_CALL(*item, IsTemporary()) |
| 107 .WillRepeatedly(Return(false)); |
106 if (i < in_progress_count) { | 108 if (i < in_progress_count) { |
107 EXPECT_CALL(*item, GetState()) | 109 EXPECT_CALL(*item, GetState()) |
108 .WillRepeatedly(Return(content::DownloadItem::IN_PROGRESS)); | 110 .WillRepeatedly(Return(content::DownloadItem::IN_PROGRESS)); |
109 EXPECT_CALL(*item, AddObserver(updater_)) | 111 EXPECT_CALL(*item, AddObserver(updater_)) |
110 .WillOnce(Return()); | 112 .WillOnce(Return()); |
111 } else { | 113 } else { |
112 EXPECT_CALL(*item, GetState()) | 114 EXPECT_CALL(*item, GetState()) |
113 .WillRepeatedly(Return(content::DownloadItem::COMPLETE)); | 115 .WillRepeatedly(Return(content::DownloadItem::COMPLETE)); |
114 } | 116 } |
115 manager_items_[manager_index].push_back(item); | 117 manager_items_[manager_index].push_back(item); |
116 } | 118 } |
117 EXPECT_CALL(*manager, SearchDownloads(string16(), _)) | 119 EXPECT_CALL(*manager, GetAllDownloads(_)) |
118 .WillOnce(SetArgPointee<1>(manager_items_[manager_index])); | 120 .WillOnce(SetArgPointee<0>(manager_items_[manager_index])); |
119 } | 121 } |
120 | 122 |
121 // Return the specified manager. | 123 // Return the specified manager. |
122 content::MockDownloadManager* Manager(int manager_index) { | 124 content::MockDownloadManager* Manager(int manager_index) { |
123 DCHECK_GT(managers_.size(), static_cast<size_t>(manager_index)); | 125 DCHECK_GT(managers_.size(), static_cast<size_t>(manager_index)); |
124 return managers_[manager_index].get(); | 126 return managers_[manager_index].get(); |
125 } | 127 } |
126 | 128 |
127 // Return the specified item. | 129 // Return the specified item. |
128 content::MockDownloadItem* Item(int manager_index, int item_index) { | 130 content::MockDownloadItem* Item(int manager_index, int item_index) { |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 SetItemValues(0, 0, 10, 20, false); | 332 SetItemValues(0, 0, 10, 20, false); |
331 SetItemValues(0, 1, 50, 60, false); | 333 SetItemValues(0, 1, 50, 60, false); |
332 SetItemValues(1, 0, 80, 90, false); | 334 SetItemValues(1, 0, 80, 90, false); |
333 | 335 |
334 float progress = -1; | 336 float progress = -1; |
335 int download_count = -1; | 337 int download_count = -1; |
336 EXPECT_TRUE(updater_->GetProgress(&progress, &download_count)); | 338 EXPECT_TRUE(updater_->GetProgress(&progress, &download_count)); |
337 EXPECT_FLOAT_EQ((10+50+80)/(20.0f+60+90), progress); | 339 EXPECT_FLOAT_EQ((10+50+80)/(20.0f+60+90), progress); |
338 EXPECT_EQ(3, download_count); | 340 EXPECT_EQ(3, download_count); |
339 } | 341 } |
OLD | NEW |