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

Side by Side Diff: content/public/test/browser_test_utils.h

Issue 2052633002: Extend the ToRenderFrameHost magic to FrameTreeNode* and Shell* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix induced script bug. Created 4 years, 6 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
OLDNEW
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_BROWSER_TEST_UTILS_H_ 5 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_
6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ 6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 ui::DomKey key, 159 ui::DomKey key,
160 ui::DomCode code, 160 ui::DomCode code,
161 ui::KeyboardCode key_code, 161 ui::KeyboardCode key_code,
162 bool control, 162 bool control,
163 bool shift, 163 bool shift,
164 bool alt, 164 bool alt,
165 bool command); 165 bool command);
166 166
167 // Allow ExecuteScript* methods to target either a WebContents or a 167 // Allow ExecuteScript* methods to target either a WebContents or a
168 // RenderFrameHost. Targetting a WebContents means executing the script in the 168 // RenderFrameHost. Targetting a WebContents means executing the script in the
169 // RenderFrameHost returned by WebContents::GetMainFrame(), which is the 169 // RenderFrameHost returned by WebContents::GetMainFrame(), which is the main
170 // main frame. Pass a specific RenderFrameHost to target it. 170 // frame. Pass a specific RenderFrameHost to target it. Embedders may declare
171 // additional ConvertToRenderFrameHost functions for convenience.
171 class ToRenderFrameHost { 172 class ToRenderFrameHost {
172 public: 173 public:
173 ToRenderFrameHost(WebContents* web_contents); 174 template <typename T>
174 ToRenderFrameHost(RenderViewHost* render_view_host); 175 ToRenderFrameHost(T* frame_convertible_value)
175 ToRenderFrameHost(RenderFrameHost* render_frame_host); 176 : render_frame_host_(ConvertToRenderFrameHost(frame_convertible_value)) {}
176 177
178 // Extract the underlying frame.
177 RenderFrameHost* render_frame_host() const { return render_frame_host_; } 179 RenderFrameHost* render_frame_host() const { return render_frame_host_; }
178 180
179 private: 181 private:
180 RenderFrameHost* render_frame_host_; 182 RenderFrameHost* render_frame_host_;
181 }; 183 };
182 184
185 RenderFrameHost* ConvertToRenderFrameHost(RenderViewHost* render_view_host);
186 RenderFrameHost* ConvertToRenderFrameHost(RenderFrameHost* render_view_host);
187 RenderFrameHost* ConvertToRenderFrameHost(WebContents* web_contents);
188
183 // Executes the passed |script| in the specified frame. The |script| should not 189 // Executes the passed |script| in the specified frame. The |script| should not
184 // invoke domAutomationController.send(); otherwise, your test will hang or be 190 // invoke domAutomationController.send(); otherwise, your test will hang or be
185 // flaky. If you want to extract a result, use one of the below functions. 191 // flaky. If you want to extract a result, use one of the below functions.
186 // Returns true on success. 192 // Returns true on success.
187 bool ExecuteScript(const ToRenderFrameHost& adapter, 193 bool ExecuteScript(const ToRenderFrameHost& adapter,
188 const std::string& script) WARN_UNUSED_RESULT; 194 const std::string& script) WARN_UNUSED_RESULT;
189 195
190 // The following methods executes the passed |script| in the specified frame and 196 // The following methods executes the passed |script| in the specified frame and
191 // sets |result| to the value passed to "window.domAutomationController.send" by 197 // sets |result| to the value passed to "window.domAutomationController.send" by
192 // the executed script. They return true on success, false if the script 198 // the executed script. They return true on success, false if the script
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 blink::WebInputEvent::Type wait_for_type_; 506 blink::WebInputEvent::Type wait_for_type_;
501 uint32_t ack_result_; 507 uint32_t ack_result_;
502 base::Closure quit_; 508 base::Closure quit_;
503 509
504 DISALLOW_COPY_AND_ASSIGN(InputMsgWatcher); 510 DISALLOW_COPY_AND_ASSIGN(InputMsgWatcher);
505 }; 511 };
506 512
507 } // namespace content 513 } // namespace content
508 514
509 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ 515 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698