| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011 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 "chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.h" |
| 6 |
| 7 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
| 8 #include "testing/gtest_mac.h" |
| 9 #include "ui/base/models/accelerator_cocoa.h" |
| 10 |
| 11 @interface FullscreenExitBubbleController(JustForTesting) |
| 12 // Already defined. |
| 13 + (NSString*)keyCommandString; |
| 14 + (NSString*)keyCombinationForAccelerator:(const ui::AcceleratorCocoa&)item; |
| 15 @end |
| 16 |
| 17 @interface FullscreenExitBubbleController(ExposedForTesting) |
| 18 - (NSTextField*)exitLabelPlaceholder; |
| 19 - (NSTextView*)exitLabel; |
| 20 @end |
| 21 |
| 22 @implementation FullscreenExitBubbleController(ExposedForTesting) |
| 23 - (NSTextField*)exitLabelPlaceholder { |
| 24 return exitLabelPlaceholder_; |
| 25 } |
| 26 |
| 27 - (NSTextView*)exitLabel { |
| 28 return exitLabel_; |
| 29 } |
| 30 @end |
| 31 |
| 32 class FullscreenExitBubbleControllerTest : public CocoaTest { |
| 33 public: |
| 34 virtual void SetUp() { |
| 35 CocoaTest::SetUp(); |
| 36 |
| 37 controller_.reset( |
| 38 [[FullscreenExitBubbleController alloc] initWithOwner:nil browser:nil]); |
| 39 EXPECT_TRUE([controller_ view]); |
| 40 |
| 41 [[test_window() contentView] addSubview:[controller_ view]]; |
| 42 } |
| 43 |
| 44 scoped_nsobject<FullscreenExitBubbleController> controller_; |
| 45 }; |
| 46 |
| 47 TEST_VIEW(FullscreenExitBubbleControllerTest, [controller_ view]) |
| 48 |
| 49 TEST_F(FullscreenExitBubbleControllerTest, LabelWasReplaced) { |
| 50 EXPECT_FALSE([controller_ exitLabelPlaceholder]); |
| 51 EXPECT_TRUE([controller_ exitLabel]); |
| 52 } |
| 53 |
| 54 TEST_F(FullscreenExitBubbleControllerTest, LabelContainsShortcut) { |
| 55 NSString* shortcut = [FullscreenExitBubbleController keyCommandString]; |
| 56 EXPECT_GT([shortcut length], 0U); |
| 57 |
| 58 NSString* message = [[[controller_ exitLabel] textStorage] string]; |
| 59 |
| 60 NSRange range = [message rangeOfString:shortcut]; |
| 61 EXPECT_NE(NSNotFound, range.location); |
| 62 } |
| 63 |
| 64 TEST_F(FullscreenExitBubbleControllerTest, ShortcutText) { |
| 65 ui::AcceleratorCocoa cmd_F(@"F", NSCommandKeyMask); |
| 66 ui::AcceleratorCocoa cmd_shift_f(@"f", NSCommandKeyMask|NSShiftKeyMask); |
| 67 NSString* cmd_F_text = [FullscreenExitBubbleController |
| 68 keyCombinationForAccelerator:cmd_F]; |
| 69 NSString* cmd_shift_f_text = [FullscreenExitBubbleController |
| 70 keyCombinationForAccelerator:cmd_shift_f]; |
| 71 EXPECT_NSEQ(cmd_shift_f_text, cmd_F_text); |
| 72 EXPECT_NSEQ(@"\u2318\u21E7F", cmd_shift_f_text); |
| 73 } |
| OLD | NEW |