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

Side by Side Diff: chrome/browser/ui/webui/web_ui_browsertest.cc

Issue 11881055: Simplify WebUI data sources. Currently WebUI data sources implement a URLDataSourceDelegate interfa… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix issue in about_ui exposed by cros tests Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
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/browser/ui/webui/web_ui_browsertest.h" 5 #include "chrome/browser/ui/webui/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 10 matching lines...) Expand all
21 #include "chrome/browser/ui/browser_navigator.h" 21 #include "chrome/browser/ui/browser_navigator.h"
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" 22 #include "chrome/browser/ui/tabs/tab_strip_model.h"
23 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 23 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
24 #include "chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.h" 24 #include "chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.h"
25 #include "chrome/browser/ui/webui/web_ui_test_handler.h" 25 #include "chrome/browser/ui/webui/web_ui_test_handler.h"
26 #include "chrome/common/chrome_paths.h" 26 #include "chrome/common/chrome_paths.h"
27 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
28 #include "chrome/test/base/test_tab_strip_model_observer.h" 28 #include "chrome/test/base/test_tab_strip_model_observer.h"
29 #include "chrome/test/base/ui_test_utils.h" 29 #include "chrome/test/base/ui_test_utils.h"
30 #include "content/public/browser/navigation_controller.h" 30 #include "content/public/browser/navigation_controller.h"
31 #include "content/public/browser/url_data_source_delegate.h" 31 #include "content/public/browser/url_data_source.h"
32 #include "content/public/browser/web_contents.h" 32 #include "content/public/browser/web_contents.h"
33 #include "content/public/browser/web_ui_controller.h" 33 #include "content/public/browser/web_ui_controller.h"
34 #include "content/public/browser/web_ui_message_handler.h" 34 #include "content/public/browser/web_ui_message_handler.h"
35 #include "net/base/net_util.h" 35 #include "net/base/net_util.h"
36 #include "testing/gmock/include/gmock/gmock.h" 36 #include "testing/gmock/include/gmock/gmock.h"
37 #include "testing/gtest/include/gtest/gtest-spi.h" 37 #include "testing/gtest/include/gtest/gtest-spi.h"
38 #include "ui/base/resource/resource_bundle.h" 38 #include "ui/base/resource/resource_bundle.h"
39 #include "ui/base/resource/resource_handle.h" 39 #include "ui/base/resource/resource_handle.h"
40 40
41 using content::NavigationController; 41 using content::NavigationController;
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 const std::string& preload_test_name) { 261 const std::string& preload_test_name) {
262 preload_test_name_ = preload_test_name; 262 preload_test_name_ = preload_test_name;
263 } 263 }
264 264
265 namespace { 265 namespace {
266 266
267 // DataSource for the dummy URL. If no data source is provided then an error 267 // DataSource for the dummy URL. If no data source is provided then an error
268 // page is shown. While this doesn't matter for most tests, without it, 268 // page is shown. While this doesn't matter for most tests, without it,
269 // navigation to different anchors cannot be listened to (via the hashchange 269 // navigation to different anchors cannot be listened to (via the hashchange
270 // event). 270 // event).
271 class MockWebUIDataSource : public content::URLDataSourceDelegate { 271 class MockWebUIDataSource : public content::URLDataSource {
272 public: 272 public:
273 MockWebUIDataSource() {} 273 MockWebUIDataSource() {}
274 274
275 private: 275 private:
276 virtual ~MockWebUIDataSource() {} 276 virtual ~MockWebUIDataSource() {}
277 277
278 virtual std::string GetSource() OVERRIDE { 278 virtual std::string GetSource() OVERRIDE {
279 return "dummyurl"; 279 return "dummyurl";
280 } 280 }
281 281
282 virtual void StartDataRequest(const std::string& path, 282 virtual void StartDataRequest(
283 bool is_incognito, 283 const std::string& path,
284 int request_id) OVERRIDE { 284 bool is_incognito,
285 const content::URLDataSource::GotDataCallback& callback) OVERRIDE {
285 std::string dummy_html = "<html><body>Dummy</body></html>"; 286 std::string dummy_html = "<html><body>Dummy</body></html>";
286 scoped_refptr<base::RefCountedString> response = 287 scoped_refptr<base::RefCountedString> response =
287 base::RefCountedString::TakeString(&dummy_html); 288 base::RefCountedString::TakeString(&dummy_html);
288 url_data_source()->SendResponse(request_id, response); 289 callback.Run(response);
289 } 290 }
290 291
291 std::string GetMimeType(const std::string& path) const OVERRIDE { 292 std::string GetMimeType(const std::string& path) const OVERRIDE {
292 return "text/html"; 293 return "text/html";
293 } 294 }
294 295
295 DISALLOW_COPY_AND_ASSIGN(MockWebUIDataSource); 296 DISALLOW_COPY_AND_ASSIGN(MockWebUIDataSource);
296 }; 297 };
297 298
298 // WebUIProvider to allow attaching the DataSource for the dummy URL when 299 // WebUIProvider to allow attaching the DataSource for the dummy URL when
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 // testDone directly and expect pass result. 712 // testDone directly and expect pass result.
712 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { 713 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) {
713 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); 714 ASSERT_TRUE(RunJavascriptAsyncTest("testDone"));
714 } 715 }
715 716
716 // Test that calling testDone during RunJavascriptTest still completes when 717 // Test that calling testDone during RunJavascriptTest still completes when
717 // waiting for async result. 718 // waiting for async result.
718 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { 719 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) {
719 ASSERT_TRUE(RunJavascriptTest("testDone")); 720 ASSERT_TRUE(RunJavascriptTest("testDone"));
720 } 721 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698