| 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 #include "base/threading/thread_task_runner_handle.h" | |
| 11 #import "ios/web/public/navigation_manager.h" | 10 #import "ios/web/public/navigation_manager.h" |
| 12 #include "ios/web/public/web_ui_ios_data_source.h" | 11 #include "ios/web/public/web_ui_ios_data_source.h" |
| 13 #include "ios/web/public/webui/web_ui_ios_controller.h" | 12 #include "ios/web/public/webui/web_ui_ios_controller.h" |
| 14 #include "ios/web/public/webui/web_ui_ios_controller_factory.h" | 13 #include "ios/web/public/webui/web_ui_ios_controller_factory.h" |
| 15 #include "ios/web/test/grit/test_resources.h" | 14 #include "ios/web/test/grit/test_resources.h" |
| 16 #include "ios/web/test/mojo_test.mojom.h" | 15 #include "ios/web/test/mojo_test.mojom.h" |
| 17 #include "ios/web/test/test_url_constants.h" | 16 #include "ios/web/test/test_url_constants.h" |
| 18 #import "ios/web/test/web_int_test.h" | 17 #import "ios/web/test/web_int_test.h" |
| 19 #import "ios/web/web_state/ui/crw_web_controller.h" | 18 #import "ios/web/web_state/ui/crw_web_controller.h" |
| 20 #import "ios/web/web_state/web_state_impl.h" | 19 #import "ios/web/web_state/web_state_impl.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // |TestUIHandler| sucessfully receives "ack" message from WebUI page. | 154 // |TestUIHandler| sucessfully receives "ack" message from WebUI page. |
| 156 TEST_F(WebUIMojoTest, MessageExchange) { | 155 TEST_F(WebUIMojoTest, MessageExchange) { |
| 157 web_state()->SetWebUsageEnabled(true); | 156 web_state()->SetWebUsageEnabled(true); |
| 158 web_state()->GetView(); // WebState won't load URL without view. | 157 web_state()->GetView(); // WebState won't load URL without view. |
| 159 NavigationManager::WebLoadParams load_params(GURL( | 158 NavigationManager::WebLoadParams load_params(GURL( |
| 160 url::SchemeHostPort(kTestWebUIScheme, kTestWebUIURLHost, 0).Serialize())); | 159 url::SchemeHostPort(kTestWebUIScheme, kTestWebUIURLHost, 0).Serialize())); |
| 161 web_state()->GetNavigationManager()->LoadURLWithParams(load_params); | 160 web_state()->GetNavigationManager()->LoadURLWithParams(load_params); |
| 162 | 161 |
| 163 // Wait until |TestUIHandler| receives "ack" message from WebUI page. | 162 // Wait until |TestUIHandler| receives "ack" message from WebUI page. |
| 164 base::test::ios::WaitUntilCondition(^{ | 163 base::test::ios::WaitUntilCondition(^{ |
| 165 // Flush any pending tasks. Don't RunUntilIdle() because | 164 base::RunLoop().RunUntilIdle(); |
| 166 // RunUntilIdle() is incompatible with mojo::SimpleWatcher's | |
| 167 // automatic arming behavior, which Mojo JS still depends upon. | |
| 168 // | |
| 169 // TODO(crbug.com/701875): Introduce the full watcher API to JS and get rid | |
| 170 // of this hack. | |
| 171 base::RunLoop loop; | |
| 172 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | |
| 173 loop.QuitClosure()); | |
| 174 loop.Run(); | |
| 175 return test_ui_handler()->IsFinReceived(); | 165 return test_ui_handler()->IsFinReceived(); |
| 176 }); | 166 }); |
| 177 } | 167 } |
| 178 | 168 |
| 179 } // namespace web | 169 } // namespace web |
| OLD | NEW |