| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_nsobject.h" | 5 #include "base/memory/scoped_nsobject.h" |
| 6 #include "chrome/browser/download/download_item_model.h" | 6 #include "chrome/browser/download/download_item_model.h" |
| 7 #import "chrome/browser/ui/cocoa/download/download_item_cell.h" | 7 #import "chrome/browser/ui/cocoa/download/download_item_cell.h" |
| 8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 9 #include "content/public/test/mock_download_item.h" | 9 #include "content/public/test/mock_download_item.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 EXPECT_FLOAT_EQ(1.0, [cell_ statusTextAlpha]); | 49 EXPECT_FLOAT_EQ(1.0, [cell_ statusTextAlpha]); |
| 50 | 50 |
| 51 [cell_ hideSecondaryTitle]; | 51 [cell_ hideSecondaryTitle]; |
| 52 [cell_ skipVisibilityAnimation]; | 52 [cell_ skipVisibilityAnimation]; |
| 53 EXPECT_FALSE([cell_ isStatusTextVisible]); | 53 EXPECT_FALSE([cell_ isStatusTextVisible]); |
| 54 EXPECT_FLOAT_EQ(0.0, [cell_ statusTextAlpha]); | 54 EXPECT_FLOAT_EQ(0.0, [cell_ statusTextAlpha]); |
| 55 } | 55 } |
| 56 | 56 |
| 57 TEST_F(DownloadItemCellTest, IndeterminateProgress) { | 57 TEST_F(DownloadItemCellTest, IndeterminateProgress) { |
| 58 testing::NiceMock<content::MockDownloadItem> item; | 58 testing::NiceMock<content::MockDownloadItem> item; |
| 59 ON_CALL(item, IsInProgress()).WillByDefault(Return(true)); | |
| 60 ON_CALL(item, IsPaused()).WillByDefault(Return(false)); | 59 ON_CALL(item, IsPaused()).WillByDefault(Return(false)); |
| 61 ON_CALL(item, PercentComplete()).WillByDefault(Return(-1)); | 60 ON_CALL(item, PercentComplete()).WillByDefault(Return(-1)); |
| 62 ON_CALL(item, GetState()) | 61 ON_CALL(item, GetState()) |
| 63 .WillByDefault(Return(content::DownloadItem::IN_PROGRESS)); | 62 .WillByDefault(Return(content::DownloadItem::IN_PROGRESS)); |
| 64 ON_CALL(item, GetFileNameToReportUser()) | 63 ON_CALL(item, GetFileNameToReportUser()) |
| 65 .WillByDefault(Return(base::FilePath("foo.bar"))); | 64 .WillByDefault(Return(base::FilePath("foo.bar"))); |
| 66 DownloadItemModel model(&item); | 65 DownloadItemModel model(&item); |
| 67 | 66 |
| 68 // Set indeterminate state. | 67 // Set indeterminate state. |
| 69 EXPECT_FALSE([cell_ indeterminateProgressTimer]); | 68 EXPECT_FALSE([cell_ indeterminateProgressTimer]); |
| 70 [cell_ setStateFromDownload:&model]; | 69 [cell_ setStateFromDownload:&model]; |
| 71 EXPECT_TRUE([cell_ indeterminateProgressTimer]); | 70 EXPECT_TRUE([cell_ indeterminateProgressTimer]); |
| 72 | 71 |
| 73 // Draw. | 72 // Draw. |
| 74 [button_ lockFocus]; | 73 [button_ lockFocus]; |
| 75 [cell_ drawWithFrame:[button_ bounds] | 74 [cell_ drawWithFrame:[button_ bounds] |
| 76 inView:button_]; | 75 inView:button_]; |
| 77 [button_ unlockFocus]; | 76 [button_ unlockFocus]; |
| 78 | 77 |
| 79 // Unset indeterminate state. | 78 // Unset indeterminate state. |
| 80 ON_CALL(item, PercentComplete()).WillByDefault(Return(0)); | 79 ON_CALL(item, PercentComplete()).WillByDefault(Return(0)); |
| 81 [cell_ setStateFromDownload:&model]; | 80 [cell_ setStateFromDownload:&model]; |
| 82 EXPECT_FALSE([cell_ indeterminateProgressTimer]); | 81 EXPECT_FALSE([cell_ indeterminateProgressTimer]); |
| 83 } | 82 } |
| OLD | NEW |