Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm

Issue 7890056: FullscreenExitBubble temp UI for Mac. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: browser tests Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 "ui/base/models/accelerator_cocoa.h"
9
10 @interface FullscreenExitBubbleController(JustForTesting)
11 // Already defined.
12 + (NSString*)keyCommandString;
13 + (NSString*)keyCombinationForAccelerator:(const ui::AcceleratorCocoa&)item;
14 @end
15
16 @interface FullscreenExitBubbleController(ExposedForTesting)
17 - (NSTextField*)exitLabelPlaceholder;
18 - (NSTextView*)exitLabel;
19 @end
20
21 @implementation FullscreenExitBubbleController(ExposedForTesting)
22 - (NSTextField*)exitLabelPlaceholder {
23 return exitLabelPlaceholder_;
24 }
25
26 - (NSTextView*)exitLabel {
27 return exitLabel_;
28 }
29 @end
30
31 class FullscreenExitBubbleControllerTest : public CocoaTest {
32 public:
33 virtual void SetUp() {
34 CocoaTest::SetUp();
35
36 controller_.reset(
37 [[FullscreenExitBubbleController alloc] initWithOwner:nil browser:nil]);
38 EXPECT_TRUE([controller_ view]);
39
40 [[test_window() contentView] addSubview:[controller_ view]];
41 }
42
43 scoped_nsobject<FullscreenExitBubbleController> controller_;
44 };
45
46 TEST_VIEW(FullscreenExitBubbleControllerTest, [controller_ view])
47
48 TEST_F(FullscreenExitBubbleControllerTest, LabelWasReplaced) {
49 EXPECT_FALSE([controller_ exitLabelPlaceholder]);
50 EXPECT_TRUE([controller_ exitLabel]);
51 }
52
53 TEST_F(FullscreenExitBubbleControllerTest, LabelContainsShortcut) {
54 NSString* shortcut = [FullscreenExitBubbleController keyCommandString];
55 EXPECT_GT([shortcut length], 0U);
56
57 NSString* message = [[[controller_ exitLabel] textStorage] string];
58
59 NSRange range = [message rangeOfString:shortcut];
60 EXPECT_NE(NSNotFound, range.location);
61 }
62
63 TEST_F(FullscreenExitBubbleControllerTest, ShortcutText) {
64 ui::AcceleratorCocoa cmd_F(@"F", NSCommandKeyMask);
65 ui::AcceleratorCocoa cmd_shift_f(@"f", NSCommandKeyMask|NSShiftKeyMask);
66 NSString* cmd_F_text = [FullscreenExitBubbleController
67 keyCombinationForAccelerator:cmd_F];
68 NSString* cmd_shift_f_text = [FullscreenExitBubbleController
69 keyCombinationForAccelerator:cmd_shift_f];
70 EXPECT_TRUE([cmd_shift_f_text isEqualToString:cmd_F_text]);
Nico 2011/09/16 18:24:05 EXPECT_NSEQ
71 EXPECT_TRUE([cmd_shift_f_text isEqualToString:@"\u2318\u21E7F"]);
72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698