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