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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 base::FilePath file_path; | 41 base::FilePath file_path; |
42 PathService::Get(CHILD_PROCESS_EXE, &file_path); | 42 PathService::Get(CHILD_PROCESS_EXE, &file_path); |
43 return file_path.DirName().AppendASCII(binding_path); | 43 return file_path.DirName().AppendASCII(binding_path); |
44 } | 44 } |
45 | 45 |
46 // The bindings for the page are generated from a .mojom file. This code looks | 46 // The bindings for the page are generated from a .mojom file. This code looks |
47 // up the generated file from disk and returns it. | 47 // up the generated file from disk and returns it. |
48 bool GetResource(const std::string& id, | 48 bool GetResource(const std::string& id, |
49 const WebUIDataSource::GotDataCallback& callback) { | 49 const WebUIDataSource::GotDataCallback& callback) { |
50 // These are handled by the WebUIDataSource that AddMojoDataSource() creates. | 50 // These are handled by the WebUIDataSource that AddMojoDataSource() creates. |
51 if (id == mojo::kCodecModuleName || id == mojo::kConnectorModuleName) | 51 if (id == mojo::kCodecModuleName || |
| 52 id == mojo::kConnectionModuleName || |
| 53 id == mojo::kConnectorModuleName || |
| 54 id == mojo::kRouterModuleName) |
52 return false; | 55 return false; |
53 | 56 |
54 std::string contents; | 57 std::string contents; |
55 CHECK(base::ReadFileToString(GetFilePathForJSResource(id), &contents, | 58 CHECK(base::ReadFileToString(GetFilePathForJSResource(id), &contents, |
56 std::string::npos)); | 59 std::string::npos)); |
57 base::RefCountedString* ref_contents = new base::RefCountedString; | 60 base::RefCountedString* ref_contents = new base::RefCountedString; |
58 ref_contents->data() = contents; | 61 ref_contents->data() = contents; |
59 callback.Run(ref_contents); | 62 callback.Run(ref_contents); |
60 return true; | 63 return true; |
61 } | 64 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 TestWebUIControllerFactory* factory() { return &factory_; } | 162 TestWebUIControllerFactory* factory() { return &factory_; } |
160 | 163 |
161 private: | 164 private: |
162 TestWebUIControllerFactory factory_; | 165 TestWebUIControllerFactory factory_; |
163 | 166 |
164 DISALLOW_COPY_AND_ASSIGN(WebUIMojoTest); | 167 DISALLOW_COPY_AND_ASSIGN(WebUIMojoTest); |
165 }; | 168 }; |
166 | 169 |
167 // Loads a webui page that contains mojo bindings and verifies a message makes | 170 // Loads a webui page that contains mojo bindings and verifies a message makes |
168 // it from the browser to the page and back. | 171 // it from the browser to the page and back. |
169 // http://crbug.com/357308 | 172 IN_PROC_BROWSER_TEST_F(WebUIMojoTest, EndToEnd) { |
170 IN_PROC_BROWSER_TEST_F(WebUIMojoTest, DISABLED_EndToEnd) { | |
171 // Currently there is no way to have a generated file included in the isolate | 173 // Currently there is no way to have a generated file included in the isolate |
172 // files. If the bindings file doesn't exist assume we're on such a bot and | 174 // files. If the bindings file doesn't exist assume we're on such a bot and |
173 // pass. | 175 // pass. |
174 // TODO(sky): remove this conditional when isolates support copying from gen. | 176 // TODO(sky): remove this conditional when isolates support copying from gen. |
175 const base::FilePath test_file_path( | 177 const base::FilePath test_file_path( |
176 GetFilePathForJSResource( | 178 GetFilePathForJSResource( |
177 "content/test/data/web_ui_test_mojo_bindings.mojom")); | 179 "content/test/data/web_ui_test_mojo_bindings.mojom")); |
178 if (!base::PathExists(test_file_path)) { | 180 if (!base::PathExists(test_file_path)) { |
179 LOG(WARNING) << " mojom binding file doesn't exist, assuming on isolate"; | 181 LOG(WARNING) << " mojom binding file doesn't exist, assuming on isolate"; |
180 return; | 182 return; |
181 } | 183 } |
182 | 184 |
183 got_message = false; | 185 got_message = false; |
184 ASSERT_TRUE(test_server()->Start()); | 186 ASSERT_TRUE(test_server()->Start()); |
185 base::RunLoop run_loop; | 187 base::RunLoop run_loop; |
186 factory()->set_run_loop(&run_loop); | 188 factory()->set_run_loop(&run_loop); |
187 GURL test_url(test_server()->GetURL("files/web_ui_mojo.html")); | 189 GURL test_url(test_server()->GetURL("files/web_ui_mojo.html")); |
188 NavigateToURL(shell(), test_url); | 190 NavigateToURL(shell(), test_url); |
189 // RunLoop is quit when message received from page. | 191 // RunLoop is quit when message received from page. |
190 run_loop.Run(); | 192 run_loop.Run(); |
191 EXPECT_TRUE(got_message); | 193 EXPECT_TRUE(got_message); |
192 } | 194 } |
193 | 195 |
194 } // namespace | 196 } // namespace |
195 } // namespace content | 197 } // namespace content |
OLD | NEW |