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

Side by Side Diff: chrome/test/ui_test_utils.h

Issue 79024: Fix 10573: Dismissing FindInPage doesn't set focus to the link... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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/data/find_in_page/end_state.html ('k') | chrome/test/ui_test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 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_UI_TEST_UTILS_H_ 5 #ifndef CHROME_TEST_UI_TEST_UTILS_H_
6 #define CHROME_TEST_UI_TEST_UTILS_H_ 6 #define CHROME_TEST_UI_TEST_UTILS_H_
7 7
8 #include "base/basictypes.h"
9 #include "chrome/common/notification_observer.h"
10
8 class Browser; 11 class Browser;
9 class GURL; 12 class GURL;
10 class NavigationController; 13 class NavigationController;
14 class WebContents;
11 15
12 // A collections of functions designed for use with InProcessBrowserTest. 16 // A collections of functions designed for use with InProcessBrowserTest.
13 namespace ui_test_utils { 17 namespace ui_test_utils {
14 18
15 // Turns on nestable tasks, runs the message loop, then resets nestable tasks 19 // Turns on nestable tasks, runs the message loop, then resets nestable tasks
16 // to what they were originally. Prefer this over MessageLoop::Run for in 20 // to what they were originally. Prefer this over MessageLoop::Run for in
17 // process browser tests that need to block until a condition is met. 21 // process browser tests that need to block until a condition is met.
18 void RunMessageLoop(); 22 void RunMessageLoop();
19 23
20 // Waits for |controller| to complete a navigation. This blocks until 24 // Waits for |controller| to complete a navigation. This blocks until
21 // the navigation finishes. 25 // the navigation finishes.
22 void WaitForNavigation(NavigationController* controller); 26 void WaitForNavigation(NavigationController* controller);
23 27
24 // Waits for |controller| to complete a navigation. This blocks until 28 // Waits for |controller| to complete a navigation. This blocks until
25 // the specified number of navigations complete. 29 // the specified number of navigations complete.
26 void WaitForNavigations(NavigationController* controller, 30 void WaitForNavigations(NavigationController* controller,
27 int number_of_navigations); 31 int number_of_navigations);
28 32
29 // Navigates the selected tab of |browser| to |url|, blocking until the 33 // Navigates the selected tab of |browser| to |url|, blocking until the
30 // navigation finishes. 34 // navigation finishes.
31 void NavigateToURL(Browser* browser, const GURL& url); 35 void NavigateToURL(Browser* browser, const GURL& url);
32 36
33 // Navigates the selected tab of |browser| to |url|, blocking until the 37 // Navigates the selected tab of |browser| to |url|, blocking until the
34 // number of navigations specified complete. 38 // number of navigations specified complete.
35 void NavigateToURLBlockUntilNavigationsComplete(Browser* browser, 39 void NavigateToURLBlockUntilNavigationsComplete(Browser* browser,
36 const GURL& url, 40 const GURL& url,
37 int number_of_navigations); 41 int number_of_navigations);
42
43
44 // This class enables you to send JavaScript as a string from the browser to the
45 // renderer for execution in a frame of your choice.
46 class JavaScriptRunner : public NotificationObserver {
47 public:
48 // Constructor. |web_contents| is a pointer to the WebContents you want to run
49 // the JavaScript code in. |frame_xpath| is a path to the frame to run it in.
50 // |jscript| is a string containing the JavaScript code to run, for example:
51 // "window.domAutomationController.send(alert('hello world'));". The
52 // JavaScript code will execute when Run is called. Note: In order for the
53 // domAutomationController to work, you must call EnableDOMAutomation() in
54 // your test class first.
55 JavaScriptRunner(WebContents* web_contents,
56 const std::wstring& frame_xpath,
57 const std::wstring& jscript);
58
59 virtual void Observe(NotificationType type,
60 const NotificationSource& source,
61 const NotificationDetails& details);
62
63 // Executes the JavaScript code passed in to the constructor. See also comment
64 // about EnableDOMAutomation in the constructor.
65 std::string Run();
66
67 private:
68 WebContents* web_contents_;
69 std::wstring frame_xpath_;
70 std::wstring jscript_;
71 std::string result_;
72
73 DISALLOW_COPY_AND_ASSIGN(JavaScriptRunner);
74 };
75
38 } 76 }
39 77
40 #endif // CHROME_TEST_UI_TEST_UTILS_H_ 78 #endif // CHROME_TEST_UI_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « chrome/test/data/find_in_page/end_state.html ('k') | chrome/test/ui_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698