| 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/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #import "base/test/ios/wait_util.h" | 8 #import "base/test/ios/wait_util.h" |
| 9 #include "ios/public/provider/web/web_ui_ios_controller.h" | 9 #include "ios/public/provider/web/web_ui_ios_controller.h" |
| 10 #include "ios/public/provider/web/web_ui_ios_controller_factory.h" | 10 #include "ios/public/provider/web/web_ui_ios_controller_factory.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 private: | 141 private: |
| 142 std::unique_ptr<WebStateImpl> web_state_; | 142 std::unique_ptr<WebStateImpl> web_state_; |
| 143 std::unique_ptr<TestUIHandler> ui_handler_; | 143 std::unique_ptr<TestUIHandler> ui_handler_; |
| 144 }; | 144 }; |
| 145 | 145 |
| 146 // Tests that JS can send messages to the native code and vice versa. | 146 // Tests that JS can send messages to the native code and vice versa. |
| 147 // TestUIHandler is used for communication and test suceeds only when | 147 // TestUIHandler is used for communication and test suceeds only when |
| 148 // |TestUIHandler| sucessfully receives "ack" message from WebUI page. | 148 // |TestUIHandler| sucessfully receives "ack" message from WebUI page. |
| 149 TEST_F(WebUIMojoTest, MessageExchange) { | 149 TEST_F(WebUIMojoTest, MessageExchange) { |
| 150 web_state()->SetWebUsageEnabled(true); | 150 web_state()->SetWebUsageEnabled(true); |
| 151 web_state()->GetWebController().useMojoForWebUI = YES; | |
| 152 web_state()->GetView(); // WebState won't load URL without view. | 151 web_state()->GetView(); // WebState won't load URL without view. |
| 153 NavigationManager::WebLoadParams load_params(GURL( | 152 NavigationManager::WebLoadParams load_params(GURL( |
| 154 url::SchemeHostPort(kTestWebUIScheme, kTestWebUIURLHost, 0).Serialize())); | 153 url::SchemeHostPort(kTestWebUIScheme, kTestWebUIURLHost, 0).Serialize())); |
| 155 web_state()->GetNavigationManager()->LoadURLWithParams(load_params); | 154 web_state()->GetNavigationManager()->LoadURLWithParams(load_params); |
| 156 | 155 |
| 157 // Wait until |TestUIHandler| receives "ack" message from WebUI page. | 156 // Wait until |TestUIHandler| receives "ack" message from WebUI page. |
| 158 base::test::ios::WaitUntilCondition(^{ | 157 base::test::ios::WaitUntilCondition(^{ |
| 159 base::RunLoop().RunUntilIdle(); | 158 base::RunLoop().RunUntilIdle(); |
| 160 return test_ui_handler()->IsFinReceived(); | 159 return test_ui_handler()->IsFinReceived(); |
| 161 }); | 160 }); |
| 162 } | 161 } |
| 163 | 162 |
| 164 } // namespace web | 163 } // namespace web |
| OLD | NEW |