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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 delete updater_; | 63 delete updater_; |
64 updater_ = NULL; | 64 updater_ = NULL; |
65 VerifyAndClearExpectations(); | 65 VerifyAndClearExpectations(); |
66 | 66 |
67 managers_.clear(); | 67 managers_.clear(); |
68 for (std::vector<Items>::iterator it = manager_items_.begin(); | 68 for (std::vector<Items>::iterator it = manager_items_.begin(); |
69 it != manager_items_.end(); ++it) | 69 it != manager_items_.end(); ++it) |
70 STLDeleteContainerPointers(it->begin(), it->end()); | 70 STLDeleteContainerPointers(it->begin(), it->end()); |
71 | 71 |
72 loop_.RunAllPending(); // Allow DownloadManager destruction. | 72 loop_.RunUntilIdle(); // Allow DownloadManager destruction. |
73 } | 73 } |
74 | 74 |
75 protected: | 75 protected: |
76 // Attach some number of DownloadManagers to the updater. | 76 // Attach some number of DownloadManagers to the updater. |
77 void SetupManagers(int manager_count) { | 77 void SetupManagers(int manager_count) { |
78 DCHECK_EQ(0U, managers_.size()); | 78 DCHECK_EQ(0U, managers_.size()); |
79 for (int i = 0; i < manager_count; ++i) { | 79 for (int i = 0; i < manager_count; ++i) { |
80 content::MockDownloadManager* mgr = | 80 content::MockDownloadManager* mgr = |
81 new StrictMock<content::MockDownloadManager>; | 81 new StrictMock<content::MockDownloadManager>; |
82 managers_.push_back(make_scoped_refptr(mgr)); | 82 managers_.push_back(make_scoped_refptr(mgr)); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 SetItemValues(0, 0, 10, 20, false); | 338 SetItemValues(0, 0, 10, 20, false); |
339 SetItemValues(0, 1, 50, 60, false); | 339 SetItemValues(0, 1, 50, 60, false); |
340 SetItemValues(1, 0, 80, 90, false); | 340 SetItemValues(1, 0, 80, 90, false); |
341 | 341 |
342 float progress = -1; | 342 float progress = -1; |
343 int download_count = -1; | 343 int download_count = -1; |
344 EXPECT_TRUE(updater_->GetProgress(&progress, &download_count)); | 344 EXPECT_TRUE(updater_->GetProgress(&progress, &download_count)); |
345 EXPECT_FLOAT_EQ((10+50+80)/(20.0f+60+90), progress); | 345 EXPECT_FLOAT_EQ((10+50+80)/(20.0f+60+90), progress); |
346 EXPECT_EQ(3, download_count); | 346 EXPECT_EQ(3, download_count); |
347 } | 347 } |
OLD | NEW |