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

Side by Side Diff: chrome/browser/ui/cocoa/profiles/avatar_button_unittest.mm

Issue 916523003: Bring up fast user switcher on right-click of the avatar menu on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unit test and fix issues from CR Created 5 years, 10 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
OLDNEW
(Empty)
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
Alexei Svitkine (slow) 2015/02/18 19:58:09 No (c)
anthonyvd 2015/02/19 03:12:52 Done.
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/profiles/avatar_button.h"
6
7 #import "base/mac/scoped_nsobject.h"
8 #import "ui/gfx/test/ui_cocoa_test_helper.h"
9
10 @interface AvatarButton (ExposedForTesting)
11 - (void)performRightClick;
12 @end
13
14 @interface AvatarButtonTestObserver: NSObject
Alexei Svitkine (slow) 2015/02/18 19:58:09 Nit: Space before :
anthonyvd 2015/02/19 03:12:52 Done.
15 @property BOOL clicked;
16 - (id)init;
17 - (void)buttonRightClicked;
18 @end
19
20 @implementation AvatarButtonTestObserver
21 @synthesize clicked;
Robert Sesek 2015/02/18 18:51:37 clicked = clicked_;
anthonyvd 2015/02/19 03:12:52 Done.
Robert Sesek 2015/02/19 21:54:21 Sorry if this comment was confusing. The @property
22 - (id)init {
23 self.clicked = NO;
24 return self;
25 }
26 - (void)buttonRightClicked {
27 self.clicked = YES;
28 }
29 @end
30
31 namespace {
32
33 class AvatarButtonTest : public ui::CocoaTest {
34 public:
Alexei Svitkine (slow) 2015/02/18 19:58:09 Nit: Indent 1 more
anthonyvd 2015/02/19 03:12:52 Done.
35 AvatarButtonTest() {
36 NSRect content_frame = [[test_window() contentView] frame];
37 base::scoped_nsobject<AvatarButton> button(
38 [[AvatarButton alloc] initWithFrame:content_frame]);
39 button_ = button.get();
40 [[test_window() contentView] addSubview:button_];
41 }
42
43 AvatarButton* button_;
44 };
45
46 TEST_F(AvatarButtonTest, RightClick) {
47 AvatarButtonTestObserver* obs = [[AvatarButtonTestObserver alloc] init];
Alexei Svitkine (slow) 2015/02/18 19:58:09 Is this leaked? Probably should be scoped_nsobjec
anthonyvd 2015/02/19 03:12:52 Done.
48 [button_ setTarget:obs];
49 [button_ setRightAction:@selector(buttonRightClicked)];
50 [button_ performRightClick];
51 ASSERT_TRUE(obs.clicked);
52 }
53
54 } // namespace
Alexei Svitkine (slow) 2015/02/18 19:58:09 Usually, the TEST_F() code isn't inside an anon na
anthonyvd 2015/02/19 03:12:52 Done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698