| 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);
|
| +}
|
|
|