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

Side by Side Diff: webkit/tools/test_shell/test_shell.cc

Issue 149620: Use WebWidget from the WebKit API. This change also makes... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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
« no previous file with comments | « webkit/tools/test_shell/test_shell.h ('k') | webkit/tools/test_shell/test_shell_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "V8Proxy.h" 5 #include "V8Proxy.h"
6 #undef LOG 6 #undef LOG
7 7
8 #include "webkit/tools/test_shell/test_shell.h" 8 #include "webkit/tools/test_shell/test_shell.h"
9 9
10 #include "base/base_paths.h" 10 #include "base/base_paths.h"
(...skipping 25 matching lines...) Expand all
36 #include "webkit/api/public/WebSize.h" 36 #include "webkit/api/public/WebSize.h"
37 #include "webkit/api/public/WebString.h" 37 #include "webkit/api/public/WebString.h"
38 #include "webkit/api/public/WebURL.h" 38 #include "webkit/api/public/WebURL.h"
39 #include "webkit/api/public/WebURLRequest.h" 39 #include "webkit/api/public/WebURLRequest.h"
40 #include "webkit/api/public/WebURLResponse.h" 40 #include "webkit/api/public/WebURLResponse.h"
41 #include "webkit/glue/glue_serialize.h" 41 #include "webkit/glue/glue_serialize.h"
42 #include "webkit/glue/webframe.h" 42 #include "webkit/glue/webframe.h"
43 #include "webkit/glue/webkit_glue.h" 43 #include "webkit/glue/webkit_glue.h"
44 #include "webkit/glue/webpreferences.h" 44 #include "webkit/glue/webpreferences.h"
45 #include "webkit/glue/webview.h" 45 #include "webkit/glue/webview.h"
46 #include "webkit/glue/webwidget.h"
47 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" 46 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
48 #include "webkit/tools/test_shell/test_navigation_controller.h" 47 #include "webkit/tools/test_shell/test_navigation_controller.h"
49 #include "webkit/tools/test_shell/test_shell_switches.h" 48 #include "webkit/tools/test_shell/test_shell_switches.h"
50 49
50 using WebKit::WebNavigationPolicy;
51 using WebKit::WebRect; 51 using WebKit::WebRect;
52 using WebKit::WebSize; 52 using WebKit::WebSize;
53 using WebKit::WebURLRequest; 53 using WebKit::WebURLRequest;
54 54
55 namespace { 55 namespace {
56 56
57 // Default timeout in ms for file page loads when in layout test mode. 57 // Default timeout in ms for file page loads when in layout test mode.
58 const int kDefaultFileTestTimeoutMillisecs = 10 * 1000; 58 const int kDefaultFileTestTimeoutMillisecs = 10 * 1000;
59 59
60 // Content area size for newly created windows. 60 // Content area size for newly created windows.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 m_focusedWidgetHost(NULL), 105 m_focusedWidgetHost(NULL),
106 #if defined(OS_WIN) 106 #if defined(OS_WIN)
107 default_edit_wnd_proc_(0), 107 default_edit_wnd_proc_(0),
108 #endif 108 #endif
109 test_params_(NULL), 109 test_params_(NULL),
110 test_is_preparing_(false), 110 test_is_preparing_(false),
111 test_is_pending_(false), 111 test_is_pending_(false),
112 is_modal_(false), 112 is_modal_(false),
113 dump_stats_table_on_exit_(false) { 113 dump_stats_table_on_exit_(false) {
114 delegate_ = new TestWebViewDelegate(this); 114 delegate_ = new TestWebViewDelegate(this);
115 popup_delegate_ = new TestWebViewDelegate(this);
115 layout_test_controller_.reset(new LayoutTestController(this)); 116 layout_test_controller_.reset(new LayoutTestController(this));
116 event_sending_controller_.reset(new EventSendingController(this)); 117 event_sending_controller_.reset(new EventSendingController(this));
117 text_input_controller_.reset(new TextInputController(this)); 118 text_input_controller_.reset(new TextInputController(this));
118 navigation_controller_.reset(new TestNavigationController(this)); 119 navigation_controller_.reset(new TestNavigationController(this));
119 120
120 URLRequestFilter* filter = URLRequestFilter::GetInstance(); 121 URLRequestFilter* filter = URLRequestFilter::GetInstance();
121 filter->AddHostnameHandler("test-shell-resource", "inspector", 122 filter->AddHostnameHandler("test-shell-resource", "inspector",
122 &URLRequestTestShellFileJob::InspectorFactory); 123 &URLRequestTestShellFileJob::InspectorFactory);
123 url_util::AddStandardScheme("test-shell-resource"); 124 url_util::AddStandardScheme("test-shell-resource");
124 } 125 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 241 }
241 if (dumped_anything) 242 if (dumped_anything)
242 printf("#EOF\n"); 243 printf("#EOF\n");
243 fflush(stdout); 244 fflush(stdout);
244 } 245 }
245 } 246 }
246 247
247 // static 248 // static
248 std::string TestShell::DumpImage(WebView* view, 249 std::string TestShell::DumpImage(WebView* view,
249 const std::wstring& file_name, const std::string& pixel_hash) { 250 const std::wstring& file_name, const std::string& pixel_hash) {
250 view->Layout(); 251 view->layout();
251 const WebSize& size = view->GetSize(); 252 const WebSize& size = view->size();
252 253
253 skia::PlatformCanvas canvas; 254 skia::PlatformCanvas canvas;
254 if (!canvas.initialize(size.width, size.height, true)) 255 if (!canvas.initialize(size.width, size.height, true))
255 return std::string(); 256 return std::string();
256 view->Paint(&canvas, WebRect(0, 0, size.width, size.height)); 257 view->paint(&canvas, WebRect(0, 0, size.width, size.height));
257 258
258 skia::BitmapPlatformDevice& device = 259 skia::BitmapPlatformDevice& device =
259 static_cast<skia::BitmapPlatformDevice&>(canvas.getTopPlatformDevice()); 260 static_cast<skia::BitmapPlatformDevice&>(canvas.getTopPlatformDevice());
260 const SkBitmap& src_bmp = device.accessBitmap(false); 261 const SkBitmap& src_bmp = device.accessBitmap(false);
261 262
262 // Encode image. 263 // Encode image.
263 std::vector<unsigned char> png; 264 std::vector<unsigned char> png;
264 SkAutoLockPixels src_bmp_lock(src_bmp); 265 SkAutoLockPixels src_bmp_lock(src_bmp);
265 PNGEncoder::ColorFormat color_format = PNGEncoder::FORMAT_BGRA; 266 PNGEncoder::ColorFormat color_format = PNGEncoder::FORMAT_BGRA;
266 267
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 TestShell::windowList()->end(), 428 TestShell::windowList()->end(),
428 window); 429 window);
429 if (entry != TestShell::windowList()->end()) { 430 if (entry != TestShell::windowList()->end()) {
430 TestShell::windowList()->erase(entry); 431 TestShell::windowList()->erase(entry);
431 return true; 432 return true;
432 } 433 }
433 434
434 return false; 435 return false;
435 } 436 }
436 437
437 void TestShell::Show(WebView* webview, WindowOpenDisposition disposition) { 438 void TestShell::Show(WebNavigationPolicy policy) {
438 delegate_->Show(webview, disposition); 439 delegate_->show(policy);
439 } 440 }
440 441
441 void TestShell::BindJSObjectsToWindow(WebFrame* frame) { 442 void TestShell::BindJSObjectsToWindow(WebFrame* frame) {
442 // Only bind the test classes if we're running tests. 443 // Only bind the test classes if we're running tests.
443 if (layout_test_mode_) { 444 if (layout_test_mode_) {
444 layout_test_controller_->BindToJavascript(frame, L"layoutTestController"); 445 layout_test_controller_->BindToJavascript(frame, L"layoutTestController");
445 event_sending_controller_->BindToJavascript(frame, L"eventSender"); 446 event_sending_controller_->BindToJavascript(frame, L"eventSender");
446 text_input_controller_->BindToJavascript(frame, L"textInputController"); 447 text_input_controller_->BindToJavascript(frame, L"textInputController");
447 } 448 }
448 } 449 }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 navigation_controller_->Reload(); 584 navigation_controller_->Reload();
584 } 585 }
585 586
586 void TestShell::SetFocus(WebWidgetHost* host, bool enable) { 587 void TestShell::SetFocus(WebWidgetHost* host, bool enable) {
587 if (!layout_test_mode_) { 588 if (!layout_test_mode_) {
588 InteractiveSetFocus(host, enable); 589 InteractiveSetFocus(host, enable);
589 } else { 590 } else {
590 if (enable) { 591 if (enable) {
591 if (m_focusedWidgetHost != host) { 592 if (m_focusedWidgetHost != host) {
592 if (m_focusedWidgetHost) 593 if (m_focusedWidgetHost)
593 m_focusedWidgetHost->webwidget()->SetFocus(false); 594 m_focusedWidgetHost->webwidget()->setFocus(false);
594 host->webwidget()->SetFocus(enable); 595 host->webwidget()->setFocus(enable);
595 m_focusedWidgetHost = host; 596 m_focusedWidgetHost = host;
596 } 597 }
597 } else { 598 } else {
598 if (m_focusedWidgetHost == host) { 599 if (m_focusedWidgetHost == host) {
599 host->webwidget()->SetFocus(enable); 600 host->webwidget()->setFocus(enable);
600 m_focusedWidgetHost = NULL; 601 m_focusedWidgetHost = NULL;
601 } 602 }
602 } 603 }
603 } 604 }
604 } 605 }
605 606
606 //----------------------------------------------------------------------------- 607 //-----------------------------------------------------------------------------
607 608
608 namespace webkit_glue { 609 namespace webkit_glue {
609 610
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 670
670 void CloseIdleConnections() { 671 void CloseIdleConnections() {
671 // Used in benchmarking, Ignored for test_shell. 672 // Used in benchmarking, Ignored for test_shell.
672 } 673 }
673 674
674 void SetCacheMode(bool enabled) { 675 void SetCacheMode(bool enabled) {
675 // Used in benchmarking, Ignored for test_shell. 676 // Used in benchmarking, Ignored for test_shell.
676 } 677 }
677 678
678 } // namespace webkit_glue 679 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/test_shell.h ('k') | webkit/tools/test_shell/test_shell_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698