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

Side by Side Diff: content/shell/shell_render_process_observer.cc

Issue 12258047: [content shell] Use the TestRunner library again and remove the mock testRunner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | « content/shell/shell_render_process_observer.h ('k') | content/shell/shell_resources.grd » ('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) 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 "content/shell/shell_render_process_observer.h" 5 #include "content/shell/shell_render_process_observer.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "content/public/renderer/render_view.h" 8 #include "content/public/renderer/render_view.h"
9 #include "content/public/renderer/render_thread.h" 9 #include "content/public/renderer/render_thread.h"
10 #include "content/public/test/layouttest_support.h" 10 #include "content/public/test/layouttest_support.h"
11 #include "content/shell/shell_messages.h" 11 #include "content/shell/shell_messages.h"
12 #include "content/shell/shell_switches.h" 12 #include "content/shell/shell_switches.h"
13 #include "content/shell/webkit_test_runner.h" 13 #include "content/shell/webkit_test_runner.h"
14 #include "content/shell/webkit_test_runner_bindings.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTestingSupport.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTestingSupport.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
17 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestInterfaces.h"
18 #include "webkit/glue/webkit_glue.h" 18 #include "webkit/glue/webkit_glue.h"
19 #include "webkit/support/gc_extension.h" 19 #include "webkit/support/gc_extension.h"
20 20
21 using WebKit::WebFrame; 21 using WebKit::WebFrame;
22 using WebKit::WebRuntimeFeatures; 22 using WebKit::WebRuntimeFeatures;
23 using WebKit::WebTestingSupport; 23 using WebKit::WebTestingSupport;
24 using WebTestRunner::WebTestDelegate; 24 using WebTestRunner::WebTestDelegate;
25 using WebTestRunner::WebTestInterfaces;
25 26
26 namespace content { 27 namespace content {
27 28
28 namespace { 29 namespace {
29 ShellRenderProcessObserver* g_instance = NULL; 30 ShellRenderProcessObserver* g_instance = NULL;
30 } 31 }
31 32
32 // static 33 // static
33 ShellRenderProcessObserver* ShellRenderProcessObserver::GetInstance() { 34 ShellRenderProcessObserver* ShellRenderProcessObserver::GetInstance() {
34 return g_instance; 35 return g_instance;
(...skipping 19 matching lines...) Expand all
54 55
55 ShellRenderProcessObserver::~ShellRenderProcessObserver() { 56 ShellRenderProcessObserver::~ShellRenderProcessObserver() {
56 CHECK(g_instance == this); 57 CHECK(g_instance == this);
57 g_instance = NULL; 58 g_instance = NULL;
58 } 59 }
59 60
60 void ShellRenderProcessObserver::SetMainWindow( 61 void ShellRenderProcessObserver::SetMainWindow(
61 RenderView* view, 62 RenderView* view,
62 WebKitTestRunner* test_runner, 63 WebKitTestRunner* test_runner,
63 WebTestDelegate* delegate) { 64 WebTestDelegate* delegate) {
65 test_interfaces_->setDelegate(delegate);
66 test_interfaces_->setWebView(view->GetWebView(), test_runner->proxy());
64 main_render_view_ = view; 67 main_render_view_ = view;
65 main_test_runner_ = test_runner; 68 main_test_runner_ = test_runner;
66 test_delegate_ = delegate; 69 test_delegate_ = delegate;
67 } 70 }
68 71
69 void ShellRenderProcessObserver::BindTestRunnersToWindow(WebFrame* frame) { 72 void ShellRenderProcessObserver::BindTestRunnersToWindow(WebFrame* frame) {
70 WebTestingSupport::injectInternalsObject(frame); 73 WebTestingSupport::injectInternalsObject(frame);
74 test_interfaces_->bindTo(frame);
71 } 75 }
72 76
73 void ShellRenderProcessObserver::WebKitInitialized() { 77 void ShellRenderProcessObserver::WebKitInitialized() {
74 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) 78 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
75 return; 79 return;
76 80
77 // To implement a catch-all for not yet implemented controller properties.
78 webkit_glue::SetJavaScriptFlags(" --harmony_proxies");
79 RenderThread::Get()->RegisterExtension(new WebKitTestRunnerBindings());
80
81 // We always expose GC to layout tests. 81 // We always expose GC to layout tests.
82 webkit_glue::SetJavaScriptFlags(" --expose-gc"); 82 webkit_glue::SetJavaScriptFlags(" --expose-gc");
83 RenderThread::Get()->RegisterExtension(extensions_v8::GCExtension::Get()); 83 RenderThread::Get()->RegisterExtension(extensions_v8::GCExtension::Get());
84
85 test_interfaces_.reset(new WebTestInterfaces);
86 test_interfaces_->resetAll();
84 } 87 }
85 88
86 bool ShellRenderProcessObserver::OnControlMessageReceived( 89 bool ShellRenderProcessObserver::OnControlMessageReceived(
87 const IPC::Message& message) { 90 const IPC::Message& message) {
88 bool handled = true; 91 bool handled = true;
89 IPC_BEGIN_MESSAGE_MAP(ShellRenderProcessObserver, message) 92 IPC_BEGIN_MESSAGE_MAP(ShellRenderProcessObserver, message)
90 IPC_MESSAGE_HANDLER(ShellViewMsg_ResetAll, OnResetAll) 93 IPC_MESSAGE_HANDLER(ShellViewMsg_ResetAll, OnResetAll)
91 IPC_MESSAGE_HANDLER(ShellViewMsg_SetWebKitSourceDir, OnSetWebKitSourceDir) 94 IPC_MESSAGE_HANDLER(ShellViewMsg_SetWebKitSourceDir, OnSetWebKitSourceDir)
92 IPC_MESSAGE_UNHANDLED(handled = false) 95 IPC_MESSAGE_UNHANDLED(handled = false)
93 IPC_END_MESSAGE_MAP() 96 IPC_END_MESSAGE_MAP()
94 97
95 return handled; 98 return handled;
96 } 99 }
97 100
98 void ShellRenderProcessObserver::OnResetAll() { 101 void ShellRenderProcessObserver::OnResetAll() {
102 test_interfaces_->resetAll();
99 if (main_render_view_) { 103 if (main_render_view_) {
100 main_test_runner_->Reset(); 104 main_test_runner_->Reset();
101 WebTestingSupport::resetInternalsObject( 105 WebTestingSupport::resetInternalsObject(
102 main_render_view_->GetWebView()->mainFrame()); 106 main_render_view_->GetWebView()->mainFrame());
103 } 107 }
104 } 108 }
105 109
106 void ShellRenderProcessObserver::OnSetWebKitSourceDir( 110 void ShellRenderProcessObserver::OnSetWebKitSourceDir(
107 const base::FilePath& webkit_source_dir) { 111 const base::FilePath& webkit_source_dir) {
108 webkit_source_dir_ = webkit_source_dir; 112 webkit_source_dir_ = webkit_source_dir;
109 } 113 }
110 114
111 } // namespace content 115 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/shell_render_process_observer.h ('k') | content/shell/shell_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698