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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/open_in_toolbar_unittest.mm
diff --git a/ios/chrome/browser/ui/open_in_toolbar_unittest.mm b/ios/chrome/browser/ui/open_in_toolbar_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..aac8fb7b628fe865f8befbb990e2265c08265e6a
--- /dev/null
+++ b/ios/chrome/browser/ui/open_in_toolbar_unittest.mm
@@ -0,0 +1,61 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/logging.h"
+#include "base/mac/scoped_nsobject.h"
+#import "ios/chrome/browser/ui/open_in_toolbar.h"
+#include "testing/platform_test.h"
+#import "third_party/ocmock/OCMock/OCMock.h"
+
+// A class that counts the number of times the |dummyMethod:| method is called.
+@interface DummyObserver : NSObject
+
+// The number of times |dummyMethod:| is invoked.
+@property(nonatomic, readonly) int dummyMethodCallCount;
+
+// The method whose invocation increases |dummyMethodCallCount| by one.
+- (void)dummyMethod:(id)parameter;
+
+@end
+
+@implementation DummyObserver
+
+@synthesize dummyMethodCallCount = _dummyMethodCallCount;
+
+- (void)dummyMethod:(id)parameter {
+ _dummyMethodCallCount++;
+}
+
+@end
+
+namespace {
+
+class OpenInToolbarTest : public PlatformTest {
+ protected:
+ UIButton* GetOpenInButtonInToolBar(OpenInToolbar* toolbar) {
+ NSArray* subviews = [toolbar subviews];
+ // Assumes there is only one UIButton in the toolbar.
+ for (UIView* subview in subviews) {
+ if ([subview isKindOfClass:[UIButton class]]) {
+ return (UIButton*)subview;
+ }
+ }
+ return nil;
+ }
+};
+
+TEST_F(OpenInToolbarTest, TestButtonActionAndSelector) {
+ base::scoped_nsobject<DummyObserver> dummyObserver(
+ [[DummyObserver alloc] init]);
+ base::scoped_nsobject<OpenInToolbar> openInToolbar([[OpenInToolbar alloc]
+ initWithTarget:dummyObserver
+ action:@selector(dummyMethod:)]);
+ UIButton* button = GetOpenInButtonInToolBar(openInToolbar);
+ ASSERT_TRUE(button);
+ EXPECT_EQ([dummyObserver dummyMethodCallCount], 0);
+ [button sendActionsForControlEvents:UIControlEventTouchUpInside];
+ EXPECT_EQ([dummyObserver dummyMethodCallCount], 1);
+}
+
+} // namespace
« 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