OLD | NEW |
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 #ifndef CONTENT_PUBLIC_TEST_RENDER_VIEW_TEST_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_RENDER_VIEW_TEST_H_ |
6 #define CONTENT_PUBLIC_TEST_RENDER_VIEW_TEST_H_ | 6 #define CONTENT_PUBLIC_TEST_RENDER_VIEW_TEST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "content/public/browser/native_web_keyboard_event.h" | 14 #include "content/public/browser/native_web_keyboard_event.h" |
15 #include "content/public/common/main_function_params.h" | 15 #include "content/public/common/main_function_params.h" |
16 #include "content/public/common/page_state.h" | 16 #include "content/public/common/page_state.h" |
17 #include "content/public/test/mock_render_thread.h" | 17 #include "content/public/test/mock_render_thread.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "third_party/WebKit/public/platform/Platform.h" | 19 #include "third_party/WebKit/public/platform/Platform.h" |
20 #include "third_party/WebKit/public/web/WebFrame.h" | 20 #include "third_party/WebKit/public/web/WebFrame.h" |
| 21 #include "third_party/WebKit/public/web/WebInputElement.h" |
21 | 22 |
22 struct ViewMsg_Resize_Params; | 23 struct ViewMsg_Resize_Params; |
23 | 24 |
24 namespace blink { | 25 namespace blink { |
25 class WebWidget; | 26 class WebWidget; |
26 } | 27 } |
27 | 28 |
28 namespace gfx { | 29 namespace gfx { |
29 class Rect; | 30 class Rect; |
30 } | 31 } |
31 | 32 |
32 namespace content { | 33 namespace content { |
33 class ContentBrowserClient; | 34 class ContentBrowserClient; |
34 class ContentClient; | 35 class ContentClient; |
35 class ContentRendererClient; | 36 class ContentRendererClient; |
36 class FakeCompositorDependencies; | 37 class FakeCompositorDependencies; |
| 38 class MockKeyboard; |
37 class MockRenderProcess; | 39 class MockRenderProcess; |
38 class PageState; | 40 class PageState; |
39 class RendererMainPlatformDelegate; | 41 class RendererMainPlatformDelegate; |
40 class RendererBlinkPlatformImplNoSandboxImpl; | 42 class RendererBlinkPlatformImplNoSandboxImpl; |
41 class RendererScheduler; | 43 class RendererScheduler; |
42 class RenderView; | 44 class RenderView; |
43 | 45 |
44 class RenderViewTest : public testing::Test { | 46 class RenderViewTest : public testing::Test { |
45 public: | 47 public: |
46 // A special BlinkPlatformImpl class for getting rid off the dependency to the | 48 // A special BlinkPlatformImpl class for getting rid off the dependency to the |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 void Reload(const GURL& url); | 122 void Reload(const GURL& url); |
121 | 123 |
122 // Returns the IPC message ID of the navigation message. | 124 // Returns the IPC message ID of the navigation message. |
123 uint32 GetNavigationIPCType(); | 125 uint32 GetNavigationIPCType(); |
124 | 126 |
125 // Resize the view. | 127 // Resize the view. |
126 void Resize(gfx::Size new_size, | 128 void Resize(gfx::Size new_size, |
127 gfx::Rect resizer_rect, | 129 gfx::Rect resizer_rect, |
128 bool is_fullscreen); | 130 bool is_fullscreen); |
129 | 131 |
| 132 // Sends IPC messages that emulate a key-press event. |
| 133 int SendKeyEvent(const MockKeyboard& keyboard, |
| 134 int key_code, |
| 135 base::string16* output); |
| 136 |
| 137 // Simulate typing the |ascii_character| into the browser. |
| 138 void SimulateUserTypingASCIICharacter(char ascii_character); |
| 139 |
| 140 // Simulates typing the |key_code| into the browser with Shift pressed if |
| 141 // |is_shift_pressed| is true. |
| 142 void SimulateUserTypingKeyCodeWithShift(int key_code, bool is_shift_pressed); |
| 143 |
| 144 // Simulates erasing text in the |input| and typing in the |new_value| |
| 145 // instead. The |input| should be focused to receive the keyboard events. |
| 146 void SimulateUserInputChangeForElement(blink::WebInputElement* input, |
| 147 blink::WebFrame* input_frame, |
| 148 const std::string& new_value); |
| 149 |
130 // These are all methods from RenderViewImpl that we expose to testing code. | 150 // These are all methods from RenderViewImpl that we expose to testing code. |
131 bool OnMessageReceived(const IPC::Message& msg); | 151 bool OnMessageReceived(const IPC::Message& msg); |
132 void DidNavigateWithinPage(blink::WebLocalFrame* frame, | 152 void DidNavigateWithinPage(blink::WebLocalFrame* frame, |
133 bool is_new_navigation); | 153 bool is_new_navigation); |
134 void SendContentStateImmediately(); | 154 void SendContentStateImmediately(); |
135 blink::WebWidget* GetWebWidget(); | 155 blink::WebWidget* GetWebWidget(); |
136 | 156 |
137 // Allows a subclass to override the various content client implementations. | 157 // Allows a subclass to override the various content client implementations. |
138 virtual ContentClient* CreateContentClient(); | 158 virtual ContentClient* CreateContentClient(); |
139 virtual ContentBrowserClient* CreateContentBrowserClient(); | 159 virtual ContentBrowserClient* CreateContentBrowserClient(); |
(...skipping 28 matching lines...) Expand all Loading... |
168 scoped_ptr<base::mac::ScopedNSAutoreleasePool> autorelease_pool_; | 188 scoped_ptr<base::mac::ScopedNSAutoreleasePool> autorelease_pool_; |
169 #endif | 189 #endif |
170 | 190 |
171 private: | 191 private: |
172 void GoToOffset(int offset, const PageState& state); | 192 void GoToOffset(int offset, const PageState& state); |
173 }; | 193 }; |
174 | 194 |
175 } // namespace content | 195 } // namespace content |
176 | 196 |
177 #endif // CONTENT_PUBLIC_TEST_RENDER_VIEW_TEST_H_ | 197 #endif // CONTENT_PUBLIC_TEST_RENDER_VIEW_TEST_H_ |
OLD | NEW |