| 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 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 PlatformTest::TearDown(); | 49 PlatformTest::TearDown(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 base::scoped_nsprotocol<id> delegate_; | 52 base::scoped_nsprotocol<id> delegate_; |
| 53 base::scoped_nsprotocol<id> empty_delegate_; | 53 base::scoped_nsprotocol<id> empty_delegate_; |
| 54 std::unique_ptr<WebStateDelegateBridge> bridge_; | 54 std::unique_ptr<WebStateDelegateBridge> bridge_; |
| 55 std::unique_ptr<WebStateDelegateBridge> empty_delegate_bridge_; | 55 std::unique_ptr<WebStateDelegateBridge> empty_delegate_bridge_; |
| 56 web::TestWebState test_web_state_; | 56 web::TestWebState test_web_state_; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 // Tests |webState:createNewWebStateForURL:openerURL:initiatedByUser:| |
| 60 // forwarding. |
| 61 TEST_F(WebStateDelegateBridgeTest, CreateNewWebState) { |
| 62 ASSERT_FALSE([delegate_ webState]); |
| 63 ASSERT_FALSE([delegate_ webStateCreationRequested]); |
| 64 |
| 65 EXPECT_FALSE( |
| 66 bridge_->CreateNewWebState(&test_web_state_, GURL(), GURL(), true)); |
| 67 |
| 68 EXPECT_EQ(&test_web_state_, [delegate_ webState]); |
| 69 ASSERT_TRUE([delegate_ webStateCreationRequested]); |
| 70 } |
| 71 |
| 59 // Tests |webState:openURLWithParams:| forwarding. | 72 // Tests |webState:openURLWithParams:| forwarding. |
| 60 TEST_F(WebStateDelegateBridgeTest, OpenURLFromWebState) { | 73 TEST_F(WebStateDelegateBridgeTest, OpenURLFromWebState) { |
| 61 ASSERT_FALSE([delegate_ webState]); | 74 ASSERT_FALSE([delegate_ webState]); |
| 62 ASSERT_FALSE([delegate_ openURLParams]); | 75 ASSERT_FALSE([delegate_ openURLParams]); |
| 63 | 76 |
| 64 web::WebState::OpenURLParams params( | 77 web::WebState::OpenURLParams params( |
| 65 GURL("https://chromium.test/"), | 78 GURL("https://chromium.test/"), |
| 66 web::Referrer(GURL("https://chromium2.test/"), ReferrerPolicyNever), | 79 web::Referrer(GURL("https://chromium2.test/"), ReferrerPolicyNever), |
| 67 WindowOpenDisposition::NEW_WINDOW, ui::PAGE_TRANSITION_FORM_SUBMIT, true); | 80 WindowOpenDisposition::NEW_WINDOW, ui::PAGE_TRANSITION_FORM_SUBMIT, true); |
| 68 EXPECT_EQ(&test_web_state_, | 81 EXPECT_EQ(&test_web_state_, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 base::scoped_nsobject<NSURLCredential> credential( | 154 base::scoped_nsobject<NSURLCredential> credential( |
| 142 [[NSURLCredential alloc] init]); | 155 [[NSURLCredential alloc] init]); |
| 143 WebStateDelegate::AuthCallback callback; | 156 WebStateDelegate::AuthCallback callback; |
| 144 bridge_->OnAuthRequired(&test_web_state_, protection_space.get(), | 157 bridge_->OnAuthRequired(&test_web_state_, protection_space.get(), |
| 145 credential.get(), callback); | 158 credential.get(), callback); |
| 146 EXPECT_TRUE([delegate_ authenticationRequested]); | 159 EXPECT_TRUE([delegate_ authenticationRequested]); |
| 147 EXPECT_EQ(&test_web_state_, [delegate_ webState]); | 160 EXPECT_EQ(&test_web_state_, [delegate_ webState]); |
| 148 } | 161 } |
| 149 | 162 |
| 150 } // namespace web | 163 } // namespace web |
| OLD | NEW |