summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/extensions/virtual_keyboard_browsertest.h
blob: 930edf28f74f47b4bb0527ba92902698ca348703 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// 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_BROWSER_CHROMEOS_EXTENSIONS_VIRTUAL_KEYBOARD_BROWSERTEST_H_
#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_VIRTUAL_KEYBOARD_BROWSERTEST_H_

#include "base/files/file_path.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "url/gurl.h"

namespace base {
class CommandLine;
class FilePath;
}

namespace content {
class RenderViewHost;
class WebContents;
}

// See the .cc for default values.
struct VirtualKeyboardBrowserTestConfig {
  VirtualKeyboardBrowserTestConfig();

  ~VirtualKeyboardBrowserTestConfig();

  // The filename of the base framework. This file should be in |test_dir_|.
  std::string base_framework_;

  // The virtual keyboard's extension id.
  std::string extension_id_;

  // Path to the test directory.
  std::string test_dir_;

  // URL of the keyboard extension.
  std::string url_;
};

class VirtualKeyboardBrowserTest : public InProcessBrowserTest {
 public:
  // Injects javascript in |file| into the keyboard page and runs the methods in
  // |file| whose names match the expression "test*".
  void RunTest(const base::FilePath& file,
               const VirtualKeyboardBrowserTestConfig& config);

  void ShowVirtualKeyboard();

  // Returns the render view host that the keyboard with extension |id| is in.
  content::RenderViewHost* GetKeyboardRenderViewHost(const std::string& id);

  // InProcessBrowserTest.
  // Ensure that the virtual keyboard is enabled.
  virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;

 protected:
  // Accumulates the javascript and injects it when the test starts. The test
  // |file| is in directory |dir| relative to the root testing directory.
  void InjectJavascript(const base::FilePath& dir, const base::FilePath& file);

 private:
  std::string utf8_content_;
};

#endif  // CHROME_BROWSER_CHROMEOS_EXTENSIONS_VIRTUAL_KEYBOARD_BROWSERTEST_H_