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

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

Issue 2946383002: Support new-style Mojo JS core API on IOS. (Closed)
Patch Set: . Created 3 years, 5 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
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 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #import "ios/testing/wait_util.h" 10 #import "ios/testing/wait_util.h"
11 #include "ios/web/grit/ios_web_resources.h"
11 #import "ios/web/public/navigation_manager.h" 12 #import "ios/web/public/navigation_manager.h"
12 #include "ios/web/public/web_state/web_state_interface_provider.h" 13 #include "ios/web/public/web_state/web_state_interface_provider.h"
13 #include "ios/web/public/web_ui_ios_data_source.h" 14 #include "ios/web/public/web_ui_ios_data_source.h"
14 #include "ios/web/public/webui/web_ui_ios_controller.h" 15 #include "ios/web/public/webui/web_ui_ios_controller.h"
15 #include "ios/web/public/webui/web_ui_ios_controller_factory.h" 16 #include "ios/web/public/webui/web_ui_ios_controller_factory.h"
16 #include "ios/web/test/grit/test_resources.h" 17 #include "ios/web/test/grit/test_resources.h"
17 #include "ios/web/test/mojo_test.mojom.h" 18 #include "ios/web/test/mojo_test.mojom.h"
18 #include "ios/web/test/test_url_constants.h" 19 #include "ios/web/test/test_url_constants.h"
19 #import "ios/web/test/web_int_test.h" 20 #import "ios/web/test/web_int_test.h"
20 #import "ios/web/web_state/ui/crw_web_controller.h" 21 #import "ios/web/web_state/ui/crw_web_controller.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 class TestUI : public WebUIIOSController { 92 class TestUI : public WebUIIOSController {
92 public: 93 public:
93 // Constructs controller from |web_ui| and |ui_handler| which will communicate 94 // Constructs controller from |web_ui| and |ui_handler| which will communicate
94 // with test WebUI page. 95 // with test WebUI page.
95 TestUI(WebUIIOS* web_ui, TestUIHandler* ui_handler) 96 TestUI(WebUIIOS* web_ui, TestUIHandler* ui_handler)
96 : WebUIIOSController(web_ui) { 97 : WebUIIOSController(web_ui) {
97 web::WebUIIOSDataSource* source = 98 web::WebUIIOSDataSource* source =
98 web::WebUIIOSDataSource::Create(kTestWebUIURLHost); 99 web::WebUIIOSDataSource::Create(kTestWebUIURLHost);
99 100
100 source->AddResourcePath("mojo_test.js", IDR_MOJO_TEST_JS); 101 source->AddResourcePath("mojo_test.js", IDR_MOJO_TEST_JS);
101 source->AddResourcePath("ios/web/test/mojo_test.mojom", 102 source->AddResourcePath("mojo_bindings.js", IDR_IOS_MOJO_BINDINGS_JS);
102 IDR_MOJO_TEST_MOJO_JS); 103 source->AddResourcePath("mojo_test.mojom.js", IDR_MOJO_TEST_MOJO_JS);
103 source->SetDefaultResource(IDR_MOJO_TEST_HTML); 104 source->SetDefaultResource(IDR_MOJO_TEST_HTML);
104 105
105 web::WebState* web_state = web_ui->GetWebState(); 106 web::WebState* web_state = web_ui->GetWebState();
106 web::WebUIIOSDataSource::Add(web_state->GetBrowserState(), source); 107 web::WebUIIOSDataSource::Add(web_state->GetBrowserState(), source);
107 108
108 web_state->GetWebStateInterfaceProvider()->registry()->AddInterface( 109 web_state->GetWebStateInterfaceProvider()->registry()->AddInterface(
109 base::Bind(&TestUIHandler::BindTestUIHandlerMojoRequest, 110 base::Bind(&TestUIHandler::BindTestUIHandlerMojoRequest,
110 base::Unretained(ui_handler))); 111 base::Unretained(ui_handler)));
111 } 112 }
112 }; 113 };
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 loop.Run(); 188 loop.Run();
188 return test_ui_handler()->IsFinReceived(); 189 return test_ui_handler()->IsFinReceived();
189 }); 190 });
190 191
191 ASSERT_TRUE(fin_received); 192 ASSERT_TRUE(fin_received);
192 EXPECT_FALSE(web_state()->IsLoading()); 193 EXPECT_FALSE(web_state()->IsLoading());
193 EXPECT_EQ(url, web_state()->GetLastCommittedURL()); 194 EXPECT_EQ(url, web_state()->GetLastCommittedURL());
194 } 195 }
195 196
196 } // namespace web 197 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/webui/resources/web_ui_module_load_notifier.js ('k') | mojo/public/js/new_bindings/base.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698