| 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/mac/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/cocoa_test_helper.h" |
| 7 #import "chrome/browser/ui/cocoa/download/download_item_cell.h" | 8 #import "chrome/browser/ui/cocoa/download/download_item_cell.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" |
| 11 #include "testing/platform_test.h" | 11 #include "testing/platform_test.h" |
| 12 | 12 |
| 13 using ::testing::Return; | 13 using ::testing::Return; |
| 14 | 14 |
| 15 | 15 |
| 16 | 16 |
| 17 using ::testing::_; | 17 using ::testing::_; |
| 18 using ::testing::ReturnRefOfCopy; | 18 using ::testing::ReturnRefOfCopy; |
| 19 | 19 |
| 20 | 20 |
| 21 class DownloadItemCellTest : public CocoaTest { | 21 class DownloadItemCellTest : public CocoaTest { |
| 22 public: | 22 public: |
| 23 DownloadItemCellTest() : CocoaTest() { | 23 DownloadItemCellTest() : CocoaTest() { |
| 24 } | 24 } |
| 25 | 25 |
| 26 virtual void SetUp() { | 26 virtual void SetUp() { |
| 27 CocoaTest::SetUp(); | 27 CocoaTest::SetUp(); |
| 28 button_.reset([[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]); | 28 button_.reset([[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]); |
| 29 [[test_window() contentView] addSubview:button_]; | 29 [[test_window() contentView] addSubview:button_]; |
| 30 cell_.reset([[DownloadItemCell alloc] initTextCell:@""]); | 30 cell_.reset([[DownloadItemCell alloc] initTextCell:@""]); |
| 31 [button_ setCell:cell_]; | 31 [button_ setCell:cell_]; |
| 32 } | 32 } |
| 33 | 33 |
| 34 protected: | 34 protected: |
| 35 scoped_nsobject<DownloadItemCell> cell_; | 35 base::scoped_nsobject<DownloadItemCell> cell_; |
| 36 scoped_nsobject<NSButton> button_; | 36 base::scoped_nsobject<NSButton> button_; |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 DISALLOW_COPY_AND_ASSIGN(DownloadItemCellTest); | 39 DISALLOW_COPY_AND_ASSIGN(DownloadItemCellTest); |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 TEST_F(DownloadItemCellTest, ToggleStatusText) { | 42 TEST_F(DownloadItemCellTest, ToggleStatusText) { |
| 43 EXPECT_FALSE([cell_ isStatusTextVisible]); | 43 EXPECT_FALSE([cell_ isStatusTextVisible]); |
| 44 EXPECT_FLOAT_EQ(0.0, [cell_ statusTextAlpha]); | 44 EXPECT_FLOAT_EQ(0.0, [cell_ statusTextAlpha]); |
| 45 | 45 |
| 46 [cell_ showSecondaryTitle]; | 46 [cell_ showSecondaryTitle]; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 73 [button_ lockFocus]; | 73 [button_ lockFocus]; |
| 74 [cell_ drawWithFrame:[button_ bounds] | 74 [cell_ drawWithFrame:[button_ bounds] |
| 75 inView:button_]; | 75 inView:button_]; |
| 76 [button_ unlockFocus]; | 76 [button_ unlockFocus]; |
| 77 | 77 |
| 78 // Unset indeterminate state. | 78 // Unset indeterminate state. |
| 79 ON_CALL(item, PercentComplete()).WillByDefault(Return(0)); | 79 ON_CALL(item, PercentComplete()).WillByDefault(Return(0)); |
| 80 [cell_ setStateFromDownload:&model]; | 80 [cell_ setStateFromDownload:&model]; |
| 81 EXPECT_FALSE([cell_ indeterminateProgressTimer]); | 81 EXPECT_FALSE([cell_ indeterminateProgressTimer]); |
| 82 } | 82 } |
| OLD | NEW |