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

Side by Side Diff: chrome/test/ui_test_utils.cc

Issue 6312154: Remove wstring from RVH's run Javascript command.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/ui_test_utils.h" 5 #include "chrome/test/ui_test_utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 public JavaScriptExecutionController { 281 public JavaScriptExecutionController {
282 public: 282 public:
283 explicit InProcessJavaScriptExecutionController( 283 explicit InProcessJavaScriptExecutionController(
284 RenderViewHost* render_view_host) 284 RenderViewHost* render_view_host)
285 : render_view_host_(render_view_host) {} 285 : render_view_host_(render_view_host) {}
286 286
287 protected: 287 protected:
288 // Executes |script| and sets the JSON response |json|. 288 // Executes |script| and sets the JSON response |json|.
289 virtual bool ExecuteJavaScriptAndGetJSON(const std::string& script, 289 virtual bool ExecuteJavaScriptAndGetJSON(const std::string& script,
290 std::string* json) { 290 std::string* json) {
291 render_view_host_->ExecuteJavascriptInWebFrame(L"", UTF8ToWide(script)); 291 render_view_host_->ExecuteJavascriptInWebFrame(string16(),
292 UTF8ToUTF16(script));
292 DOMOperationObserver dom_op_observer(render_view_host_); 293 DOMOperationObserver dom_op_observer(render_view_host_);
293 return dom_op_observer.GetResponse(json); 294 return dom_op_observer.GetResponse(json);
294 } 295 }
295 296
296 virtual void FirstObjectAdded() { 297 virtual void FirstObjectAdded() {
297 AddRef(); 298 AddRef();
298 } 299 }
299 300
300 virtual void LastObjectRemoved() { 301 virtual void LastObjectRemoved() {
301 Release(); 302 Release();
(...skipping 14 matching lines...) Expand all
316 // |frame_xpath|. If |result| is not NULL, stores the value that the evaluation 317 // |frame_xpath|. If |result| is not NULL, stores the value that the evaluation
317 // of the script in |result|. Returns true on success. 318 // of the script in |result|. Returns true on success.
318 bool ExecuteJavaScriptHelper(RenderViewHost* render_view_host, 319 bool ExecuteJavaScriptHelper(RenderViewHost* render_view_host,
319 const std::wstring& frame_xpath, 320 const std::wstring& frame_xpath,
320 const std::wstring& original_script, 321 const std::wstring& original_script,
321 scoped_ptr<Value>* result) { 322 scoped_ptr<Value>* result) {
322 // TODO(jcampan): we should make the domAutomationController not require an 323 // TODO(jcampan): we should make the domAutomationController not require an
323 // automation id. 324 // automation id.
324 std::wstring script = L"window.domAutomationController.setAutomationId(0);" + 325 std::wstring script = L"window.domAutomationController.setAutomationId(0);" +
325 original_script; 326 original_script;
326 render_view_host->ExecuteJavascriptInWebFrame(frame_xpath, script); 327 render_view_host->ExecuteJavascriptInWebFrame(WideToUTF16Hack(frame_xpath),
328 WideToUTF16Hack(script));
327 DOMOperationObserver dom_op_observer(render_view_host); 329 DOMOperationObserver dom_op_observer(render_view_host);
328 std::string json; 330 std::string json;
329 if (!dom_op_observer.GetResponse(&json)) 331 if (!dom_op_observer.GetResponse(&json))
330 return false; 332 return false;
331 333
332 // Nothing more to do for callers that ignore the returned JS value. 334 // Nothing more to do for callers that ignore the returned JS value.
333 if (!result) 335 if (!result)
334 return true; 336 return true;
335 337
336 // Wrap |json| in an array before deserializing because valid JSON has an 338 // Wrap |json| in an array before deserializing because valid JSON has an
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); 1026 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap);
1025 } 1027 }
1026 1028
1027 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { 1029 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) {
1028 DCHECK(bitmap); 1030 DCHECK(bitmap);
1029 SnapshotTaker taker; 1031 SnapshotTaker taker;
1030 return taker.TakeEntirePageSnapshot(rvh, bitmap); 1032 return taker.TakeEntirePageSnapshot(rvh, bitmap);
1031 } 1033 }
1032 1034
1033 } // namespace ui_test_utils 1035 } // namespace ui_test_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698