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

Unified Diff: chrome/test/base/extension_js_browser_test.h

Issue 320753002: Support javascript gtests in an extension background page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixup comment Created 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/base/extension_js_browser_test.h
diff --git a/chrome/test/base/extension_js_browser_test.h b/chrome/test/base/extension_js_browser_test.h
new file mode 100644
index 0000000000000000000000000000000000000000..49c4ac3634f30d4dabfba319fea7b81f2efd15f2
--- /dev/null
+++ b/chrome/test/base/extension_js_browser_test.h
@@ -0,0 +1,44 @@
+// Copyright 2014 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 CHROME_TEST_BASE_EXTENSION_JS_BROWSER_TEST_H_
+#define CHROME_TEST_BASE_EXTENSION_JS_BROWSER_TEST_H_
+
+#include "chrome/test/base/extension_load_waiter.h"
+#include "chrome/test/base/javascript_browser_test.h"
+
+// A super class that handles javascript-based tests against an extension.
+//
+// To use this class:
+// Add (or reuse) a WaitFor* method (e.g. WaitForWebStoreExtension) to this
Peter Lundblad 2014/06/11 16:45:05 Seems like the documentation is making forward-loo
Peter Lundblad 2014/06/11 16:45:05 Seems like the documentation is making forward-loo
Peter Lundblad 2014/06/11 16:45:05 Seems like the documentation is making forward-loo
+// class.
+// In your js test fixture, add on your prototype:
+// testGenPreamble: function() {
+// GEN(' MyLaunchMethod('extension_id');');
+// GEN(' WaitForWebStoreExtension('extension_id');');
+// },
+class ExtensionJSBrowserTest : public JavaScriptBrowserTest {
+ public:
+ ExtensionJSBrowserTest() : libs_loaded_(false) {}
+
+ virtual ~ExtensionJSBrowserTest() {}
+
+ protected:
+ // Waits for an extension to load.
+ void WaitFor(const char* extension_id);
Peter Lundblad 2014/06/11 16:45:05 Call WaitForExtension for clarity. Also, clarify
Peter Lundblad 2014/06/11 16:45:05 Call WaitForExtension for clarity. Also, clarify
Peter Lundblad 2014/06/11 16:45:05 Call WaitForExtension for clarity. Also, clarify
David Tseng 2014/06/11 17:52:54 Ok.
+
+ // Method required for js2gtest.
+ // Runs |test_fixture|.|test_name| using the framework in test_api.js.
+ bool RunJavascriptTestF(bool is_async,
+ const std::string& test_fixture,
+ const std::string& test_name);
+
+ private:
+ ExtensionLoadWaiter load_waiter_;
+ bool libs_loaded_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionJSBrowserTest);
+};
+
+#endif // CHROME_TEST_BASE_EXTENSION_JS_BROWSER_TEST_H_

Powered by Google App Engine
This is Rietveld 408576698