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/test/web_test_with_web_state.h" | 5 #import "ios/web/public/test/web_test_with_web_state.h" |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
9 #import "base/test/ios/wait_util.h" | 9 #import "base/test/ios/wait_util.h" |
10 #include "ios/web/public/web_state/url_verification_constants.h" | 10 #include "ios/web/public/web_state/url_verification_constants.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 } // namespace | 22 } // namespace |
23 | 23 |
24 namespace web { | 24 namespace web { |
25 | 25 |
26 WebTestWithWebState::WebTestWithWebState() {} | 26 WebTestWithWebState::WebTestWithWebState() {} |
27 | 27 |
28 WebTestWithWebState::~WebTestWithWebState() {} | 28 WebTestWithWebState::~WebTestWithWebState() {} |
29 | 29 |
30 void WebTestWithWebState::SetUp() { | 30 void WebTestWithWebState::SetUp() { |
31 WebTest::SetUp(); | 31 WebTest::SetUp(); |
32 std::unique_ptr<WebStateImpl> web_state(new WebStateImpl(GetBrowserState())); | 32 web::WebState::CreateParams params(GetBrowserState()); |
33 web_state->GetNavigationManagerImpl().InitializeSession(NO); | 33 web_state_ = web::WebState::Create(params); |
34 web_state->SetWebUsageEnabled(true); | 34 web_state_->SetWebUsageEnabled(true); |
35 web_state_.reset(web_state.release()); | |
36 | 35 |
37 // Force generation of child views; necessary for some tests. | 36 // Force generation of child views; necessary for some tests. |
38 [GetWebController(web_state_.get()) triggerPendingLoad]; | 37 [GetWebController(web_state()) triggerPendingLoad]; |
39 } | 38 } |
40 | 39 |
41 void WebTestWithWebState::TearDown() { | 40 void WebTestWithWebState::TearDown() { |
42 DestroyWebState(); | 41 DestroyWebState(); |
43 WebTest::TearDown(); | 42 WebTest::TearDown(); |
44 } | 43 } |
45 | 44 |
46 void WebTestWithWebState::LoadHtml(NSString* html, const GURL& url) { | 45 void WebTestWithWebState::LoadHtml(NSString* html, const GURL& url) { |
47 // Sets MIME type to "text/html" once navigation is committed. | 46 // Sets MIME type to "text/html" once navigation is committed. |
48 class MimeTypeUpdater : public WebStateObserver { | 47 class MimeTypeUpdater : public WebStateObserver { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 150 |
152 void WebTestWithWebState::WillProcessTask(const base::PendingTask&) { | 151 void WebTestWithWebState::WillProcessTask(const base::PendingTask&) { |
153 // Nothing to do. | 152 // Nothing to do. |
154 } | 153 } |
155 | 154 |
156 void WebTestWithWebState::DidProcessTask(const base::PendingTask&) { | 155 void WebTestWithWebState::DidProcessTask(const base::PendingTask&) { |
157 processed_a_task_ = true; | 156 processed_a_task_ = true; |
158 } | 157 } |
159 | 158 |
160 } // namespace web | 159 } // namespace web |
OLD | NEW |