| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/web/public/web_state/web_state_delegate_bridge.h" | 5 #import "ios/web/public/web_state/web_state_delegate_bridge.h" |
| 6 | 6 |
| 7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/mac/bind_objc_block.h" | 11 #include "base/mac/bind_objc_block.h" |
| 12 #import "base/mac/scoped_nsobject.h" | 12 #import "base/mac/scoped_nsobject.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #import "ios/web/public/test/crw_mock_web_state_delegate.h" |
| 14 #import "ios/web/public/test/fakes/test_web_state.h" | 15 #import "ios/web/public/test/fakes/test_web_state.h" |
| 15 #import "ios/web/public/web_state/context_menu_params.h" | 16 #import "ios/web/public/web_state/context_menu_params.h" |
| 16 #import "ios/web/web_state/web_state_delegate_stub.h" | |
| 17 #include "testing/platform_test.h" | 17 #include "testing/platform_test.h" |
| 18 #import "third_party/ocmock/gtest_support.h" | 18 #import "third_party/ocmock/gtest_support.h" |
| 19 #include "ui/base/page_transition_types.h" | 19 #include "ui/base/page_transition_types.h" |
| 20 | 20 |
| 21 // Class which conforms to CRWWebStateDelegate protocol, but does not implement | 21 // Class which conforms to CRWWebStateDelegate protocol, but does not implement |
| 22 // any optional methods. | 22 // any optional methods. |
| 23 @interface TestEmptyWebStateDelegate : NSObject<CRWWebStateDelegate> | 23 @interface TestEmptyWebStateDelegate : NSObject<CRWWebStateDelegate> |
| 24 @end | 24 @end |
| 25 @implementation TestEmptyWebStateDelegate | 25 @implementation TestEmptyWebStateDelegate |
| 26 @end | 26 @end |
| 27 | 27 |
| 28 namespace web { | 28 namespace web { |
| 29 | 29 |
| 30 // Test fixture to test WebStateDelegateBridge class. | 30 // Test fixture to test WebStateDelegateBridge class. |
| 31 class WebStateDelegateBridgeTest : public PlatformTest { | 31 class WebStateDelegateBridgeTest : public PlatformTest { |
| 32 protected: | 32 protected: |
| 33 void SetUp() override { | 33 void SetUp() override { |
| 34 PlatformTest::SetUp(); | 34 PlatformTest::SetUp(); |
| 35 | 35 |
| 36 id originalMockDelegate = | 36 id originalMockDelegate = |
| 37 [OCMockObject niceMockForProtocol:@protocol(CRWWebStateDelegate)]; | 37 [OCMockObject niceMockForProtocol:@protocol(CRWWebStateDelegate)]; |
| 38 delegate_.reset([[CRWWebStateDelegateStub alloc] | 38 delegate_.reset([[CRWMockWebStateDelegate alloc] |
| 39 initWithRepresentedObject:originalMockDelegate]); | 39 initWithRepresentedObject:originalMockDelegate]); |
| 40 empty_delegate_.reset([[TestEmptyWebStateDelegate alloc] init]); | 40 empty_delegate_.reset([[TestEmptyWebStateDelegate alloc] init]); |
| 41 | 41 |
| 42 bridge_.reset(new WebStateDelegateBridge(delegate_.get())); | 42 bridge_.reset(new WebStateDelegateBridge(delegate_.get())); |
| 43 empty_delegate_bridge_.reset( | 43 empty_delegate_bridge_.reset( |
| 44 new WebStateDelegateBridge(empty_delegate_.get())); | 44 new WebStateDelegateBridge(empty_delegate_.get())); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void TearDown() override { | 47 void TearDown() override { |
| 48 EXPECT_OCMOCK_VERIFY(delegate_); | 48 EXPECT_OCMOCK_VERIFY(delegate_); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 base::scoped_nsobject<NSURLCredential> credential( | 148 base::scoped_nsobject<NSURLCredential> credential( |
| 149 [[NSURLCredential alloc] init]); | 149 [[NSURLCredential alloc] init]); |
| 150 WebStateDelegate::AuthCallback callback; | 150 WebStateDelegate::AuthCallback callback; |
| 151 bridge_->OnAuthRequired(&test_web_state_, protection_space.get(), | 151 bridge_->OnAuthRequired(&test_web_state_, protection_space.get(), |
| 152 credential.get(), callback); | 152 credential.get(), callback); |
| 153 EXPECT_TRUE([delegate_ authenticationRequested]); | 153 EXPECT_TRUE([delegate_ authenticationRequested]); |
| 154 EXPECT_EQ(&test_web_state_, [delegate_ webState]); | 154 EXPECT_EQ(&test_web_state_, [delegate_ webState]); |
| 155 } | 155 } |
| 156 | 156 |
| 157 } // namespace web | 157 } // namespace web |
| OLD | NEW |