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..850a9feadb896c22dadde0e0cfbad9e9487a0f3a |
| --- /dev/null |
| +++ b/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm |
| @@ -0,0 +1,72 @@ |
| +// 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" |
| +#include "ui/base/models/accelerator_cocoa.h" |
| + |
| +@interface FullscreenExitBubbleController(JustForTesting) |
| +// Already defined. |
| ++ (NSString*)keyCommandString; |
| ++ (NSString*)keyCombinationForAccelerator:(const ui::AcceleratorCocoa&)item; |
| +@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); |
| +} |
| + |
| +TEST_F(FullscreenExitBubbleControllerTest, ShortcutText) { |
| + ui::AcceleratorCocoa cmd_F(@"F", NSCommandKeyMask); |
| + ui::AcceleratorCocoa cmd_shift_f(@"f", NSCommandKeyMask|NSShiftKeyMask); |
| + NSString* cmd_F_text = [FullscreenExitBubbleController |
| + keyCombinationForAccelerator:cmd_F]; |
| + NSString* cmd_shift_f_text = [FullscreenExitBubbleController |
| + keyCombinationForAccelerator:cmd_shift_f]; |
| + EXPECT_TRUE([cmd_shift_f_text isEqualToString:cmd_F_text]); |
|
Nico
2011/09/16 18:24:05
EXPECT_NSEQ
|
| + EXPECT_TRUE([cmd_shift_f_text isEqualToString:@"\u2318\u21E7F"]); |
| +} |