summaryrefslogtreecommitdiffstats
path: root/chrome/test/ui_test_utils.h
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-29 22:24:01 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-29 22:24:01 +0000
commit45671618a6690a8501f01905a4ed6d19cfcdc0b1 (patch)
tree92137770b65d54fb7b025e7d004bc3c0c107955f /chrome/test/ui_test_utils.h
parent30369d92f0970a3b4f8720a00449023cb171fd28 (diff)
downloadchromium_src-45671618a6690a8501f01905a4ed6d19cfcdc0b1.zip
chromium_src-45671618a6690a8501f01905a4ed6d19cfcdc0b1.tar.gz
chromium_src-45671618a6690a8501f01905a4ed6d19cfcdc0b1.tar.bz2
Migrating the SSL UI tests to be browser tests.
Reenabling all of them. Hopefully it'll help with flakiness. Note that I am keeping the SSL UI tests alive until the browser test framework has been ported to Mac and Linux. BUG=6584,2136 TEST=Run the browser tests. Review URL: http://codereview.chromium.org/101013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14901 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/ui_test_utils.h')
-rw-r--r--chrome/test/ui_test_utils.h61
1 files changed, 28 insertions, 33 deletions
diff --git a/chrome/test/ui_test_utils.h b/chrome/test/ui_test_utils.h
index 863c758..3c166e8 100644
--- a/chrome/test/ui_test_utils.h
+++ b/chrome/test/ui_test_utils.h
@@ -13,7 +13,8 @@
class Browser;
class GURL;
class NavigationController;
-class WebContents;
+class Value;
+class TabContents;
// A collections of functions designed for use with InProcessBrowserTest.
namespace ui_test_utils {
@@ -43,38 +44,32 @@ void NavigateToURLBlockUntilNavigationsComplete(Browser* browser,
int number_of_navigations);
-// This class enables you to send JavaScript as a string from the browser to the
-// renderer for execution in a frame of your choice.
-class JavaScriptRunner : public NotificationObserver {
- public:
- // Constructor. |web_contents| is a pointer to the WebContents you want to run
- // the JavaScript code in. |frame_xpath| is a path to the frame to run it in.
- // |jscript| is a string containing the JavaScript code to run, for example:
- // "window.domAutomationController.send(alert('hello world'));". The
- // JavaScript code will execute when Run is called. Note: In order for the
- // domAutomationController to work, you must call EnableDOMAutomation() in
- // your test class first.
- JavaScriptRunner(WebContents* web_contents,
- const std::wstring& frame_xpath,
- const std::wstring& jscript);
-
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
-
- // Executes the JavaScript code passed in to the constructor. See also comment
- // about EnableDOMAutomation in the constructor.
- std::string Run();
-
- private:
- WebContents* web_contents_;
- std::wstring frame_xpath_;
- std::wstring jscript_;
- std::string result_;
-
- DISALLOW_COPY_AND_ASSIGN(JavaScriptRunner);
-};
-
+// Executes the passed |script| in the frame pointed to by |frame_xpath| (use
+// empty string for main frame) and returns the value the evaluation of the
+// script returned. The caller owns the returned value.
+Value* ExecuteJavaScript(TabContents* tab_contents,
+ const std::wstring& frame_xpath,
+ const std::wstring& script);
+
+// The following methods executes the passed |script| in the frame pointed to by
+// |frame_xpath| (use empty string for main frame) and sets |result| to the
+// value returned by the script evaluation.
+// They return true on success, false if the script evaluation failed or did not
+// evaluate to the expected type.
+// Note: In order for the domAutomationController to work, you must call
+// EnableDOMAutomation() in your test first.
+bool ExecuteJavaScriptAndExtractInt(TabContents* tab_contents,
+ const std::wstring& frame_xpath,
+ const std::wstring& script,
+ int* result);
+bool ExecuteJavaScriptAndExtractBool(TabContents* tab_contents,
+ const std::wstring& frame_xpath,
+ const std::wstring& script,
+ bool* result);
+bool ExecuteJavaScriptAndExtractString(TabContents* tab_contents,
+ const std::wstring& frame_xpath,
+ const std::wstring& script,
+ std::string* result);
}
#endif // CHROME_TEST_UI_TEST_UTILS_H_