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

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

Issue 9363001: Eliminate DownloadProgressUpdated. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests work Created 8 years, 10 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/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/browser/download/download_request_handle.h" 10 #include "content/browser/download/download_request_handle.h"
11 #include "content/browser/download/download_types.h" 11 #include "content/browser/download/download_types.h"
12 #include "content/test/mock_download_item.h" 12 #include "content/test/mock_download_item.h"
13 #include "content/test/mock_download_manager.h" 13 #include "content/test/mock_download_manager.h"
14 #include "content/test/test_browser_thread.h" 14 #include "content/test/test_browser_thread.h"
15 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 18
19 using ::testing::AtLeast; 19 using ::testing::AtLeast;
20 using ::testing::Mock; 20 using ::testing::Mock;
21 using ::testing::Return; 21 using ::testing::Return;
22 using ::testing::SetArgPointee; 22 using ::testing::SetArgPointee;
23 using ::testing::StrictMock; 23 using ::testing::StrictMock;
24 using ::testing::_; 24 using ::testing::_;
25 25
26 class TestDownloadStatusUpdater : public DownloadStatusUpdater {
27 protected:
28 virtual void UpdateAppIconDownloadProgress() OVERRIDE {
29 return;
30 }
31 };
32
26 class DownloadStatusUpdaterTest : public testing::Test { 33 class DownloadStatusUpdaterTest : public testing::Test {
27 public: 34 public:
28 DownloadStatusUpdaterTest() 35 DownloadStatusUpdaterTest()
29 : updater_(new DownloadStatusUpdater()), 36 : updater_(new TestDownloadStatusUpdater()),
30 ui_thread_(content::BrowserThread::UI, &loop_) {} 37 ui_thread_(content::BrowserThread::UI, &loop_) {}
31 38
32 virtual ~DownloadStatusUpdaterTest() { 39 virtual ~DownloadStatusUpdaterTest() {
33 for (size_t mgr_idx = 0; mgr_idx < managers_.size(); ++mgr_idx) { 40 for (size_t mgr_idx = 0; mgr_idx < managers_.size(); ++mgr_idx) {
34 EXPECT_CALL(*Manager(mgr_idx), RemoveObserver(updater_)); 41 EXPECT_CALL(*Manager(mgr_idx), RemoveObserver(updater_));
35 for (size_t item_idx = 0; item_idx < manager_items_[mgr_idx].size(); 42 for (size_t item_idx = 0; item_idx < manager_items_[mgr_idx].size();
36 ++item_idx) { 43 ++item_idx) {
37 if (Item(mgr_idx, item_idx)->GetState() == 44 if (Item(mgr_idx, item_idx)->GetState() ==
38 content::DownloadItem::IN_PROGRESS) 45 content::DownloadItem::IN_PROGRESS)
39 EXPECT_CALL(*Item(mgr_idx, item_idx), RemoveObserver(updater_)); 46 EXPECT_CALL(*Item(mgr_idx, item_idx), RemoveObserver(updater_));
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 SetItemValues(0, 0, 10, 20); 281 SetItemValues(0, 0, 10, 20);
275 SetItemValues(0, 1, 50, 60); 282 SetItemValues(0, 1, 50, 60);
276 SetItemValues(1, 0, 80, 90); 283 SetItemValues(1, 0, 80, 90);
277 284
278 float progress = -1; 285 float progress = -1;
279 int download_count = -1; 286 int download_count = -1;
280 EXPECT_TRUE(updater_->GetProgress(&progress, &download_count)); 287 EXPECT_TRUE(updater_->GetProgress(&progress, &download_count));
281 EXPECT_FLOAT_EQ((10+50+80)/(20.0f+60+90), progress); 288 EXPECT_FLOAT_EQ((10+50+80)/(20.0f+60+90), progress);
282 EXPECT_EQ(3, download_count); 289 EXPECT_EQ(3, download_count);
283 } 290 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_status_updater.cc ('k') | content/browser/download/download_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698