OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #import "chrome/browser/ui/cocoa/constrained_window/cw_alert.h" | |
6 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | |
7 | |
8 class CWAlertTest : public CocoaTest { | |
9 }; | |
10 | |
11 TEST_F(CWAlertTest, Show) { | |
12 scoped_nsobject<CWAlert> alert([[CWAlert alloc] init]); | |
13 EXPECT_TRUE([alert window]); | |
14 EXPECT_TRUE([alert closeButton]); | |
15 | |
16 [alert setMessageText:@"Message text"]; | |
17 [alert setInformativeText:@"Informative text"]; | |
18 [alert addButtonWithTitle:@"OK" keyEquivalent:@""]; | |
19 [alert addButtonWithTitle:@"Cancel" keyEquivalent:@""]; | |
20 | |
21 [alert layout]; | |
22 [[alert window] makeKeyAndOrderFront:nil]; | |
23 } | |
24 | |
25 TEST_F(CWAlertTest, AccessoryView) { | |
26 scoped_nsobject<CWAlert> alert([[CWAlert alloc] init]); | |
27 EXPECT_FALSE([alert accessoryView]); | |
28 | |
29 NSRect view_rect = NSMakeRect(0, 0, 700, 300); | |
30 scoped_nsobject<NSView> view([[NSView alloc] initWithFrame:view_rect]); | |
31 [alert setAccessoryView:view]; | |
32 | |
33 [alert layout]; | |
34 NSRect window_rect = [[alert window] frame]; | |
35 EXPECT_GT(NSWidth(window_rect), NSWidth(view_rect)); | |
36 EXPECT_GT(NSHeight(window_rect), NSHeight(view_rect)); | |
37 | |
38 [[alert window] makeKeyAndOrderFront:nil]; | |
39 } | |
OLD | NEW |