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 "base/memory/scoped_nsobject.h" | |
6 #include "base/message_loop.h" | |
7 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | |
8 #import "chrome/browser/ui/cocoa/intents/web_intent_progress_view_controller.h" | |
9 #include "testing/gtest/include/gtest/gtest.h" | |
10 #include "testing/platform_test.h" | |
11 | |
12 class WebIntentProgressViewControllerTest : public CocoaTest { | |
13 public: | |
14 WebIntentProgressViewControllerTest() { | |
15 view_controller_.reset([[WebIntentProgressViewController alloc] init]); | |
16 view_.reset([[view_controller_ view] retain]); | |
17 [[test_window() contentView] addSubview:view_]; | |
18 } | |
19 | |
20 protected: | |
21 scoped_nsobject<WebIntentProgressViewController> view_controller_; | |
22 scoped_nsobject<NSView> view_; | |
23 MessageLoop message_loop_; | |
Robert Sesek
2012/10/10 21:29:36
What's this for?
sail
2012/10/10 21:39:10
This is need for the Timer used by the progress in
Robert Sesek
2012/10/10 21:40:58
Can you copy the comment to the other test, too?
sail
2012/10/10 21:47:41
Done.
| |
24 }; | |
25 | |
26 TEST_VIEW(WebIntentProgressViewControllerTest, view_) | |
27 | |
28 TEST_F(WebIntentProgressViewControllerTest, Layout) { | |
29 const CGFloat margin = 10; | |
30 NSRect inner_frame = NSMakeRect(margin, margin, 100, 50); | |
31 | |
32 // Layout with empty title and message. | |
33 NSSize empty_size = | |
34 [view_controller_ minimumSizeForInnerWidth:NSWidth(inner_frame)]; | |
35 EXPECT_LE(empty_size.width, NSWidth(inner_frame)); | |
36 [view_ setFrame:NSInsetRect(inner_frame, -margin, -margin)]; | |
37 [view_controller_ layoutSubviewsWithinFrame:inner_frame]; | |
38 | |
39 // Layout with a long string that wraps. | |
40 NSString* string = @"A quick brown fox jumps over the lazy dog."; | |
41 [view_controller_ setTitle:string]; | |
42 [view_controller_ setMessage:string]; | |
43 NSSize new_size = | |
44 [view_controller_ minimumSizeForInnerWidth:NSWidth(inner_frame)]; | |
45 EXPECT_GE(new_size.width, empty_size.width); | |
46 EXPECT_GT(new_size.height, empty_size.height); | |
47 EXPECT_EQ(NSWidth(inner_frame), new_size.width); | |
48 inner_frame.size.height = new_size.height; | |
49 [view_ setFrame:NSInsetRect(inner_frame, -margin, -margin)]; | |
50 [view_controller_ layoutSubviewsWithinFrame:inner_frame]; | |
51 | |
52 // Verify that all controls are inside the inner frame. | |
53 for (NSView* child in [view_ subviews]) | |
54 EXPECT_TRUE(NSContainsRect(inner_frame, [child frame])); | |
55 } | |
56 | |
57 TEST_F(WebIntentProgressViewControllerTest, Progress) { | |
58 [view_controller_ setPercentDone:-1]; | |
59 [view_ display]; | |
60 [view_controller_ setPercentDone:50]; | |
61 [view_ display]; | |
62 } | |
OLD | NEW |