Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <limits> | 5 #include <limits> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "content/public/common/service_registry.h" | 22 #include "content/public/common/service_registry.h" |
| 23 #include "content/public/common/url_utils.h" | 23 #include "content/public/common/url_utils.h" |
| 24 #include "content/public/test/browser_test_utils.h" | 24 #include "content/public/test/browser_test_utils.h" |
| 25 #include "content/public/test/content_browser_test.h" | 25 #include "content/public/test/content_browser_test.h" |
| 26 #include "content/public/test/content_browser_test_utils.h" | 26 #include "content/public/test/content_browser_test_utils.h" |
| 27 #include "content/shell/browser/shell.h" | 27 #include "content/shell/browser/shell.h" |
| 28 #include "content/test/data/web_ui_test_mojo_bindings.mojom.h" | 28 #include "content/test/data/web_ui_test_mojo_bindings.mojom.h" |
| 29 #include "mojo/test/test_utils.h" | 29 #include "mojo/test/test_utils.h" |
| 30 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" | 30 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" |
| 31 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h" | 31 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h" |
| 32 #include "third_party/mojo/src/mojo/public/js/constants.h" | 32 #include "third_party/mojo/src/mojo/public/js/constants.h" |
|
mmenke
2015/11/03 19:12:57
include embedded_test_server.h
svaldez
2015/11/03 19:33:16
Done.
| |
| 33 | 33 |
| 34 namespace content { | 34 namespace content { |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 bool got_message = false; | 37 bool got_message = false; |
| 38 | 38 |
| 39 // The bindings for the page are generated from a .mojom file. This code looks | 39 // The bindings for the page are generated from a .mojom file. This code looks |
| 40 // up the generated file from disk and returns it. | 40 // up the generated file from disk and returns it. |
| 41 bool GetResource(const std::string& id, | 41 bool GetResource(const std::string& id, |
| 42 const WebUIDataSource::GotDataCallback& callback) { | 42 const WebUIDataSource::GotDataCallback& callback) { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 } | 194 } |
| 195 | 195 |
| 196 // Loads a webui page that contains mojo bindings and verifies a message makes | 196 // Loads a webui page that contains mojo bindings and verifies a message makes |
| 197 // it from the browser to the page and back. | 197 // it from the browser to the page and back. |
| 198 IN_PROC_BROWSER_TEST_F(WebUIMojoTest, EndToEndPing) { | 198 IN_PROC_BROWSER_TEST_F(WebUIMojoTest, EndToEndPing) { |
| 199 if (!IsGeneratedResourceAvailable( | 199 if (!IsGeneratedResourceAvailable( |
| 200 "content/test/data/web_ui_test_mojo_bindings.mojom")) | 200 "content/test/data/web_ui_test_mojo_bindings.mojom")) |
| 201 return; | 201 return; |
| 202 | 202 |
| 203 got_message = false; | 203 got_message = false; |
| 204 ASSERT_TRUE(test_server()->Start()); | 204 ASSERT_TRUE(embedded_test_server()->Start()); |
| 205 base::RunLoop run_loop; | 205 base::RunLoop run_loop; |
| 206 factory()->set_run_loop(&run_loop); | 206 factory()->set_run_loop(&run_loop); |
| 207 GURL test_url(test_server()->GetURL("files/web_ui_mojo.html?ping")); | 207 GURL test_url(embedded_test_server()->GetURL("/web_ui_mojo.html?ping")); |
| 208 NavigateToURL(shell(), test_url); | 208 NavigateToURL(shell(), test_url); |
| 209 // RunLoop is quit when message received from page. | 209 // RunLoop is quit when message received from page. |
| 210 run_loop.Run(); | 210 run_loop.Run(); |
| 211 EXPECT_TRUE(got_message); | 211 EXPECT_TRUE(got_message); |
| 212 | 212 |
| 213 // Check that a second render frame in the same renderer process works | 213 // Check that a second render frame in the same renderer process works |
| 214 // correctly. | 214 // correctly. |
| 215 Shell* other_shell = CreateBrowser(); | 215 Shell* other_shell = CreateBrowser(); |
| 216 got_message = false; | 216 got_message = false; |
| 217 base::RunLoop other_run_loop; | 217 base::RunLoop other_run_loop; |
| 218 factory()->set_run_loop(&other_run_loop); | 218 factory()->set_run_loop(&other_run_loop); |
| 219 NavigateToURL(other_shell, test_url); | 219 NavigateToURL(other_shell, test_url); |
| 220 // RunLoop is quit when message received from page. | 220 // RunLoop is quit when message received from page. |
| 221 other_run_loop.Run(); | 221 other_run_loop.Run(); |
| 222 EXPECT_TRUE(got_message); | 222 EXPECT_TRUE(got_message); |
| 223 EXPECT_EQ(shell()->web_contents()->GetRenderProcessHost(), | 223 EXPECT_EQ(shell()->web_contents()->GetRenderProcessHost(), |
| 224 other_shell->web_contents()->GetRenderProcessHost()); | 224 other_shell->web_contents()->GetRenderProcessHost()); |
| 225 } | 225 } |
| 226 | 226 |
| 227 // Loads a webui page that connects to a test Mojo application via the browser's | 227 // Loads a webui page that connects to a test Mojo application via the browser's |
| 228 // Mojo shell interface. | 228 // Mojo shell interface. |
| 229 IN_PROC_BROWSER_TEST_F(WebUIMojoTest, ConnectToApplication) { | 229 IN_PROC_BROWSER_TEST_F(WebUIMojoTest, ConnectToApplication) { |
| 230 if (!IsGeneratedResourceAvailable( | 230 if (!IsGeneratedResourceAvailable( |
| 231 "content/public/test/test_mojo_service.mojom")) | 231 "content/public/test/test_mojo_service.mojom")) |
| 232 return; | 232 return; |
| 233 | 233 |
| 234 ASSERT_TRUE(test_server()->Start()); | 234 ASSERT_TRUE(embedded_test_server()->Start()); |
| 235 NavigateToURL(shell(), | 235 NavigateToURL(shell(), |
| 236 test_server()->GetURL("files/web_ui_mojo_shell_test.html")); | 236 embedded_test_server()->GetURL("/web_ui_mojo_shell_test.html")); |
| 237 | 237 |
| 238 DOMMessageQueue message_queue; | 238 DOMMessageQueue message_queue; |
| 239 std::string message; | 239 std::string message; |
| 240 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | 240 ASSERT_TRUE(message_queue.WaitForMessage(&message)); |
| 241 EXPECT_EQ("true", message); | 241 EXPECT_EQ("true", message); |
| 242 } | 242 } |
| 243 | 243 |
| 244 } // namespace | 244 } // namespace |
| 245 } // namespace content | 245 } // namespace content |
| OLD | NEW |