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") { ...@@ -346,11 +346,10 @@ source_set("test_support") {
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
testonly = true testonly = true
sources = [ sources = [
"public/test/crw_mock_web_state_delegate.h", "public/test/crw_fake_web_state_delegate.h",
"public/test/crw_mock_web_state_delegate.mm", "public/test/crw_fake_web_state_delegate.mm",
] ]
deps = [ deps = [
"//ios/testing:ocmock_support",
"//ios/web", "//ios/web",
] ]
} }
......
...@@ -2,15 +2,14 @@ ...@@ -2,15 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef 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_MOCK_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" #import "ios/web/public/web_state_delegate_bridge.h"
// Stub implementation for CRWWebStateDelegate protocol. // Stub implementation for CRWWebStateDelegate protocol.
@interface CRWMockWebStateDelegate @interface CRWFakeWebStateDelegate : NSObject <CRWWebStateDelegate>
: OCMockComplexTypeHelper<CRWWebStateDelegate>
// web::WebState::OpenURLParams in |webState:openURLWithParams:| call. // web::WebState::OpenURLParams in |webState:openURLWithParams:| call.
@property(nonatomic, readonly) @property(nonatomic, readonly)
const web::WebState::OpenURLParams* openURLParams; const web::WebState::OpenURLParams* openURLParams;
...@@ -51,4 +50,4 @@ ...@@ -51,4 +50,4 @@
@end @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 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // 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/ui/context_menu_params.h"
#import "ios/web/public/web_state.h" #import "ios/web/public/web_state.h"
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
@implementation CRWMockWebStateDelegate { @implementation CRWFakeWebStateDelegate {
// Backs up the property with the same name. // Backs up the property with the same name.
std::unique_ptr<web::WebState::OpenURLParams> _openURLParams; std::unique_ptr<web::WebState::OpenURLParams> _openURLParams;
// Backs up the property with the same name. // Backs up the property with the same name.
......
...@@ -10,10 +10,11 @@ ...@@ -10,10 +10,11 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/strings/utf_string_conversions.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/test/fakes/test_web_state.h"
#import "ios/web/public/ui/context_menu_params.h" #import "ios/web/public/ui/context_menu_params.h"
#include "testing/platform_test.h" #include "testing/platform_test.h"
#import "third_party/ocmock/OCMock/OCMock.h"
#import "third_party/ocmock/gtest_support.h" #import "third_party/ocmock/gtest_support.h"
#include "ui/base/page_transition_types.h" #include "ui/base/page_transition_types.h"
...@@ -25,6 +26,7 @@ ...@@ -25,6 +26,7 @@
// any optional methods. // any optional methods.
@interface TestEmptyWebStateDelegate : NSObject<CRWWebStateDelegate> @interface TestEmptyWebStateDelegate : NSObject<CRWWebStateDelegate>
@end @end
@implementation TestEmptyWebStateDelegate @implementation TestEmptyWebStateDelegate
@end @end
...@@ -36,10 +38,7 @@ class WebStateDelegateBridgeTest : public PlatformTest { ...@@ -36,10 +38,7 @@ class WebStateDelegateBridgeTest : public PlatformTest {
void SetUp() override { void SetUp() override {
PlatformTest::SetUp(); PlatformTest::SetUp();
id originalMockDelegate = delegate_ = [[CRWFakeWebStateDelegate alloc] init];
[OCMockObject niceMockForProtocol:@protocol(CRWWebStateDelegate)];
delegate_ = [[CRWMockWebStateDelegate alloc]
initWithRepresentedObject:originalMockDelegate];
empty_delegate_ = [[TestEmptyWebStateDelegate alloc] init]; empty_delegate_ = [[TestEmptyWebStateDelegate alloc] init];
bridge_.reset(new WebStateDelegateBridge(delegate_)); bridge_.reset(new WebStateDelegateBridge(delegate_));
...@@ -47,11 +46,10 @@ class WebStateDelegateBridgeTest : public PlatformTest { ...@@ -47,11 +46,10 @@ class WebStateDelegateBridgeTest : public PlatformTest {
} }
void TearDown() override { void TearDown() override {
EXPECT_OCMOCK_VERIFY((OCMockObject*)delegate_);
PlatformTest::TearDown(); PlatformTest::TearDown();
} }
CRWMockWebStateDelegate* delegate_; CRWFakeWebStateDelegate* delegate_;
id empty_delegate_; id empty_delegate_;
std::unique_ptr<WebStateDelegateBridge> bridge_; std::unique_ptr<WebStateDelegateBridge> bridge_;
std::unique_ptr<WebStateDelegateBridge> empty_delegate_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