| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 #include "base/scoped_nsobject.h" | 6 #include "base/scoped_nsobject.h" |
| 7 #import "chrome/browser/cocoa/bubble_view.h" | 7 #import "chrome/browser/cocoa/bubble_view.h" |
| 8 #include "chrome/browser/cocoa/cocoa_test_helper.h" | 8 #include "chrome/browser/cocoa/cocoa_test_helper.h" |
| 9 #import "testing/gtest_mac.h" |
| 9 | 10 |
| 10 class BubbleViewTest : public CocoaTest { | 11 class BubbleViewTest : public CocoaTest { |
| 11 public: | 12 public: |
| 12 BubbleViewTest() { | 13 BubbleViewTest() { |
| 13 NSRect frame = NSMakeRect(0, 0, 50, 50); | 14 NSRect frame = NSMakeRect(0, 0, 50, 50); |
| 14 scoped_nsobject<BubbleView> view( | 15 scoped_nsobject<BubbleView> view( |
| 15 [[BubbleView alloc] initWithFrame:frame themeProvider:test_window()]); | 16 [[BubbleView alloc] initWithFrame:frame themeProvider:test_window()]); |
| 16 view_ = view.get(); | 17 view_ = view.get(); |
| 17 [[test_window() contentView] addSubview:view_]; | 18 [[test_window() contentView] addSubview:view_]; |
| 18 [view_ setContent:@"Hi there, I'm a bubble view"]; | 19 [view_ setContent:@"Hi there, I'm a bubble view"]; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 30 [[BubbleView alloc] initWithFrame:frame themeProvider:nil]); | 31 [[BubbleView alloc] initWithFrame:frame themeProvider:nil]); |
| 31 [[test_window() contentView] addSubview:view.get()]; | 32 [[test_window() contentView] addSubview:view.get()]; |
| 32 [view display]; | 33 [view display]; |
| 33 } | 34 } |
| 34 | 35 |
| 35 // Make sure things don't go haywire when given invalid or long strings. | 36 // Make sure things don't go haywire when given invalid or long strings. |
| 36 TEST_F(BubbleViewTest, SetContent) { | 37 TEST_F(BubbleViewTest, SetContent) { |
| 37 [view_ setContent:nil]; | 38 [view_ setContent:nil]; |
| 38 EXPECT_TRUE([view_ content] == nil); | 39 EXPECT_TRUE([view_ content] == nil); |
| 39 [view_ setContent:@""]; | 40 [view_ setContent:@""]; |
| 40 EXPECT_TRUE([[view_ content] isEqualToString:@""]); | 41 EXPECT_NSEQ(@"", [view_ content]); |
| 41 NSString* str = @"This is a really really long string that's just too long"; | 42 NSString* str = @"This is a really really long string that's just too long"; |
| 42 [view_ setContent:str]; | 43 [view_ setContent:str]; |
| 43 EXPECT_TRUE([[view_ content] isEqualToString:str]); | 44 EXPECT_NSEQ(str, [view_ content]); |
| 44 } | 45 } |
| 45 | 46 |
| 46 TEST_F(BubbleViewTest, CornerFlags) { | 47 TEST_F(BubbleViewTest, CornerFlags) { |
| 47 // Set some random flags just to check. | 48 // Set some random flags just to check. |
| 48 [view_ setCornerFlags:kRoundedTopRightCorner | kRoundedTopLeftCorner]; | 49 [view_ setCornerFlags:kRoundedTopRightCorner | kRoundedTopLeftCorner]; |
| 49 EXPECT_EQ([view_ cornerFlags], | 50 EXPECT_EQ([view_ cornerFlags], |
| 50 (unsigned long)kRoundedTopRightCorner | kRoundedTopLeftCorner); | 51 (unsigned long)kRoundedTopRightCorner | kRoundedTopLeftCorner); |
| 51 // Set no flags (all 4 draw corners are square). | 52 // Set no flags (all 4 draw corners are square). |
| 52 [view_ setCornerFlags:0]; | 53 [view_ setCornerFlags:0]; |
| 53 EXPECT_EQ([view_ cornerFlags], 0UL); | 54 EXPECT_EQ([view_ cornerFlags], 0UL); |
| 54 // Set all bits. Meaningless past the first 4, but harmless to set too many. | 55 // Set all bits. Meaningless past the first 4, but harmless to set too many. |
| 55 [view_ setCornerFlags:0xFFFFFFFF]; | 56 [view_ setCornerFlags:0xFFFFFFFF]; |
| 56 EXPECT_EQ([view_ cornerFlags], 0xFFFFFFFF); | 57 EXPECT_EQ([view_ cornerFlags], 0xFFFFFFFF); |
| 57 } | 58 } |
| OLD | NEW |