| 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 #include <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #import "base/test/ios/wait_util.h" | 9 #import "base/test/ios/wait_util.h" |
| 10 #import "ios/web/public/navigation_manager.h" | 10 #import "ios/web/public/navigation_manager.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 TestUIHandler* ui_handler_; | 127 TestUIHandler* ui_handler_; |
| 128 }; | 128 }; |
| 129 } // namespace | 129 } // namespace |
| 130 | 130 |
| 131 // A test fixture for verifying mojo comminication for WebUI. | 131 // A test fixture for verifying mojo comminication for WebUI. |
| 132 class WebUIMojoTest : public WebIntTest { | 132 class WebUIMojoTest : public WebIntTest { |
| 133 protected: | 133 protected: |
| 134 WebUIMojoTest() | 134 WebUIMojoTest() |
| 135 : web_state_(new WebStateImpl(GetBrowserState())), | 135 : web_state_(new WebStateImpl(GetBrowserState())), |
| 136 ui_handler_(new TestUIHandler()) { | 136 ui_handler_(new TestUIHandler()) { |
| 137 web_state_->GetNavigationManagerImpl().InitializeSession(nil, nil, NO, 0); | 137 web_state_->GetNavigationManagerImpl().InitializeSession(nil, NO); |
| 138 WebUIIOSControllerFactory::RegisterFactory( | 138 WebUIIOSControllerFactory::RegisterFactory( |
| 139 new TestWebUIControllerFactory(ui_handler_.get())); | 139 new TestWebUIControllerFactory(ui_handler_.get())); |
| 140 } | 140 } |
| 141 | 141 |
| 142 // Returns WebState which loads test WebUI page. | 142 // Returns WebState which loads test WebUI page. |
| 143 WebStateImpl* web_state() { return web_state_.get(); } | 143 WebStateImpl* web_state() { return web_state_.get(); } |
| 144 // Returns UI handler which communicates with WebUI page. | 144 // Returns UI handler which communicates with WebUI page. |
| 145 TestUIHandler* test_ui_handler() { return ui_handler_.get(); } | 145 TestUIHandler* test_ui_handler() { return ui_handler_.get(); } |
| 146 | 146 |
| 147 private: | 147 private: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 160 web_state()->GetNavigationManager()->LoadURLWithParams(load_params); | 160 web_state()->GetNavigationManager()->LoadURLWithParams(load_params); |
| 161 | 161 |
| 162 // Wait until |TestUIHandler| receives "ack" message from WebUI page. | 162 // Wait until |TestUIHandler| receives "ack" message from WebUI page. |
| 163 base::test::ios::WaitUntilCondition(^{ | 163 base::test::ios::WaitUntilCondition(^{ |
| 164 base::RunLoop().RunUntilIdle(); | 164 base::RunLoop().RunUntilIdle(); |
| 165 return test_ui_handler()->IsFinReceived(); | 165 return test_ui_handler()->IsFinReceived(); |
| 166 }); | 166 }); |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace web | 169 } // namespace web |
| OLD | NEW |