| OLD | NEW |
| 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/render_view_test.h" | 5 #include "chrome/test/render_view_test.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 7 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 8 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
| 9 #include "chrome/common/native_web_keyboard_event.h" | 9 #include "chrome/common/native_web_keyboard_event.h" |
| 10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } | 54 } |
| 55 | 55 |
| 56 WebFrame* RenderViewTest::GetMainFrame() { | 56 WebFrame* RenderViewTest::GetMainFrame() { |
| 57 return view_->webview()->mainFrame(); | 57 return view_->webview()->mainFrame(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void RenderViewTest::ExecuteJavaScript(const char* js) { | 60 void RenderViewTest::ExecuteJavaScript(const char* js) { |
| 61 GetMainFrame()->executeScript(WebScriptSource(WebString::fromUTF8(js))); | 61 GetMainFrame()->executeScript(WebScriptSource(WebString::fromUTF8(js))); |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool RenderViewTest::ExecuteJavaScriptAndReturnIntValue( |
| 65 const string16& script, |
| 66 int* int_result) { |
| 67 v8::Handle<v8::Value> result = |
| 68 GetMainFrame()->executeScriptAndReturnValue(WebScriptSource(script)); |
| 69 if (result.IsEmpty() || !result->IsInt32()) |
| 70 return false; |
| 71 |
| 72 if (int_result) |
| 73 *int_result = result->Int32Value(); |
| 74 |
| 75 return true; |
| 76 } |
| 77 |
| 64 void RenderViewTest::LoadHTML(const char* html) { | 78 void RenderViewTest::LoadHTML(const char* html) { |
| 65 std::string url_str = "data:text/html;charset=utf-8,"; | 79 std::string url_str = "data:text/html;charset=utf-8,"; |
| 66 url_str.append(html); | 80 url_str.append(html); |
| 67 GURL url(url_str); | 81 GURL url(url_str); |
| 68 | 82 |
| 69 GetMainFrame()->loadRequest(WebURLRequest(url)); | 83 GetMainFrame()->loadRequest(WebURLRequest(url)); |
| 70 | 84 |
| 71 // The load actually happens asynchronously, so we pump messages to process | 85 // The load actually happens asynchronously, so we pump messages to process |
| 72 // the pending continuation. | 86 // the pending continuation. |
| 73 ProcessPendingMessages(); | 87 ProcessPendingMessages(); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 mouse_event.button = WebMouseEvent::ButtonLeft; | 335 mouse_event.button = WebMouseEvent::ButtonLeft; |
| 322 mouse_event.x = bounds.CenterPoint().x(); | 336 mouse_event.x = bounds.CenterPoint().x(); |
| 323 mouse_event.y = bounds.CenterPoint().y(); | 337 mouse_event.y = bounds.CenterPoint().y(); |
| 324 mouse_event.clickCount = 1; | 338 mouse_event.clickCount = 1; |
| 325 ViewMsg_HandleInputEvent input_event(0); | 339 ViewMsg_HandleInputEvent input_event(0); |
| 326 input_event.WriteData(reinterpret_cast<const char*>(&mouse_event), | 340 input_event.WriteData(reinterpret_cast<const char*>(&mouse_event), |
| 327 sizeof(WebMouseEvent)); | 341 sizeof(WebMouseEvent)); |
| 328 view_->OnHandleInputEvent(input_event); | 342 view_->OnHandleInputEvent(input_event); |
| 329 return true; | 343 return true; |
| 330 } | 344 } |
| OLD | NEW |