Commit 4dbd54be authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

Remove unnecessary use of OCMockComplexTypeHelper

CRWMockWebStateDelegate did not forward any message to the
represented object passed in its constructor, nor was used
with any OCMock methods to expect/stub/reject invocation.

Since it is a fake implementation of CRWWebStateDelegate
and can subclass NSObject. Rename the class since it is not
a mock.

Bug: none
Change-Id: I225cbc0da44f406060ea040108c6c735ca6cac94
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1903140
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Auto-Submit: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713788}
parent 336a38dd
......@@ -346,11 +346,10 @@ source_set("test_support") {
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [
"public/test/crw_mock_web_state_delegate.h",
"public/test/crw_mock_web_state_delegate.mm",
"public/test/crw_fake_web_state_delegate.h",
"public/test/crw_fake_web_state_delegate.mm",
]
deps = [
"//ios/testing:ocmock_support",
"//ios/web",
]
}
......
......@@ -2,15 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_WEB_PUBLIC_TEST_CRW_MOCK_WEB_STATE_DELEGATE_H_
#define IOS_WEB_PUBLIC_TEST_CRW_MOCK_WEB_STATE_DELEGATE_H_
#ifndef IOS_WEB_PUBLIC_TEST_CRW_FAKE_WEB_STATE_DELEGATE_H_
#define IOS_WEB_PUBLIC_TEST_CRW_FAKE_WEB_STATE_DELEGATE_H_
#import "ios/testing/ocmock_complex_type_helper.h"
#import "ios/web/public/web_state_delegate_bridge.h"
// Stub implementation for CRWWebStateDelegate protocol.
@interface CRWMockWebStateDelegate
: OCMockComplexTypeHelper<CRWWebStateDelegate>
@interface CRWFakeWebStateDelegate : NSObject <CRWWebStateDelegate>
// web::WebState::OpenURLParams in |webState:openURLWithParams:| call.
@property(nonatomic, readonly)
const web::WebState::OpenURLParams* openURLParams;
......@@ -51,4 +50,4 @@
@end
#endif // IOS_WEB_PUBLIC_TEST_CRW_MOCK_WEB_STATE_DELEGATE_H_
#endif // IOS_WEB_PUBLIC_TEST_CRW_FAKE_WEB_STATE_DELEGATE_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/web/public/test/crw_mock_web_state_delegate.h"
#import "ios/web/public/test/crw_fake_web_state_delegate.h"
#import "ios/web/public/ui/context_menu_params.h"
#import "ios/web/public/web_state.h"
......@@ -11,7 +11,7 @@
#error "This file requires ARC support."
#endif
@implementation CRWMockWebStateDelegate {
@implementation CRWFakeWebStateDelegate {
// Backs up the property with the same name.
std::unique_ptr<web::WebState::OpenURLParams> _openURLParams;
// Backs up the property with the same name.
......
......@@ -10,10 +10,11 @@
#include "base/bind.h"
#include "base/strings/utf_string_conversions.h"
#import "ios/web/public/test/crw_mock_web_state_delegate.h"
#import "ios/web/public/test/crw_fake_web_state_delegate.h"
#import "ios/web/public/test/fakes/test_web_state.h"
#import "ios/web/public/ui/context_menu_params.h"
#include "testing/platform_test.h"
#import "third_party/ocmock/OCMock/OCMock.h"
#import "third_party/ocmock/gtest_support.h"
#include "ui/base/page_transition_types.h"
......@@ -25,6 +26,7 @@
// any optional methods.
@interface TestEmptyWebStateDelegate : NSObject<CRWWebStateDelegate>
@end
@implementation TestEmptyWebStateDelegate
@end
......@@ -36,10 +38,7 @@ class WebStateDelegateBridgeTest : public PlatformTest {
void SetUp() override {
PlatformTest::SetUp();
id originalMockDelegate =
[OCMockObject niceMockForProtocol:@protocol(CRWWebStateDelegate)];
delegate_ = [[CRWMockWebStateDelegate alloc]
initWithRepresentedObject:originalMockDelegate];
delegate_ = [[CRWFakeWebStateDelegate alloc] init];
empty_delegate_ = [[TestEmptyWebStateDelegate alloc] init];
bridge_.reset(new WebStateDelegateBridge(delegate_));
......@@ -47,11 +46,10 @@ class WebStateDelegateBridgeTest : public PlatformTest {
}
void TearDown() override {
EXPECT_OCMOCK_VERIFY((OCMockObject*)delegate_);
PlatformTest::TearDown();
}
CRWMockWebStateDelegate* delegate_;
CRWFakeWebStateDelegate* delegate_;
id empty_delegate_;
std::unique_ptr<WebStateDelegateBridge> bridge_;
std::unique_ptr<WebStateDelegateBridge> empty_delegate_bridge_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment