Chromium Code Reviews| Index: content/browser/webui/web_ui_mojo_browsertest.cc |
| diff --git a/content/browser/webui/web_ui_mojo_browsertest.cc b/content/browser/webui/web_ui_mojo_browsertest.cc |
| index 3f5a6de8118d98975cc4ac1c2c3ececee13bf1e2..9d941c9f6c1a7f33d46a864ae43386538eb2df82 100644 |
| --- a/content/browser/webui/web_ui_mojo_browsertest.cc |
| +++ b/content/browser/webui/web_ui_mojo_browsertest.cc |
| @@ -7,6 +7,7 @@ |
| #include "base/command_line.h" |
| #include "base/files/file_path.h" |
| #include "base/files/file_util.h" |
| +#include "base/path_service.h" |
| #include "base/run_loop.h" |
| #include "base/strings/string_util.h" |
| #include "content/browser/webui/web_ui_controller_factory_registry.h" |
| @@ -52,10 +53,22 @@ bool GetResource(const std::string& id, |
| id == mojo::kValidatorModuleName) |
| return false; |
| + if (id.find(".mojom") != std::string::npos) { |
| + std::string contents; |
| + CHECK(base::ReadFileToString(mojo::test::GetFilePathForJSResource(id), |
| + &contents, std::string::npos)) |
| + << id; |
| + base::RefCountedString* ref_contents = new base::RefCountedString; |
| + ref_contents->data() = contents; |
| + callback.Run(ref_contents); |
| + return true; |
| + } |
| + |
| + base::FilePath path; |
| + DCHECK(base::PathService::Get(content::DIR_TEST_DATA, &path)); |
| + path = path.AppendASCII(id.substr(0, id.find("?"))); |
| std::string contents; |
| - CHECK(base::ReadFileToString(mojo::test::GetFilePathForJSResource(id), |
| - &contents, |
| - std::string::npos)) << id; |
| + CHECK(base::ReadFileToString(path, &contents, std::string::npos)) << id; |
|
magjed_chromium
2015/11/24 08:55:50
After your CL, we are hitting this CHECK on the Ca
|
| base::RefCountedString* ref_contents = new base::RefCountedString; |
| ref_contents->data() = contents; |
| callback.Run(ref_contents); |
| @@ -90,13 +103,14 @@ class BrowserTargetImpl : public BrowserTarget { |
| // WebUIController that sets up mojo bindings. |
| class TestWebUIController : public WebUIController { |
| public: |
| - TestWebUIController(WebUI* web_ui, base::RunLoop* run_loop) |
| - : WebUIController(web_ui), |
| - run_loop_(run_loop) { |
| + TestWebUIController(WebUI* web_ui, base::RunLoop* run_loop) |
| + : WebUIController(web_ui), run_loop_(run_loop) { |
| content::WebUIDataSource* data_source = |
| - WebUIDataSource::AddMojoDataSource( |
| - web_ui->GetWebContents()->GetBrowserContext()); |
| + WebUIDataSource::Create("mojo-web-ui"); |
| + data_source->AddMojoResources(); |
| data_source->SetRequestFilter(base::Bind(&GetResource)); |
| + content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), |
| + data_source); |
| } |
| protected: |
| @@ -205,7 +219,7 @@ IN_PROC_BROWSER_TEST_F(WebUIMojoTest, EndToEndPing) { |
| ASSERT_TRUE(embedded_test_server()->Start()); |
| base::RunLoop run_loop; |
| factory()->set_run_loop(&run_loop); |
| - GURL test_url(embedded_test_server()->GetURL("/web_ui_mojo.html?ping")); |
| + GURL test_url("chrome://mojo-web-ui/web_ui_mojo.html?ping"); |
| NavigateToURL(shell(), test_url); |
| // RunLoop is quit when message received from page. |
| run_loop.Run(); |
| @@ -234,7 +248,7 @@ IN_PROC_BROWSER_TEST_F(WebUIMojoTest, ConnectToApplication) { |
| ASSERT_TRUE(embedded_test_server()->Start()); |
| NavigateToURL(shell(), |
| - embedded_test_server()->GetURL("/web_ui_mojo_shell_test.html")); |
| + GURL("chrome://mojo-web-ui/web_ui_mojo_shell_test.html")); |
| DOMMessageQueue message_queue; |
| std::string message; |