Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(729)

Side by Side Diff: ios/web/webui/web_ui_mojo_inttest.mm

Issue 2725133002: Mojo: Armed Watchers (Closed)
Patch Set: . Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/web/webui/mojo_facade_unittest.mm ('k') | ipc/ipc_sync_channel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
10 #import "ios/web/public/navigation_manager.h" 11 #import "ios/web/public/navigation_manager.h"
11 #include "ios/web/public/web_ui_ios_data_source.h" 12 #include "ios/web/public/web_ui_ios_data_source.h"
12 #include "ios/web/public/webui/web_ui_ios_controller.h" 13 #include "ios/web/public/webui/web_ui_ios_controller.h"
13 #include "ios/web/public/webui/web_ui_ios_controller_factory.h" 14 #include "ios/web/public/webui/web_ui_ios_controller_factory.h"
14 #include "ios/web/test/grit/test_resources.h" 15 #include "ios/web/test/grit/test_resources.h"
15 #include "ios/web/test/mojo_test.mojom.h" 16 #include "ios/web/test/mojo_test.mojom.h"
16 #include "ios/web/test/test_url_constants.h" 17 #include "ios/web/test/test_url_constants.h"
17 #import "ios/web/test/web_int_test.h" 18 #import "ios/web/test/web_int_test.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"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // |TestUIHandler| sucessfully receives "ack" message from WebUI page. 155 // |TestUIHandler| sucessfully receives "ack" message from WebUI page.
155 TEST_F(WebUIMojoTest, MessageExchange) { 156 TEST_F(WebUIMojoTest, MessageExchange) {
156 web_state()->SetWebUsageEnabled(true); 157 web_state()->SetWebUsageEnabled(true);
157 web_state()->GetView(); // WebState won't load URL without view. 158 web_state()->GetView(); // WebState won't load URL without view.
158 NavigationManager::WebLoadParams load_params(GURL( 159 NavigationManager::WebLoadParams load_params(GURL(
159 url::SchemeHostPort(kTestWebUIScheme, kTestWebUIURLHost, 0).Serialize())); 160 url::SchemeHostPort(kTestWebUIScheme, kTestWebUIURLHost, 0).Serialize()));
160 web_state()->GetNavigationManager()->LoadURLWithParams(load_params); 161 web_state()->GetNavigationManager()->LoadURLWithParams(load_params);
161 162
162 // Wait until |TestUIHandler| receives "ack" message from WebUI page. 163 // Wait until |TestUIHandler| receives "ack" message from WebUI page.
163 base::test::ios::WaitUntilCondition(^{ 164 base::test::ios::WaitUntilCondition(^{
164 base::RunLoop().RunUntilIdle(); 165 // Flush any pending tasks. Don't RunUntilIdle() because
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();
165 return test_ui_handler()->IsFinReceived(); 175 return test_ui_handler()->IsFinReceived();
166 }); 176 });
167 } 177 }
168 178
169 } // namespace web 179 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/webui/mojo_facade_unittest.mm ('k') | ipc/ipc_sync_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698