Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / constrained_window / constrained_window_button_unittest.mm
blobed9b40c478e9028d846d97c12318410c8a252796
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
3 // found in the LICENSE file.
5 #import "base/mac/scoped_nsobject.h"
6 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
7 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "testing/platform_test.h"
11 class ConstrainedWindowButtonTest : public CocoaTest {
12  public:
13   ConstrainedWindowButtonTest() {
14     NSRect frame = NSMakeRect(0, 0, 50, 30);
15     button_.reset([[ConstrainedWindowButton alloc] initWithFrame:frame]);
16     [button_ setTitle:@"Abcdefg"];
17     [button_ sizeToFit];
18     [[test_window() contentView] addSubview:button_];
19   }
21  protected:
22   base::scoped_nsobject<ConstrainedWindowButton> button_;
25 TEST_VIEW(ConstrainedWindowButtonTest, button_)
27 // Test hover, mostly to ensure nothing leaks or crashes.
28 TEST_F(ConstrainedWindowButtonTest, DisplayWithHover) {
29   [[button_ cell] setIsMouseInside:NO];
30   [button_ display];
31   [[button_ cell] setIsMouseInside:YES];
32   [button_ display];
35 // Test disabled, mostly to ensure nothing leaks or crashes.
36 TEST_F(ConstrainedWindowButtonTest, DisplayWithDisable) {
37   [button_ setEnabled:YES];
38   [button_ display];
39   [button_ setEnabled:NO];
40   [button_ display];
43 // Test pushed, mostly to ensure nothing leaks or crashes.
44 TEST_F(ConstrainedWindowButtonTest, DisplayWithPushed) {
45   [[button_ cell] setHighlighted:NO];
46   [button_ display];
47   [[button_ cell] setHighlighted:YES];
48   [button_ display];
51 // Tracking rects
52 TEST_F(ConstrainedWindowButtonTest, TrackingRects) {
53   ConstrainedWindowButtonCell* cell = [button_ cell];
54   EXPECT_FALSE([cell isMouseInside]);
56   [button_ mouseEntered:nil];
57   EXPECT_TRUE([cell isMouseInside]);
58   [button_ mouseExited:nil];
59   EXPECT_FALSE([cell isMouseInside]);