Chromium Code Reviews| Index: chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm |
| diff --git a/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..426fd6b144b4b2cb4269dd15e94d7e612b6c2c94 |
| --- /dev/null |
| +++ b/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm |
| @@ -0,0 +1,59 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import "chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.h" |
| + |
| +#include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
| + |
| +@interface FullscreenExitBubbleController(JustForTesting) |
| +// Already defined. |
| ++ (NSString*)keyCommandString; |
| +@end |
| + |
| +@interface FullscreenExitBubbleController(ExposedForTesting) |
| +- (NSTextField*)exitLabelPlaceholder; |
| +- (NSTextView*)exitLabel; |
| +@end |
| + |
| +@implementation FullscreenExitBubbleController(ExposedForTesting) |
| +- (NSTextField*)exitLabelPlaceholder { |
| + return exitLabelPlaceholder_; |
| +} |
| + |
| +- (NSTextView*)exitLabel { |
| + return exitLabel_; |
| +} |
| +@end |
| + |
| +class FullscreenExitBubbleControllerTest : public CocoaTest { |
| + public: |
| + virtual void SetUp() { |
| + CocoaTest::SetUp(); |
| + |
| + controller_.reset( |
| + [[FullscreenExitBubbleController alloc] initWithOwner:nil browser:nil]); |
| + EXPECT_TRUE([controller_ view]); |
| + |
| + [[test_window() contentView] addSubview:[controller_ view]]; |
| + } |
| + |
| + scoped_nsobject<FullscreenExitBubbleController> controller_; |
| +}; |
| + |
| +TEST_VIEW(FullscreenExitBubbleControllerTest, [controller_ view]) |
| + |
| +TEST_F(FullscreenExitBubbleControllerTest, LabelWasReplaced) { |
| + EXPECT_FALSE([controller_ exitLabelPlaceholder]); |
| + EXPECT_TRUE([controller_ exitLabel]); |
| +} |
| + |
| +TEST_F(FullscreenExitBubbleControllerTest, LabelContainsShortcut) { |
| + NSString* shortcut = [FullscreenExitBubbleController keyCommandString]; |
| + EXPECT_GT([shortcut length], 0U); |
| + |
| + NSString* message = [[[controller_ exitLabel] textStorage] string]; |
| + |
| + NSRange range = [message rangeOfString:shortcut]; |
| + EXPECT_NE(NSNotFound, range.location); |
| +} |
|
Nico
2011/09/15 20:09:14
Can you test keyCombinationForAccelerator:? Both t
jeremya
2011/09/16 03:39:58
Done.
|