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.
|