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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_WEB_UI_TEST_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_WEB_UI_TEST_HANDLER_H_
8 #include "base/compiler_specific.h"
9 #include "base/strings/string16.h"
10 #include "content/public/browser/web_ui_message_handler.h"
21 // This class registers test framework specific handlers on WebUI objects.
22 class WebUITestHandler
: public content::WebUIMessageHandler
{
26 // Sends a message through |preload_host| with the |js_text| to preload at the
27 // appropriate time before the onload call is made.
28 void PreloadJavaScript(const base::string16
& js_text
,
29 content::RenderViewHost
* preload_host
);
31 // Runs |js_text| in this object's WebUI frame. Does not wait for any result.
32 void RunJavaScript(const base::string16
& js_text
);
34 // Runs |js_text| in this object's WebUI frame. Waits for result, logging an
35 // error message on failure. Returns test pass/fail.
36 bool RunJavaScriptTestWithResult(const base::string16
& js_text
);
38 // WebUIMessageHandler overrides.
39 // Add test handlers to the current WebUI object.
40 void RegisterMessages() override
;
43 // Receives testResult messages.
44 void HandleTestResult(const base::ListValue
* test_result
);
46 // Gets the callback that Javascript execution is complete.
47 void JavaScriptComplete(const base::Value
* result
);
49 // Runs a message loop until test finishes. Returns the result of the
53 // Received test pass/fail;
56 // Pass fail result of current test.
59 // Test code finished trying to execute. This will be set to true when the
60 // selected tab is done with this execution request whether it was able to
61 // parse/execute the javascript or not.
64 // Test code was able to execute successfully. This is *NOT* the test
66 bool run_test_succeeded_
;
68 // Waiting for a test to finish.
71 DISALLOW_COPY_AND_ASSIGN(WebUITestHandler
);
74 #endif // CHROME_BROWSER_UI_WEBUI_WEB_UI_TEST_HANDLER_H_