Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: chrome/browser/ui/cocoa/intents/web_intent_progress_view_controller_unittest.mm

Issue 11009017: Mac Web Intents Part 11: Progress view (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: a Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 // Need for the progress indicator timer.
24 MessageLoop message_loop_;
25 };
26
27 TEST_VIEW(WebIntentProgressViewControllerTest, view_)
28
29 TEST_F(WebIntentProgressViewControllerTest, Layout) {
30 const CGFloat margin = 10;
31 NSRect inner_frame = NSMakeRect(margin, margin, 100, 50);
32
33 // Layout with empty title and message.
34 NSSize empty_size =
35 [view_controller_ minimumSizeForInnerWidth:NSWidth(inner_frame)];
36 EXPECT_LE(empty_size.width, NSWidth(inner_frame));
37 [view_ setFrame:NSInsetRect(inner_frame, -margin, -margin)];
38 [view_controller_ layoutSubviewsWithinFrame:inner_frame];
39
40 // Layout with a long string that wraps.
41 NSString* string = @"A quick brown fox jumps over the lazy dog.";
42 [view_controller_ setTitle:string];
43 [view_controller_ setMessage:string];
44 NSSize new_size =
45 [view_controller_ minimumSizeForInnerWidth:NSWidth(inner_frame)];
46 EXPECT_GE(new_size.width, empty_size.width);
47 EXPECT_GT(new_size.height, empty_size.height);
48 EXPECT_EQ(NSWidth(inner_frame), new_size.width);
49 inner_frame.size.height = new_size.height;
50 [view_ setFrame:NSInsetRect(inner_frame, -margin, -margin)];
51 [view_controller_ layoutSubviewsWithinFrame:inner_frame];
52
53 // Verify that all controls are inside the inner frame.
54 for (NSView* child in [view_ subviews])
55 EXPECT_TRUE(NSContainsRect(inner_frame, [child frame]));
56 }
57
58 TEST_F(WebIntentProgressViewControllerTest, Progress) {
59 [view_controller_ setPercentDone:-1];
60 [view_ display];
61 [view_controller_ setPercentDone:50];
62 [view_ display];
63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698