1 // Copyright 2014 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. 4 5 #ifndef CHROME_TEST_BASE_EXTENSION_JS_BROWSER_TEST_H_ 6 #define CHROME_TEST_BASE_EXTENSION_JS_BROWSER_TEST_H_ 7 8 #include "base/callback_forward.h" 9 #include "chrome/test/base/extension_load_waiter_one_shot.h" 10 #include "chrome/test/base/javascript_browser_test.h" 11 12 // A super class that handles javascript-based tests against an extension. 13 // 14 // See an example usage at 15 //chrome/browser/resources/chromeos/chromevox2/cvox2/background/background.extjs 16 class ExtensionJSBrowserTest : public JavaScriptBrowserTest { 17 public: 18 ExtensionJSBrowserTest(); 19 20 virtual ~ExtensionJSBrowserTest(); 21 22 protected: 23 // Waits for an extension to load; returns immediately if already loaded. 24 void WaitForExtension(const char* extension_id, const base::Closure& load_cb); 25 26 // Method required for js2gtest. 27 // Runs |test_fixture|.|test_name| using the framework in test_api.js. 28 bool RunJavascriptTestF(bool is_async, 29 const std::string& test_fixture, 30 const std::string& test_name); 31 32 private: 33 scoped_ptr<ExtensionLoadWaiterOneShot> load_waiter_; 34 bool libs_loaded_; 35 36 DISALLOW_COPY_AND_ASSIGN(ExtensionJSBrowserTest); 37 }; 38 39 #endif // CHROME_TEST_BASE_EXTENSION_JS_BROWSER_TEST_H_ 40