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

Side by Side Diff: ios/chrome/browser/ui/open_in_toolbar_unittest.mm

Issue 2589803002: Upstream Chrome on iOS source code [6/11]. (Closed)
Patch Set: Created 4 years 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 2014 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 #include "base/logging.h"
6 #include "base/mac/scoped_nsobject.h"
7 #import "ios/chrome/browser/ui/open_in_toolbar.h"
8 #include "testing/platform_test.h"
9 #import "third_party/ocmock/OCMock/OCMock.h"
10
11 // A class that counts the number of times the |dummyMethod:| method is called.
12 @interface DummyObserver : NSObject
13
14 // The number of times |dummyMethod:| is invoked.
15 @property(nonatomic, readonly) int dummyMethodCallCount;
16
17 // The method whose invocation increases |dummyMethodCallCount| by one.
18 - (void)dummyMethod:(id)parameter;
19
20 @end
21
22 @implementation DummyObserver
23
24 @synthesize dummyMethodCallCount = _dummyMethodCallCount;
25
26 - (void)dummyMethod:(id)parameter {
27 _dummyMethodCallCount++;
28 }
29
30 @end
31
32 namespace {
33
34 class OpenInToolbarTest : public PlatformTest {
35 protected:
36 UIButton* GetOpenInButtonInToolBar(OpenInToolbar* toolbar) {
37 NSArray* subviews = [toolbar subviews];
38 // Assumes there is only one UIButton in the toolbar.
39 for (UIView* subview in subviews) {
40 if ([subview isKindOfClass:[UIButton class]]) {
41 return (UIButton*)subview;
42 }
43 }
44 return nil;
45 }
46 };
47
48 TEST_F(OpenInToolbarTest, TestButtonActionAndSelector) {
49 base::scoped_nsobject<DummyObserver> dummyObserver(
50 [[DummyObserver alloc] init]);
51 base::scoped_nsobject<OpenInToolbar> openInToolbar([[OpenInToolbar alloc]
52 initWithTarget:dummyObserver
53 action:@selector(dummyMethod:)]);
54 UIButton* button = GetOpenInButtonInToolBar(openInToolbar);
55 ASSERT_TRUE(button);
56 EXPECT_EQ([dummyObserver dummyMethodCallCount], 0);
57 [button sendActionsForControlEvents:UIControlEventTouchUpInside];
58 EXPECT_EQ([dummyObserver dummyMethodCallCount], 1);
59 }
60
61 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/open_in_toolbar.mm ('k') | ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698