| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROME_TEST_RENDER_VIEW_TEST_H_ | 5 #ifndef CHROME_TEST_RENDER_VIEW_TEST_H_ |
| 6 #define CHROME_TEST_RENDER_VIEW_TEST_H_ | 6 #define CHROME_TEST_RENDER_VIEW_TEST_H_ |
| 7 | 7 |
| 8 #include <string> |
| 9 |
| 8 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "chrome/renderer/mock_keyboard.h" |
| 9 #include "chrome/renderer/mock_render_process.h" | 12 #include "chrome/renderer/mock_render_process.h" |
| 10 #include "chrome/renderer/mock_render_thread.h" | 13 #include "chrome/renderer/mock_render_thread.h" |
| 11 #include "chrome/renderer/render_view.h" | 14 #include "chrome/renderer/render_view.h" |
| 12 #include "chrome/renderer/renderer_webkitclient_impl.h" | 15 #include "chrome/renderer/renderer_webkitclient_impl.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "webkit/glue/webframe.h" | 17 #include "webkit/glue/webframe.h" |
| 15 | 18 |
| 16 class RenderViewTest : public testing::Test { | 19 class RenderViewTest : public testing::Test { |
| 17 public: | 20 public: |
| 18 RenderViewTest() {} | 21 RenderViewTest() {} |
| 19 ~RenderViewTest() {} | 22 ~RenderViewTest() {} |
| 20 | 23 |
| 21 protected: | 24 protected: |
| 22 // Spins the message loop to process all messages that are currently pending. | 25 // Spins the message loop to process all messages that are currently pending. |
| 23 void ProcessPendingMessages(); | 26 void ProcessPendingMessages(); |
| 24 | 27 |
| 25 // Returns a pointer to the main frame. | 28 // Returns a pointer to the main frame. |
| 26 WebFrame* GetMainFrame(); | 29 WebFrame* GetMainFrame(); |
| 27 | 30 |
| 28 // Executes the given JavaScript in the context of the main frame. The input | 31 // Executes the given JavaScript in the context of the main frame. The input |
| 29 // is a NULL-terminated UTF-8 string. | 32 // is a NULL-terminated UTF-8 string. |
| 30 void ExecuteJavaScript(const char* js); | 33 void ExecuteJavaScript(const char* js); |
| 31 | 34 |
| 32 // Loads the given HTML into the main frame as a data: URL. | 35 // Loads the given HTML into the main frame as a data: URL. |
| 33 void LoadHTML(const char* html); | 36 void LoadHTML(const char* html); |
| 34 | 37 |
| 38 // Sends IPC messages that emulates a key-press event. |
| 39 int SendKeyEvent(MockKeyboard::Layout layout, |
| 40 int key_code, |
| 41 MockKeyboard::Modifiers key_modifiers, |
| 42 std::wstring* output); |
| 43 |
| 35 // testing::Test | 44 // testing::Test |
| 36 virtual void SetUp(); | 45 virtual void SetUp(); |
| 37 | 46 |
| 38 virtual void TearDown(); | 47 virtual void TearDown(); |
| 39 | 48 |
| 40 MessageLoop msg_loop_; | 49 MessageLoop msg_loop_; |
| 41 MockRenderThread render_thread_; | 50 MockRenderThread render_thread_; |
| 42 scoped_ptr<MockProcess> mock_process_; | 51 scoped_ptr<MockProcess> mock_process_; |
| 43 scoped_refptr<RenderView> view_; | 52 scoped_refptr<RenderView> view_; |
| 44 RendererWebKitClientImpl webkitclient_; | 53 RendererWebKitClientImpl webkitclient_; |
| 54 scoped_ptr<MockKeyboard> mock_keyboard_; |
| 45 }; | 55 }; |
| 46 | 56 |
| 47 #endif // CHROME_TEST_RENDER_VIEW_TEST_H_ | 57 #endif // CHROME_TEST_RENDER_VIEW_TEST_H_ |
| OLD | NEW |