summaryrefslogtreecommitdiffstats
path: root/content/browser/webui/web_ui_browsertest.h
diff options
context:
space:
mode:
Diffstat (limited to 'content/browser/webui/web_ui_browsertest.h')
-rw-r--r--content/browser/webui/web_ui_browsertest.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/content/browser/webui/web_ui_browsertest.h b/content/browser/webui/web_ui_browsertest.h
new file mode 100644
index 0000000..000fbde
--- /dev/null
+++ b/content/browser/webui/web_ui_browsertest.h
@@ -0,0 +1,58 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_WEBUI_WEB_UI_BROWSERTEST_H_
+#define CONTENT_BROWSER_WEBUI_WEB_UI_BROWSERTEST_H_
+#pragma once
+
+#include <string>
+
+#include "base/file_path.h"
+#include "chrome/test/in_process_browser_test.h"
+#include "content/browser/webui/web_ui_handler_browsertest.h"
+
+class WebUIMessageHandler;
+
+// The runner of WebUI javascript based tests.
+// See chrome/test/data/webui/test_api.js for the javascript side test API's.
+//
+// These tests should follow the form given in:
+// chrome/test/data/webui/sample_downloads.js.
+// and the lone test within this class.
+class WebUIBrowserTest : public InProcessBrowserTest {
+ public:
+ virtual ~WebUIBrowserTest();
+
+ bool RunWebUITest(const FilePath::CharType* src_path);
+
+ protected:
+ WebUIBrowserTest();
+
+ // Setup test path.
+ virtual void SetUpInProcessBrowserTestFixture();
+
+ // Returns a mock WebUI object under test (if any).
+ virtual WebUIMessageHandler* GetMockMessageHandler();
+
+ private:
+ // Builds a javascript test in the form:
+ // <js_library> ...
+ // <src_path> ...
+ // runTests(function test1() {...},
+ // ...
+ // );
+ void BuildJavaScriptTest(const FilePath& src_path,
+ std::string* content);
+
+ // Attaches mock and test handlers.
+ void SetupHandlers();
+
+ // Handles test framework messages.
+ scoped_ptr<WebUIHandlerBrowserTest> test_handler_;
+
+ // Location of test data (currently test/data/webui).
+ FilePath test_data_directory_;
+};
+
+#endif // CONTENT_BROWSER_WEBUI_WEB_UI_BROWSERTEST_H_