| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/test/web_test.h" | 5 #import "ios/web/test/web_test.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #import "base/test/ios/wait_util.h" | 12 #import "base/test/ios/wait_util.h" |
| 13 #import "ios/testing/ocmock_complex_type_helper.h" | 13 #import "ios/testing/ocmock_complex_type_helper.h" |
| 14 #import "ios/web/navigation/crw_session_controller.h" | 14 #import "ios/web/navigation/crw_session_controller.h" |
| 15 #include "ios/web/public/active_state_manager.h" | 15 #include "ios/web/public/active_state_manager.h" |
| 16 #include "ios/web/public/referrer.h" | 16 #include "ios/web/public/referrer.h" |
| 17 #include "ios/web/public/url_schemes.h" |
| 17 #import "ios/web/public/web_state/ui/crw_web_delegate.h" | 18 #import "ios/web/public/web_state/ui/crw_web_delegate.h" |
| 18 #import "ios/web/web_state/ui/crw_web_controller.h" | 19 #import "ios/web/web_state/ui/crw_web_controller.h" |
| 19 #import "ios/web/web_state/web_state_impl.h" | 20 #import "ios/web/web_state/web_state_impl.h" |
| 20 #include "third_party/ocmock/OCMock/OCMock.h" | 21 #include "third_party/ocmock/OCMock/OCMock.h" |
| 21 | 22 |
| 22 // Helper Mock to stub out API with C++ objects in arguments. | 23 // Helper Mock to stub out API with C++ objects in arguments. |
| 23 @interface WebDelegateMock : OCMockComplexTypeHelper | 24 @interface WebDelegateMock : OCMockComplexTypeHelper |
| 24 @end | 25 @end |
| 25 | 26 |
| 26 @implementation WebDelegateMock | 27 @implementation WebDelegateMock |
| 27 // Stub implementation always returns YES. | 28 // Stub implementation always returns YES. |
| 28 - (BOOL)webController:(CRWWebController*)webController | 29 - (BOOL)webController:(CRWWebController*)webController |
| 29 shouldOpenURL:(const GURL&)url | 30 shouldOpenURL:(const GURL&)url |
| 30 mainDocumentURL:(const GURL&)mainDocumentURL | 31 mainDocumentURL:(const GURL&)mainDocumentURL |
| 31 linkClicked:(BOOL)linkClicked { | 32 linkClicked:(BOOL)linkClicked { |
| 32 return YES; | 33 return YES; |
| 33 } | 34 } |
| 34 @end | 35 @end |
| 35 | 36 |
| 36 namespace web { | 37 namespace web { |
| 37 | 38 |
| 38 #pragma mark - | 39 #pragma mark - |
| 39 | 40 |
| 40 WebTest::WebTest() : web_client_(base::WrapUnique(new TestWebClient)) {} | 41 WebTest::WebTest() : web_client_(base::WrapUnique(new TestWebClient)) { |
| 42 static dispatch_once_t onceToken; |
| 43 dispatch_once(&onceToken, ^{ |
| 44 RegisterWebSchemes(true); |
| 45 }); |
| 46 } |
| 47 |
| 41 WebTest::~WebTest() {} | 48 WebTest::~WebTest() {} |
| 42 | 49 |
| 43 void WebTest::SetUp() { | 50 void WebTest::SetUp() { |
| 44 PlatformTest::SetUp(); | 51 PlatformTest::SetUp(); |
| 45 BrowserState::GetActiveStateManager(&browser_state_)->SetActive(true); | 52 BrowserState::GetActiveStateManager(&browser_state_)->SetActive(true); |
| 46 } | 53 } |
| 47 | 54 |
| 48 void WebTest::TearDown() { | 55 void WebTest::TearDown() { |
| 49 BrowserState::GetActiveStateManager(&browser_state_)->SetActive(false); | 56 BrowserState::GetActiveStateManager(&browser_state_)->SetActive(false); |
| 50 PlatformTest::TearDown(); | 57 PlatformTest::TearDown(); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 218 } |
| 212 return false; | 219 return false; |
| 213 } | 220 } |
| 214 | 221 |
| 215 NSString* WebTestWithWebController::CreateLoadCheck() { | 222 NSString* WebTestWithWebController::CreateLoadCheck() { |
| 216 return [NSString stringWithFormat:@"<p style=\"display: none;\">%d</p>", | 223 return [NSString stringWithFormat:@"<p style=\"display: none;\">%d</p>", |
| 217 s_html_load_count++]; | 224 s_html_load_count++]; |
| 218 } | 225 } |
| 219 | 226 |
| 220 } // namespace web | 227 } // namespace web |
| OLD | NEW |