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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/profiles/avatar_button_unittest.mm
diff --git a/chrome/browser/ui/cocoa/profiles/avatar_button_unittest.mm b/chrome/browser/ui/cocoa/profiles/avatar_button_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..941629608d4fc9239b943582c0fbbb9054effd13
--- /dev/null
+++ b/chrome/browser/ui/cocoa/profiles/avatar_button_unittest.mm
@@ -0,0 +1,54 @@
+// 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.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "chrome/browser/ui/cocoa/profiles/avatar_button.h"
+
+#import "base/mac/scoped_nsobject.h"
+#import "ui/gfx/test/ui_cocoa_test_helper.h"
+
+@interface AvatarButton (ExposedForTesting)
+- (void)performRightClick;
+@end
+
+@interface AvatarButtonTestObserver: NSObject
Alexei Svitkine (slow) 2015/02/18 19:58:09 Nit: Space before :
anthonyvd 2015/02/19 03:12:52 Done.
+@property BOOL clicked;
+- (id)init;
+- (void)buttonRightClicked;
+@end
+
+@implementation AvatarButtonTestObserver
+@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
+- (id)init {
+ self.clicked = NO;
+ return self;
+}
+- (void)buttonRightClicked {
+ self.clicked = YES;
+}
+@end
+
+namespace {
+
+class AvatarButtonTest : public ui::CocoaTest {
+public:
Alexei Svitkine (slow) 2015/02/18 19:58:09 Nit: Indent 1 more
anthonyvd 2015/02/19 03:12:52 Done.
+ AvatarButtonTest() {
+ NSRect content_frame = [[test_window() contentView] frame];
+ base::scoped_nsobject<AvatarButton> button(
+ [[AvatarButton alloc] initWithFrame:content_frame]);
+ button_ = button.get();
+ [[test_window() contentView] addSubview:button_];
+ }
+
+ AvatarButton* button_;
+};
+
+TEST_F(AvatarButtonTest, RightClick) {
+ 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.
+ [button_ setTarget:obs];
+ [button_ setRightAction:@selector(buttonRightClicked)];
+ [button_ performRightClick];
+ ASSERT_TRUE(obs.clicked);
+}
+
+} // 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.

Powered by Google App Engine
This is Rietveld 408576698