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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 std::vector<content::DownloadManager::Observer*> manager_observers_; | 181 std::vector<content::DownloadManager::Observer*> manager_observers_; |
182 | 182 |
183 // Pointer so we can verify that destruction triggers appropriate | 183 // Pointer so we can verify that destruction triggers appropriate |
184 // changes. | 184 // changes. |
185 TestDownloadStatusUpdater *updater_; | 185 TestDownloadStatusUpdater *updater_; |
186 | 186 |
187 // Thread so that the DownloadManager (which is a DeleteOnUIThread | 187 // Thread so that the DownloadManager (which is a DeleteOnUIThread |
188 // object) can be deleted. | 188 // object) can be deleted. |
189 // TODO(rdsmith): This can be removed when the DownloadManager | 189 // TODO(rdsmith): This can be removed when the DownloadManager |
190 // is no longer required to be deleted on the UI thread. | 190 // is no longer required to be deleted on the UI thread. |
191 MessageLoop loop_; | 191 base::MessageLoop loop_; |
192 content::TestBrowserThread ui_thread_; | 192 content::TestBrowserThread ui_thread_; |
193 }; | 193 }; |
194 | 194 |
195 // Test null updater. | 195 // Test null updater. |
196 TEST_F(DownloadStatusUpdaterTest, Basic) { | 196 TEST_F(DownloadStatusUpdaterTest, Basic) { |
197 float progress = -1; | 197 float progress = -1; |
198 int download_count = -1; | 198 int download_count = -1; |
199 EXPECT_TRUE(updater_->GetProgress(&progress, &download_count)); | 199 EXPECT_TRUE(updater_->GetProgress(&progress, &download_count)); |
200 EXPECT_FLOAT_EQ(0.0f, progress); | 200 EXPECT_FLOAT_EQ(0.0f, progress); |
201 EXPECT_EQ(0, download_count); | 201 EXPECT_EQ(0, download_count); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 SetItemValues(0, 0, 10, 20, false); | 340 SetItemValues(0, 0, 10, 20, false); |
341 SetItemValues(0, 1, 50, 60, false); | 341 SetItemValues(0, 1, 50, 60, false); |
342 SetItemValues(1, 0, 80, 90, false); | 342 SetItemValues(1, 0, 80, 90, false); |
343 | 343 |
344 float progress = -1; | 344 float progress = -1; |
345 int download_count = -1; | 345 int download_count = -1; |
346 EXPECT_TRUE(updater_->GetProgress(&progress, &download_count)); | 346 EXPECT_TRUE(updater_->GetProgress(&progress, &download_count)); |
347 EXPECT_FLOAT_EQ((10+50+80)/(20.0f+60+90), progress); | 347 EXPECT_FLOAT_EQ((10+50+80)/(20.0f+60+90), progress); |
348 EXPECT_EQ(3, download_count); | 348 EXPECT_EQ(3, download_count); |
349 } | 349 } |
OLD | NEW |