| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/test/base/web_ui_browsertest.h" | 5 #include "chrome/test/base/web_ui_browsertest.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 virtual void StartDataRequest( | 281 virtual void StartDataRequest( |
| 282 const std::string& path, | 282 const std::string& path, |
| 283 bool is_incognito, | 283 bool is_incognito, |
| 284 const content::URLDataSource::GotDataCallback& callback) OVERRIDE { | 284 const content::URLDataSource::GotDataCallback& callback) OVERRIDE { |
| 285 std::string dummy_html = "<html><body>Dummy</body></html>"; | 285 std::string dummy_html = "<html><body>Dummy</body></html>"; |
| 286 scoped_refptr<base::RefCountedString> response = | 286 scoped_refptr<base::RefCountedString> response = |
| 287 base::RefCountedString::TakeString(&dummy_html); | 287 base::RefCountedString::TakeString(&dummy_html); |
| 288 callback.Run(response); | 288 callback.Run(response); |
| 289 } | 289 } |
| 290 | 290 |
| 291 std::string GetMimeType(const std::string& path) const OVERRIDE { | 291 virtual std::string GetMimeType(const std::string& path) const OVERRIDE { |
| 292 return "text/html"; | 292 return "text/html"; |
| 293 } | 293 } |
| 294 | 294 |
| 295 DISALLOW_COPY_AND_ASSIGN(MockWebUIDataSource); | 295 DISALLOW_COPY_AND_ASSIGN(MockWebUIDataSource); |
| 296 }; | 296 }; |
| 297 | 297 |
| 298 // WebUIProvider to allow attaching the DataSource for the dummy URL when | 298 // WebUIProvider to allow attaching the DataSource for the dummy URL when |
| 299 // testing. | 299 // testing. |
| 300 class MockWebUIProvider | 300 class MockWebUIProvider |
| 301 : public TestChromeWebUIControllerFactory::WebUIProvider { | 301 : public TestChromeWebUIControllerFactory::WebUIProvider { |
| 302 public: | 302 public: |
| 303 MockWebUIProvider() {} | 303 MockWebUIProvider() {} |
| 304 | 304 |
| 305 // Returns a new WebUI | 305 // Returns a new WebUI |
| 306 WebUIController* NewWebUI(content::WebUI* web_ui, const GURL& url) OVERRIDE { | 306 virtual WebUIController* NewWebUI(content::WebUI* web_ui, |
| 307 const GURL& url) OVERRIDE { |
| 307 WebUIController* controller = new content::WebUIController(web_ui); | 308 WebUIController* controller = new content::WebUIController(web_ui); |
| 308 Profile* profile = Profile::FromWebUI(web_ui); | 309 Profile* profile = Profile::FromWebUI(web_ui); |
| 309 content::URLDataSource::Add(profile, new MockWebUIDataSource()); | 310 content::URLDataSource::Add(profile, new MockWebUIDataSource()); |
| 310 return controller; | 311 return controller; |
| 311 } | 312 } |
| 312 | 313 |
| 313 private: | 314 private: |
| 314 DISALLOW_COPY_AND_ASSIGN(MockWebUIProvider); | 315 DISALLOW_COPY_AND_ASSIGN(MockWebUIProvider); |
| 315 }; | 316 }; |
| 316 | 317 |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 // testDone directly and expect pass result. | 717 // testDone directly and expect pass result. |
| 717 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { | 718 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { |
| 718 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); | 719 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); |
| 719 } | 720 } |
| 720 | 721 |
| 721 // Test that calling testDone during RunJavascriptTest still completes when | 722 // Test that calling testDone during RunJavascriptTest still completes when |
| 722 // waiting for async result. | 723 // waiting for async result. |
| 723 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { | 724 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { |
| 724 ASSERT_TRUE(RunJavascriptTest("testDone")); | 725 ASSERT_TRUE(RunJavascriptTest("testDone")); |
| 725 } | 726 } |
| OLD | NEW |