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

Side by Side 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, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 #import "ios/chrome/browser/infobars/infobar_picker_view.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8 #import "testing/gtest_mac.h"
9 #include "third_party/ocmock/OCMock/OCMock.h"
10 #include "third_party/ocmock/gtest_support.h"
11
12 // Test that invoking the right bar button action invokes the "Done" delegate
13 // method.
14 TEST(InfoBarPickerViewTest, DelegateDone) {
15 InfoBarPickerView* infobar_picker_view =
16 [[InfoBarPickerView alloc] initWithFrame:CGRectZero];
17 id mock_delegate =
18 [OCMockObject mockForProtocol:@protocol(InfoBarPickerViewDelegate)];
19 infobar_picker_view.delegate = mock_delegate;
20 [[mock_delegate expect] infoBarPickerViewPressedDone:infobar_picker_view];
21 UIBarButtonItem* rightButton =
22 infobar_picker_view.navigationBar.topItem.rightBarButtonItem;
23 [rightButton.target performSelector:rightButton.action];
24 EXPECT_OCMOCK_VERIFY(mock_delegate);
25 }
26
27 // Test that invoking the left bar button action invokes the "Cancel" delegate
28 // method.
29 TEST(InfoBarPickerViewTest, DelegateCancel) {
30 InfoBarPickerView* infobar_picker_view =
31 [[InfoBarPickerView alloc] initWithFrame:CGRectZero];
32 id mock_delegate =
33 [OCMockObject mockForProtocol:@protocol(InfoBarPickerViewDelegate)];
34 infobar_picker_view.delegate = mock_delegate;
35 [[mock_delegate expect] infoBarPickerViewPressedCancel:infobar_picker_view];
36 UIBarButtonItem* leftButton =
37 infobar_picker_view.navigationBar.topItem.leftBarButtonItem;
38 [leftButton.target performSelector:leftButton.action];
39 EXPECT_OCMOCK_VERIFY(mock_delegate);
40 }
41
42 // Tests that setting the InfoBarPickerView pickerDelegate property sets the
43 // delegate of its picker view.
44 TEST(InfoBarPickerViewTest, PickerViewDelegate) {
45 InfoBarPickerView* infobar_picker_view =
46 [[InfoBarPickerView alloc] initWithFrame:CGRectZero];
47 id mock_picker_delegate =
48 [OCMockObject mockForProtocol:@protocol(UIPickerViewDelegate)];
49 infobar_picker_view.pickerDelegate = mock_picker_delegate;
50 EXPECT_NSEQ(mock_picker_delegate, infobar_picker_view.pickerView.delegate);
51 }
52
53 // Tests that setting the InfoBarPickerView pickerDataSource property sets the
54 // data source of its picker view.
55 TEST(InfoBarPickerViewTest, PickerViewDataSource) {
56 InfoBarPickerView* infobar_picker_view =
57 [[InfoBarPickerView alloc] initWithFrame:CGRectZero];
58 id mock_picker_data_source =
59 [OCMockObject mockForProtocol:@protocol(UIPickerViewDataSource)];
60 infobar_picker_view.pickerDataSource = mock_picker_data_source;
61 EXPECT_NSEQ(mock_picker_data_source,
62 infobar_picker_view.pickerView.dataSource);
63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698