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

Unified Diff: ios/chrome/browser/infobars/infobar_picker_view_unittest.mm

Issue 2107743002: Add InfoBarPickerController for displaying a picker view from an infobar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@update_passwords_strings
Patch Set: Created 4 years, 6 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: ios/chrome/browser/infobars/infobar_picker_view_unittest.mm
diff --git a/ios/chrome/browser/infobars/infobar_picker_view_unittest.mm b/ios/chrome/browser/infobars/infobar_picker_view_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..404a7d15c296ff5d8bf52e10c64c303bfee08dcd
--- /dev/null
+++ b/ios/chrome/browser/infobars/infobar_picker_view_unittest.mm
@@ -0,0 +1,63 @@
+// Copyright 2016 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.
+
+#import "ios/chrome/browser/infobars/infobar_picker_view.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+#import "testing/gtest_mac.h"
+#include "third_party/ocmock/OCMock/OCMock.h"
+#include "third_party/ocmock/gtest_support.h"
+
+// Test that invoking the right bar button action invokes the "Done" delegate
+// method.
+TEST(InfoBarPickerViewTest, DelegateDone) {
+ InfoBarPickerView* infobar_picker_view =
+ [[InfoBarPickerView alloc] initWithFrame:CGRectZero];
+ id mock_delegate =
+ [OCMockObject mockForProtocol:@protocol(InfoBarPickerViewDelegate)];
+ infobar_picker_view.delegate = mock_delegate;
+ [[mock_delegate expect] infoBarPickerViewPressedDone:infobar_picker_view];
+ UIBarButtonItem* rightButton =
+ infobar_picker_view.navigationBar.topItem.rightBarButtonItem;
+ [rightButton.target performSelector:rightButton.action];
+ EXPECT_OCMOCK_VERIFY(mock_delegate);
+}
+
+// Test that invoking the left bar button action invokes the "Cancel" delegate
+// method.
+TEST(InfoBarPickerViewTest, DelegateCancel) {
+ InfoBarPickerView* infobar_picker_view =
+ [[InfoBarPickerView alloc] initWithFrame:CGRectZero];
+ id mock_delegate =
+ [OCMockObject mockForProtocol:@protocol(InfoBarPickerViewDelegate)];
+ infobar_picker_view.delegate = mock_delegate;
+ [[mock_delegate expect] infoBarPickerViewPressedCancel:infobar_picker_view];
+ UIBarButtonItem* leftButton =
+ infobar_picker_view.navigationBar.topItem.leftBarButtonItem;
+ [leftButton.target performSelector:leftButton.action];
+ EXPECT_OCMOCK_VERIFY(mock_delegate);
+}
+
+// Tests that setting the InfoBarPickerView pickerDelegate property sets the
+// delegate of its picker view.
+TEST(InfoBarPickerViewTest, PickerViewDelegate) {
+ InfoBarPickerView* infobar_picker_view =
+ [[InfoBarPickerView alloc] initWithFrame:CGRectZero];
+ id mock_picker_delegate =
+ [OCMockObject mockForProtocol:@protocol(UIPickerViewDelegate)];
+ infobar_picker_view.pickerDelegate = mock_picker_delegate;
+ EXPECT_NSEQ(mock_picker_delegate, infobar_picker_view.pickerView.delegate);
+}
+
+// Tests that setting the InfoBarPickerView pickerDataSource property sets the
+// data source of its picker view.
+TEST(InfoBarPickerViewTest, PickerViewDataSource) {
+ InfoBarPickerView* infobar_picker_view =
+ [[InfoBarPickerView alloc] initWithFrame:CGRectZero];
+ id mock_picker_data_source =
+ [OCMockObject mockForProtocol:@protocol(UIPickerViewDataSource)];
+ infobar_picker_view.pickerDataSource = mock_picker_data_source;
+ EXPECT_NSEQ(mock_picker_data_source,
+ infobar_picker_view.pickerView.dataSource);
+}

Powered by Google App Engine
This is Rietveld 408576698