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

Side by Side Diff: chrome/browser/cocoa/bubble_view_unittest.mm

Issue 196043: Pretty-up the blocked popup view by sharing code from the status bubble. Bloc... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 3 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
Property Changes:
Name: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 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 <Cocoa/Cocoa.h>
6
7 #include "base/scoped_nsobject.h"
8 #import "chrome/browser/cocoa/bubble_view.h"
9 #include "chrome/browser/cocoa/cocoa_test_helper.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/platform_test.h"
12
13 class BubbleViewTest : public PlatformTest {
14 public:
15 BubbleViewTest() {
16 NSRect frame = NSMakeRect(0, 0, 50, 50);
17 view_.reset([[BubbleView alloc] initWithFrame:frame
18 themeProvider:cocoa_helper_.window()]);
19 [cocoa_helper_.contentView() addSubview:view_.get()];
20 [view_ setContent:@"Hi there, I'm a bubble view"];
21 }
22
23 CocoaTestHelper cocoa_helper_;
24 scoped_nsobject<BubbleView> view_;
25 };
26
27 // Test adding/removing from the view hierarchy, mostly to ensure nothing
28 // leaks or crashes.
29 TEST_F(BubbleViewTest, AddRemove) {
30 EXPECT_EQ(cocoa_helper_.contentView(), [view_ superview]);
31 [view_.get() removeFromSuperview];
32 EXPECT_FALSE([view_ superview]);
33 }
34
35 // Test drawing, mostly to ensure nothing leaks or crashes.
36 TEST_F(BubbleViewTest, Display) {
37 [view_ display];
38 }
39
40 // Test a nil themeProvider in init.
41 TEST_F(BubbleViewTest, NilThemeProvider) {
42 NSRect frame = NSMakeRect(0, 0, 50, 50);
43 view_.reset([[BubbleView alloc] initWithFrame:frame
44 themeProvider:nil]);
45 [cocoa_helper_.contentView() addSubview:view_.get()];
46 [view_ display];
47 }
48
49 // Make sure things don't go haywire when given invalid or extra-long strings
rohitrao (ping after 24h) 2009/09/08 19:25:21 Is there any value in testing displaying extra-lon
pink (ping after 24hrs) 2009/09/08 19:50:17 No, not really. I can remove.
50 TEST_F(BubbleViewTest, SetContent) {
51 [view_ setContent:nil];
52 EXPECT_TRUE([view_ content] == nil);
53 [view_ setContent:@""];
54 EXPECT_TRUE([[view_ content] isEqualToString:@""]);
55 NSString* str = @"This is just a really long string that's just too long";
56 [view_ setContent:str];
57 EXPECT_TRUE([str isEqualToString:[view_ content]]);
58 }
59
60 TEST_F(BubbleViewTest, CornerFlags) {
61 // Set some random flags just to check.
62 [view_ setCornerFlags:kRoundedTopRightCorner | kRoundedTopLeftCorner];
63 EXPECT_EQ([view_ cornerFlags],
64 (unsigned long)kRoundedTopRightCorner | kRoundedTopLeftCorner);
65 // Set no flags (all 4 draw corners are square).
66 [view_ setCornerFlags:0];
67 EXPECT_EQ([view_ cornerFlags], 0UL);
68 // Set all bits. Meaningless past the first 4, but harmless to set too many.
69 [view_ setCornerFlags:0xFFFFFFFF];
70 EXPECT_EQ([view_ cornerFlags], 0xFFFFFFFF);
71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698