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_vector.h" | 5 #include "base/memory/scoped_vector.h" |
6 #include "base/memory/weak_ptr.h" | 6 #include "base/memory/weak_ptr.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/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 17 matching lines...) Expand all Loading... |
28 acceptable_notification_item_(NULL) { | 28 acceptable_notification_item_(NULL) { |
29 } | 29 } |
30 void SetAcceptableNotificationItem(content::DownloadItem* item) { | 30 void SetAcceptableNotificationItem(content::DownloadItem* item) { |
31 acceptable_notification_item_ = item; | 31 acceptable_notification_item_ = item; |
32 } | 32 } |
33 size_t NotificationCount() { | 33 size_t NotificationCount() { |
34 return notification_count_; | 34 return notification_count_; |
35 } | 35 } |
36 protected: | 36 protected: |
37 virtual void UpdateAppIconDownloadProgress( | 37 virtual void UpdateAppIconDownloadProgress( |
38 content::DownloadItem* download) OVERRIDE { | 38 content::DownloadItem* download) override { |
39 ++notification_count_; | 39 ++notification_count_; |
40 if (acceptable_notification_item_) | 40 if (acceptable_notification_item_) |
41 EXPECT_EQ(acceptable_notification_item_, download); | 41 EXPECT_EQ(acceptable_notification_item_, download); |
42 } | 42 } |
43 private: | 43 private: |
44 size_t notification_count_; | 44 size_t notification_count_; |
45 content::DownloadItem* acceptable_notification_item_; | 45 content::DownloadItem* acceptable_notification_item_; |
46 }; | 46 }; |
47 | 47 |
48 class DownloadStatusUpdaterTest : public testing::Test { | 48 class DownloadStatusUpdaterTest : public testing::Test { |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 SetItemValues(0, 0, 10, 20, false); | 334 SetItemValues(0, 0, 10, 20, false); |
335 SetItemValues(0, 1, 50, 60, false); | 335 SetItemValues(0, 1, 50, 60, false); |
336 SetItemValues(1, 0, 80, 90, false); | 336 SetItemValues(1, 0, 80, 90, false); |
337 | 337 |
338 float progress = -1; | 338 float progress = -1; |
339 int download_count = -1; | 339 int download_count = -1; |
340 EXPECT_TRUE(updater_->GetProgress(&progress, &download_count)); | 340 EXPECT_TRUE(updater_->GetProgress(&progress, &download_count)); |
341 EXPECT_FLOAT_EQ((10+50+80)/(20.0f+60+90), progress); | 341 EXPECT_FLOAT_EQ((10+50+80)/(20.0f+60+90), progress); |
342 EXPECT_EQ(3, download_count); | 342 EXPECT_EQ(3, download_count); |
343 } | 343 } |
OLD | NEW |