Chromium Code Reviews| 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 | |
| 9 @interface FullscreenExitBubbleController(JustForTesting) | |
| 10 // Already defined. | |
| 11 + (NSString*)keyCommandString; | |
| 12 @end | |
| 13 | |
| 14 @interface FullscreenExitBubbleController(ExposedForTesting) | |
| 15 - (NSTextField*)exitLabelPlaceholder; | |
| 16 - (NSTextView*)exitLabel; | |
| 17 @end | |
| 18 | |
| 19 @implementation FullscreenExitBubbleController(ExposedForTesting) | |
| 20 - (NSTextField*)exitLabelPlaceholder { | |
| 21 return exitLabelPlaceholder_; | |
| 22 } | |
| 23 | |
| 24 - (NSTextView*)exitLabel { | |
| 25 return exitLabel_; | |
| 26 } | |
| 27 @end | |
| 28 | |
| 29 class FullscreenExitBubbleControllerTest : public CocoaTest { | |
| 30 public: | |
| 31 virtual void SetUp() { | |
| 32 CocoaTest::SetUp(); | |
| 33 | |
| 34 controller_.reset( | |
| 35 [[FullscreenExitBubbleController alloc] initWithOwner:nil browser:nil]); | |
| 36 EXPECT_TRUE([controller_ view]); | |
| 37 | |
| 38 [[test_window() contentView] addSubview:[controller_ view]]; | |
| 39 } | |
| 40 | |
| 41 scoped_nsobject<FullscreenExitBubbleController> controller_; | |
| 42 }; | |
| 43 | |
| 44 TEST_VIEW(FullscreenExitBubbleControllerTest, [controller_ view]) | |
| 45 | |
| 46 TEST_F(FullscreenExitBubbleControllerTest, LabelWasReplaced) { | |
| 47 EXPECT_FALSE([controller_ exitLabelPlaceholder]); | |
| 48 EXPECT_TRUE([controller_ exitLabel]); | |
| 49 } | |
| 50 | |
| 51 TEST_F(FullscreenExitBubbleControllerTest, LabelContainsShortcut) { | |
| 52 NSString* shortcut = [FullscreenExitBubbleController keyCommandString]; | |
| 53 EXPECT_GT([shortcut length], 0U); | |
| 54 | |
| 55 NSString* message = [[[controller_ exitLabel] textStorage] string]; | |
| 56 | |
| 57 NSRange range = [message rangeOfString:shortcut]; | |
| 58 EXPECT_NE(NSNotFound, range.location); | |
| 59 } | |
|
Nico
2011/09/15 20:09:14
Can you test keyCombinationForAccelerator:? Both t
jeremya
2011/09/16 03:39:58
Done.
| |
| OLD | NEW |