| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #import "chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.h" | 5 #import "chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 7 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 8 #include "testing/gtest_mac.h" | 8 #include "testing/gtest_mac.h" |
| 9 #include "ui/base/models/accelerator_cocoa.h" | 9 #include "ui/base/models/accelerator_cocoa.h" |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 return exitLabel_; | 28 return exitLabel_; |
| 29 } | 29 } |
| 30 @end | 30 @end |
| 31 | 31 |
| 32 class FullscreenExitBubbleControllerTest : public CocoaTest { | 32 class FullscreenExitBubbleControllerTest : public CocoaTest { |
| 33 public: | 33 public: |
| 34 virtual void SetUp() { | 34 virtual void SetUp() { |
| 35 CocoaTest::SetUp(); | 35 CocoaTest::SetUp(); |
| 36 | 36 |
| 37 controller_.reset( | 37 controller_.reset( |
| 38 [[FullscreenExitBubbleController alloc] initWithOwner:nil browser:nil]); | 38 [[FullscreenExitBubbleController alloc] initWithOwner:nil |
| 39 EXPECT_TRUE([controller_ view]); | 39 browser:nil |
| 40 url:GURL() |
| 41 askPermission:NO]); |
| 42 EXPECT_TRUE([controller_ window]); |
| 43 } |
| 40 | 44 |
| 41 [[test_window() contentView] addSubview:[controller_ view]]; | 45 virtual void TearDown() { |
| 46 [controller_ close]; |
| 47 controller_.reset(); |
| 48 CocoaTest::TearDown(); |
| 42 } | 49 } |
| 43 | 50 |
| 44 scoped_nsobject<FullscreenExitBubbleController> controller_; | 51 scoped_nsobject<FullscreenExitBubbleController> controller_; |
| 45 }; | 52 }; |
| 46 | 53 |
| 47 TEST_VIEW(FullscreenExitBubbleControllerTest, [controller_ view]) | |
| 48 | |
| 49 TEST_F(FullscreenExitBubbleControllerTest, LabelWasReplaced) { | 54 TEST_F(FullscreenExitBubbleControllerTest, LabelWasReplaced) { |
| 50 EXPECT_FALSE([controller_ exitLabelPlaceholder]); | 55 EXPECT_FALSE([controller_ exitLabelPlaceholder]); |
| 51 EXPECT_TRUE([controller_ exitLabel]); | 56 EXPECT_TRUE([controller_ exitLabel]); |
| 52 } | 57 } |
| 53 | 58 |
| 54 TEST_F(FullscreenExitBubbleControllerTest, LabelContainsShortcut) { | 59 TEST_F(FullscreenExitBubbleControllerTest, LabelContainsShortcut) { |
| 55 NSString* shortcut = [FullscreenExitBubbleController keyCommandString]; | 60 NSString* shortcut = [FullscreenExitBubbleController keyCommandString]; |
| 56 EXPECT_GT([shortcut length], 0U); | 61 EXPECT_GT([shortcut length], 0U); |
| 57 | 62 |
| 58 NSString* message = [[[controller_ exitLabel] textStorage] string]; | 63 NSString* message = [[[controller_ exitLabel] textStorage] string]; |
| 59 | 64 |
| 60 NSRange range = [message rangeOfString:shortcut]; | 65 NSRange range = [message rangeOfString:shortcut]; |
| 61 EXPECT_NE(NSNotFound, range.location); | 66 EXPECT_NE(NSNotFound, range.location); |
| 62 } | 67 } |
| 63 | 68 |
| 64 TEST_F(FullscreenExitBubbleControllerTest, ShortcutText) { | 69 TEST_F(FullscreenExitBubbleControllerTest, ShortcutText) { |
| 65 ui::AcceleratorCocoa cmd_F(@"F", NSCommandKeyMask); | 70 ui::AcceleratorCocoa cmd_F(@"F", NSCommandKeyMask); |
| 66 ui::AcceleratorCocoa cmd_shift_f(@"f", NSCommandKeyMask|NSShiftKeyMask); | 71 ui::AcceleratorCocoa cmd_shift_f(@"f", NSCommandKeyMask|NSShiftKeyMask); |
| 67 NSString* cmd_F_text = [FullscreenExitBubbleController | 72 NSString* cmd_F_text = [FullscreenExitBubbleController |
| 68 keyCombinationForAccelerator:cmd_F]; | 73 keyCombinationForAccelerator:cmd_F]; |
| 69 NSString* cmd_shift_f_text = [FullscreenExitBubbleController | 74 NSString* cmd_shift_f_text = [FullscreenExitBubbleController |
| 70 keyCombinationForAccelerator:cmd_shift_f]; | 75 keyCombinationForAccelerator:cmd_shift_f]; |
| 71 EXPECT_NSEQ(cmd_shift_f_text, cmd_F_text); | 76 EXPECT_NSEQ(cmd_shift_f_text, cmd_F_text); |
| 72 EXPECT_NSEQ(@"\u2318\u21E7F", cmd_shift_f_text); | 77 EXPECT_NSEQ(@"\u2318\u21E7F", cmd_shift_f_text); |
| 73 } | 78 } |
| OLD | NEW |