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

Side by Side Diff: chrome/test/base/render_view_test.h

Issue 8230034: Split most of RenderViewTest and associated classes into content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Mac build breaks. Created 9 years, 2 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
« no previous file with comments | « chrome/test/base/chrome_render_view_test.cc ('k') | chrome/test/base/render_view_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_TEST_BASE_RENDER_VIEW_TEST_H_
6 #define CHROME_TEST_BASE_RENDER_VIEW_TEST_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/command_line.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop.h"
14 #include "chrome/renderer/autofill/autofill_agent.h"
15 #include "chrome/renderer/mock_keyboard.h"
16 #include "chrome/renderer/mock_render_thread.h"
17 #include "content/common/main_function_params.h"
18 #include "content/common/native_web_keyboard_event.h"
19 #include "content/common/sandbox_init_wrapper.h"
20 #include "content/renderer/renderer_webkitplatformsupport_impl.h"
21 #include "chrome/renderer/chrome_content_renderer_client.h"
22 #include "testing/gtest/include/gtest/gtest.h"
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
24
25 class ExtensionDispatcher;
26 class MockRenderProcess;
27 class RendererMainPlatformDelegate;
28 struct ViewMsg_Navigate_Params;
29
30 namespace WebKit {
31 class WebWidget;
32 }
33
34 namespace autofill {
35 class AutofillAgent;
36 class PasswordAutofillManager;
37 }
38
39 namespace content {
40 class RenderView;
41 }
42
43 namespace gfx {
44 class Rect;
45 }
46
47 class RenderViewTest : public testing::Test {
48 public:
49 // A special WebKitPlatformSupportImpl class for getting rid off the
50 // dependency to the sandbox, which is not available in RenderViewTest.
51 class RendererWebKitPlatformSupportImplNoSandbox :
52 public RendererWebKitPlatformSupportImpl {
53 public:
54 virtual WebKit::WebSandboxSupport* sandboxSupport() {
55 return NULL;
56 }
57 };
58
59 RenderViewTest();
60 virtual ~RenderViewTest();
61
62 protected:
63 // Spins the message loop to process all messages that are currently pending.
64 void ProcessPendingMessages();
65
66 // Returns a pointer to the main frame.
67 WebKit::WebFrame* GetMainFrame();
68
69 // Executes the given JavaScript in the context of the main frame. The input
70 // is a NULL-terminated UTF-8 string.
71 void ExecuteJavaScript(const char* js);
72
73 // Executes the given JavaScript and sets the int value it evaluates to in
74 // |result|.
75 // Returns true if the JavaScript was evaluated correctly to an int value,
76 // false otherwise.
77 bool ExecuteJavaScriptAndReturnIntValue(const string16& script, int* result);
78
79 // Loads the given HTML into the main frame as a data: URL.
80 void LoadHTML(const char* html);
81
82 // Sends IPC messages that emulates a key-press event.
83 int SendKeyEvent(MockKeyboard::Layout layout,
84 int key_code,
85 MockKeyboard::Modifiers key_modifiers,
86 std::wstring* output);
87
88 // Sends one native key event over IPC.
89 void SendNativeKeyEvent(const NativeWebKeyboardEvent& key_event);
90
91 // Returns the bounds (coordinates and size) of the element with id
92 // |element_id|. Returns an empty rect if such an element was not found.
93 gfx::Rect GetElementBounds(const std::string& element_id);
94
95 // Sends a left mouse click in the middle of the element with id |element_id|.
96 // Returns true if the event was sent, false otherwise (typically because
97 // the element was not found).
98 bool SimulateElementClick(const std::string& element_id);
99
100 // Clears anything associated with the browsing history.
101 void ClearHistory();
102
103 // These are all methods from RenderViewImpl that we expose to testing code.
104 bool OnMessageReceived(const IPC::Message& msg);
105 void OnNavigate(const ViewMsg_Navigate_Params& params);
106 void DidNavigateWithinPage(WebKit::WebFrame* frame, bool is_new_navigation);
107 void SendContentStateImmediately();
108 WebKit::WebWidget* GetWebWidget();
109
110 // testing::Test
111 virtual void SetUp();
112
113 virtual void TearDown();
114
115 MessageLoop msg_loop_;
116 chrome::ChromeContentRendererClient chrome_content_renderer_client_;
117 ExtensionDispatcher* extension_dispatcher_;
118 MockRenderThread render_thread_;
119 scoped_ptr<MockRenderProcess> mock_process_;
120 // We use a naked pointer because we don't want to expose RenderViewImpl in
121 // the embedder's namespace.
122 content::RenderView* view_;
123 RendererWebKitPlatformSupportImplNoSandbox webkit_platform_support_;
124 scoped_ptr<MockKeyboard> mock_keyboard_;
125
126 // Used to setup the process so renderers can run.
127 scoped_ptr<RendererMainPlatformDelegate> platform_;
128 scoped_ptr<MainFunctionParams> params_;
129 scoped_ptr<CommandLine> command_line_;
130 scoped_ptr<SandboxInitWrapper> sandbox_init_wrapper_;
131
132 autofill::PasswordAutofillManager* password_autofill_;
133 autofill::AutofillAgent* autofill_agent_;
134 };
135
136 #endif // CHROME_TEST_BASE_RENDER_VIEW_TEST_H_
OLDNEW
« no previous file with comments | « chrome/test/base/chrome_render_view_test.cc ('k') | chrome/test/base/render_view_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698