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.
5 #ifndef CHROME_TEST_BASE_JAVASCRIPT_BROWSER_TEST_H_
6 #define CHROME_TEST_BASE_JAVASCRIPT_BROWSER_TEST_H_
8 #include "base/memory/scoped_vector.h"
9 #include "base/strings/string16.h"
10 #include "base/values.h"
11 #include "chrome/test/base/in_process_browser_test.h"
13 // A base class providing construction of javascript testing assets.
14 class JavaScriptBrowserTest
: public InProcessBrowserTest
{
16 static const base::FilePath::CharType kA11yAuditLibraryJSPath
[];
17 static const base::FilePath::CharType kMockJSPath
[];
18 static const base::FilePath::CharType kWebUILibraryJS
[];
19 static const base::FilePath::CharType kWebUITestFolder
[];
21 typedef ScopedVector
<const base::Value
> ConstValueVector
;
23 // Add a custom helper JS library for your test.
24 // If a relative path is specified, it'll be read
25 // as relative to the test data dir.
26 void AddLibrary(const base::FilePath
& library_path
);
29 JavaScriptBrowserTest();
31 ~JavaScriptBrowserTest() override
;
33 // InProcessBrowserTest overrides.
34 void SetUpOnMainThread() override
;
36 // Builds a vector of strings of all added javascript libraries suitable for
37 // execution by subclasses.
38 void BuildJavascriptLibraries(std::vector
<base::string16
>* libraries
);
40 // Builds a string with a call to the runTest JS function, passing the
41 // given |is_async|, |test_name| and its |args|.
42 // This is then suitable for execution by subclasses in a
43 // |RunJavaScriptBrowserTestF| call.
44 base::string16
BuildRunTestJSCall(bool is_async
,
45 const std::string
& test_name
,
46 const ConstValueVector
& args
);
49 // User added libraries.
50 std::vector
<base::FilePath
> user_libraries_
;
52 // User library search paths.
53 std::vector
<base::FilePath
> library_search_paths_
;
55 DISALLOW_COPY_AND_ASSIGN(JavaScriptBrowserTest
);
58 #endif // CHROME_TEST_BASE_JAVASCRIPT_BROWSER_TEST_H_