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

Side by Side Diff: content/shell/renderer/webkit_test_runner.cc

Issue 21955003: Cleanup: Use content::kAboutBlankURL instead of the raw string in contents/. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix build Created 7 years, 4 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 "content/shell/renderer/webkit_test_runner.h" 5 #include "content/shell/renderer/webkit_test_runner.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <clocale> 8 #include <clocale>
9 #include <cmath> 9 #include <cmath>
10 10
11 #include "base/base64.h" 11 #include "base/base64.h"
12 #include "base/debug/debugger.h" 12 #include "base/debug/debugger.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/md5.h" 14 #include "base/md5.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "base/strings/sys_string_conversions.h" 19 #include "base/strings/sys_string_conversions.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/time/time.h" 21 #include "base/time/time.h"
22 #include "content/public/common/url_constants.h"
22 #include "content/public/renderer/history_item_serialization.h" 23 #include "content/public/renderer/history_item_serialization.h"
23 #include "content/public/renderer/render_view.h" 24 #include "content/public/renderer/render_view.h"
24 #include "content/public/renderer/render_view_visitor.h" 25 #include "content/public/renderer/render_view_visitor.h"
25 #include "content/public/test/layouttest_support.h" 26 #include "content/public/test/layouttest_support.h"
26 #include "content/shell/common/shell_messages.h" 27 #include "content/shell/common/shell_messages.h"
27 #include "content/shell/common/webkit_test_helpers.h" 28 #include "content/shell/common/webkit_test_helpers.h"
28 #include "content/shell/renderer/shell_render_process_observer.h" 29 #include "content/shell/renderer/shell_render_process_observer.h"
29 #include "net/base/net_errors.h" 30 #include "net/base/net_errors.h"
30 #include "net/base/net_util.h" 31 #include "net/base/net_util.h"
31 #include "skia/ext/platform_canvas.h" 32 #include "skia/ext/platform_canvas.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 void CopyCanvasToBitmap(SkCanvas* canvas, SkBitmap* snapshot) { 111 void CopyCanvasToBitmap(SkCanvas* canvas, SkBitmap* snapshot) {
111 SkDevice* device = skia::GetTopDevice(*canvas); 112 SkDevice* device = skia::GetTopDevice(*canvas);
112 const SkBitmap& bitmap = device->accessBitmap(false); 113 const SkBitmap& bitmap = device->accessBitmap(false);
113 const bool success = bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config); 114 const bool success = bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config);
114 DCHECK(success); 115 DCHECK(success);
115 116
116 #if !defined(OS_MACOSX) 117 #if !defined(OS_MACOSX)
117 // Only the expected PNGs for Mac have a valid alpha channel. 118 // Only the expected PNGs for Mac have a valid alpha channel.
118 MakeBitmapOpaque(snapshot); 119 MakeBitmapOpaque(snapshot);
119 #endif 120 #endif
120
121 } 121 }
122 122
123 class SyncNavigationStateVisitor : public RenderViewVisitor { 123 class SyncNavigationStateVisitor : public RenderViewVisitor {
124 public: 124 public:
125 SyncNavigationStateVisitor() {} 125 SyncNavigationStateVisitor() {}
126 virtual ~SyncNavigationStateVisitor() {} 126 virtual ~SyncNavigationStateVisitor() {}
127 127
128 virtual bool Visit(RenderView* render_view) OVERRIDE { 128 virtual bool Visit(RenderView* render_view) OVERRIDE {
129 SyncNavigationState(render_view); 129 SyncNavigationState(render_view);
130 return true; 130 return true;
(...skipping 17 matching lines...) Expand all
148 if (!test_runner) { 148 if (!test_runner) {
149 NOTREACHED(); 149 NOTREACHED();
150 return true; 150 return true;
151 } 151 }
152 if (test_runner->proxy() == proxy_) { 152 if (test_runner->proxy() == proxy_) {
153 render_view_ = render_view; 153 render_view_ = render_view;
154 return false; 154 return false;
155 } 155 }
156 return true; 156 return true;
157 } 157 }
158
158 private: 159 private:
159 WebTestProxyBase* proxy_; 160 WebTestProxyBase* proxy_;
160 RenderView* render_view_; 161 RenderView* render_view_;
161 162
162 DISALLOW_COPY_AND_ASSIGN(ProxyToRenderViewVisitor); 163 DISALLOW_COPY_AND_ASSIGN(ProxyToRenderViewVisitor);
163 }; 164 };
164 165
165 class NavigateAwayVisitor : public RenderViewVisitor { 166 class NavigateAwayVisitor : public RenderViewVisitor {
166 public: 167 public:
167 NavigateAwayVisitor(RenderView* main_render_view) 168 explicit NavigateAwayVisitor(RenderView* main_render_view)
168 : main_render_view_(main_render_view) {} 169 : main_render_view_(main_render_view) {}
169 virtual ~NavigateAwayVisitor() {} 170 virtual ~NavigateAwayVisitor() {}
170 171
171 virtual bool Visit(RenderView* render_view) OVERRIDE { 172 virtual bool Visit(RenderView* render_view) OVERRIDE {
172 if (render_view == main_render_view_) 173 if (render_view == main_render_view_)
173 return true; 174 return true;
174 render_view->GetWebView()->mainFrame() 175 render_view->GetWebView()->mainFrame()->loadRequest(
175 ->loadRequest(WebURLRequest(GURL("about:blank"))); 176 WebURLRequest(GURL(kAboutBlankURL)));
176 return true; 177 return true;
177 } 178 }
178 179
179 private: 180 private:
180 RenderView* main_render_view_; 181 RenderView* main_render_view_;
181 182
182 DISALLOW_COPY_AND_ASSIGN(NavigateAwayVisitor); 183 DISALLOW_COPY_AND_ASSIGN(NavigateAwayVisitor);
183 }; 184 };
184 185
185 } // namespace 186 } // namespace
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 session_histories_ = session_histories; 664 session_histories_ = session_histories;
664 current_entry_indexes_ = current_entry_indexes; 665 current_entry_indexes_ = current_entry_indexes;
665 CaptureDump(); 666 CaptureDump();
666 } 667 }
667 668
668 void WebKitTestRunner::OnReset() { 669 void WebKitTestRunner::OnReset() {
669 ShellRenderProcessObserver::GetInstance()->test_interfaces()->resetAll(); 670 ShellRenderProcessObserver::GetInstance()->test_interfaces()->resetAll();
670 Reset(); 671 Reset();
671 // Navigating to about:blank will make sure that no new loads are initiated 672 // Navigating to about:blank will make sure that no new loads are initiated
672 // by the renderer. 673 // by the renderer.
673 render_view()->GetWebView()->mainFrame() 674 render_view()->GetWebView()->mainFrame()->loadRequest(
674 ->loadRequest(WebURLRequest(GURL("about:blank"))); 675 WebURLRequest(GURL(kAboutBlankURL)));
675 Send(new ShellViewHostMsg_ResetDone(routing_id())); 676 Send(new ShellViewHostMsg_ResetDone(routing_id()));
676 } 677 }
677 678
678 void WebKitTestRunner::OnNotifyDone() { 679 void WebKitTestRunner::OnNotifyDone() {
679 render_view()->GetWebView()->mainFrame()->executeScript( 680 render_view()->GetWebView()->mainFrame()->executeScript(
680 WebScriptSource(WebString::fromUTF8("testRunner.notifyDone();"))); 681 WebScriptSource(WebString::fromUTF8("testRunner.notifyDone();")));
681 } 682 }
682 683
683 } // namespace content 684 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/resource_fetcher_browsertest.cc ('k') | content/shell/shell_application_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698