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_BROWSER_CHROMEOS_EXTENSIONS_VIRTUAL_KEYBOARD_BROWSERTEST_H_
6#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_VIRTUAL_KEYBOARD_BROWSERTEST_H_
7
8#include "base/files/file_path.h"
9#include "chrome/test/base/in_process_browser_test.h"
10#include "url/gurl.h"
11
12namespace base {
13class CommandLine;
14class FilePath;
15}
16
17namespace content {
18class RenderViewHost;
19class WebContents;
20}
21
22// See the .cc for default values.
23struct VirtualKeyboardBrowserTestConfig {
24  VirtualKeyboardBrowserTestConfig();
25
26  ~VirtualKeyboardBrowserTestConfig();
27
28  // The filename of the base framework. This file should be in |test_dir_|.
29  std::string base_framework_;
30
31  // The virtual keyboard's extension id.
32  std::string extension_id_;
33
34  // Path to the test directory.
35  std::string test_dir_;
36
37  // URL of the keyboard extension.
38  std::string url_;
39};
40
41class VirtualKeyboardBrowserTest : public InProcessBrowserTest {
42 public:
43  // Injects javascript in |file| into the keyboard page and runs the methods in
44  // |file| whose names match the expression "test*".
45  void RunTest(const base::FilePath& file,
46               const VirtualKeyboardBrowserTestConfig& config);
47
48  void ShowVirtualKeyboard();
49
50  // Returns the render view host that the keyboard with extension |id| is in.
51  content::RenderViewHost* GetKeyboardRenderViewHost(const std::string& id);
52
53  // InProcessBrowserTest.
54  // Ensure that the virtual keyboard is enabled.
55  virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
56
57 protected:
58  // Accumulates the javascript and injects it when the test starts. The test
59  // |file| is in directory |dir| relative to the root testing directory.
60  void InjectJavascript(const base::FilePath& dir, const base::FilePath& file);
61
62 private:
63  std::string utf8_content_;
64};
65
66#endif  // CHROME_BROWSER_CHROMEOS_EXTENSIONS_VIRTUAL_KEYBOARD_BROWSERTEST_H_
67