OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "chrome/browser/cocoa/extensions/chevron_menu_button.h" |
| 6 #import "chrome/browser/cocoa/extensions/chevron_menu_button_cell.h" |
| 7 |
| 8 #include "base/scoped_nsobject.h" |
| 9 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| 10 |
| 11 namespace { |
| 12 |
| 13 class ChevronMenuButtonTest : public CocoaTest { |
| 14 public: |
| 15 ChevronMenuButtonTest() { |
| 16 NSRect frame = NSMakeRect(0, 0, 50, 30); |
| 17 scoped_nsobject<ChevronMenuButton> button( |
| 18 [[ChevronMenuButton alloc] initWithFrame:frame]); |
| 19 button_ = button.get(); |
| 20 [[test_window() contentView] addSubview:button_]; |
| 21 } |
| 22 |
| 23 ChevronMenuButton* button_; |
| 24 }; |
| 25 |
| 26 // Test basic view operation. |
| 27 TEST_VIEW(ChevronMenuButtonTest, button_); |
| 28 |
| 29 // |ChevronMenuButton exists entirely to override the cell class. |
| 30 TEST_F(ChevronMenuButtonTest, CellSubclass) { |
| 31 EXPECT_TRUE([[button_ cell] isKindOfClass:[ChevronMenuButtonCell class]]); |
| 32 } |
| 33 |
| 34 // Test both hovered and non-hovered display. |
| 35 TEST_F(ChevronMenuButtonTest, HoverAndNonHoverDisplay) { |
| 36 ChevronMenuButtonCell* cell = [button_ cell]; |
| 37 EXPECT_FALSE([cell showsBorderOnlyWhileMouseInside]); |
| 38 EXPECT_FALSE([cell isMouseInside]); |
| 39 |
| 40 [cell setShowsBorderOnlyWhileMouseInside:YES]; |
| 41 [cell mouseEntered:nil]; |
| 42 EXPECT_TRUE([cell isMouseInside]); |
| 43 [button_ display]; |
| 44 |
| 45 [cell mouseExited:nil]; |
| 46 EXPECT_FALSE([cell isMouseInside]); |
| 47 [button_ display]; |
| 48 } |
| 49 |
| 50 } // namespace |
OLD | NEW |