ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chrome / browser / chromeos / extensions / input_view_browsertest.cc
blob8fc4b38e6c19298e95057b589b506274c0709723
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 #include "ash/shell.h"
6 #include "base/files/file_path.h"
7 #include "chrome/browser/chromeos/extensions/virtual_keyboard_browsertest.h"
8 #include "chrome/browser/extensions/crx_installer.h"
9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_test_notification_observer.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/test/base/ui_test_utils.h"
14 #include "content/public/browser/render_view_host.h"
15 #include "content/public/browser/site_instance.h"
16 #include "content/public/browser/web_contents.h"
17 #include "content/public/common/url_constants.h"
18 #include "content/public/test/browser_test_utils.h"
19 #include "extensions/browser/extension_system.h"
20 #include "extensions/browser/notification_types.h"
21 #include "extensions/common/constants.h"
22 #include "extensions/common/extension.h"
23 #include "extensions/common/file_util.h"
24 #include "ui/aura/client/aura_constants.h"
25 #include "ui/base/ime/chromeos/extension_ime_util.h"
26 #include "ui/base/ime/chromeos/input_method_manager.h"
27 #include "ui/base/ime/input_method.h"
29 namespace {
31 const base::FilePath::CharType kExtensionName[] = "GoogleKeyboardInput-xkb.crx";
33 const base::FilePath::CharType kInputViewTestDir[] =
34 "chromeos/virtual_keyboard/inputview/";
35 const base::FilePath::CharType kBaseKeyboardTestFramework[] = "test_base.js";
37 const char kDefaultLayout[] = "us";
38 const char kCompactLayout[] = "us.compact.qwerty";
40 struct InputViewConfig : public VirtualKeyboardBrowserTestConfig {
41 explicit InputViewConfig(std::string id, std::string layout) {
42 base_framework_ = kBaseKeyboardTestFramework;
43 extension_id_ = id;
44 test_dir_ = kInputViewTestDir;
45 url_ = std::string(extensions::kExtensionScheme) +
46 url::kStandardSchemeSeparator + id + "/inputview.html?id=" +
47 layout;
51 } // namespace
53 class InputViewBrowserTest : public VirtualKeyboardBrowserTest {
54 public:
55 // Installs the IME Extension keyboard |kExtensionName|.
56 std::string InstallIMEExtension() {
57 // Loads extension.
58 base::FilePath path = ui_test_utils::GetTestFilePath(
59 base::FilePath(kInputViewTestDir), base::FilePath(kExtensionName));
60 ExtensionService* service = extensions::ExtensionSystem::Get(
61 browser()->profile())->extension_service();
62 scoped_refptr<extensions::CrxInstaller> installer =
63 extensions::CrxInstaller::CreateSilent(service);
65 ExtensionTestNotificationObserver observer(browser());
66 observer.Watch(extensions::NOTIFICATION_CRX_INSTALLER_DONE,
67 content::Source<extensions::CrxInstaller>(installer.get()));
68 installer->set_allow_silent_install(true);
69 installer->set_creation_flags(extensions::Extension::FROM_WEBSTORE);
70 installer->InstallCrx(path);
71 // Wait for CRX to be installed.
72 observer.Wait();
73 std::string extensionId = installer->extension()->id();
74 if (!service->GetExtensionById(extensionId, false))
75 return "";
76 return extensionId;
80 // Disabled for flaking. See crbug.com/459420.
81 IN_PROC_BROWSER_TEST_F(InputViewBrowserTest, DISABLED_TypingTest) {
82 std::string id = InstallIMEExtension();
83 ASSERT_FALSE(id.empty());
84 RunTest(base::FilePath("typing_test.js"),
85 InputViewConfig(id, kDefaultLayout));
88 // Disabled for flaking. See crbug.com/459420.
89 IN_PROC_BROWSER_TEST_F(InputViewBrowserTest, DISABLED_CompactTypingTest) {
90 std::string id = InstallIMEExtension();
91 ASSERT_FALSE(id.empty());
92 RunTest(base::FilePath("typing_test.js"),
93 InputViewConfig(id, kCompactLayout));
96 // Disabled for flaking. See crbug.com/459420.
97 IN_PROC_BROWSER_TEST_F(InputViewBrowserTest, DISABLED_CompactLongpressTest) {
98 std::string id = InstallIMEExtension();
99 ASSERT_FALSE(id.empty());
100 RunTest(base::FilePath("longpress_test.js"),
101 InputViewConfig(id, kCompactLayout));
104 // Disabled for leaking memory: http://crbug.com/380537
105 IN_PROC_BROWSER_TEST_F(InputViewBrowserTest, DISABLED_KeysetTransitionTest) {
106 std::string id = InstallIMEExtension();
107 ASSERT_FALSE(id.empty());
108 RunTest(base::FilePath("keyset_transition_test.js"),
109 InputViewConfig(id, kDefaultLayout));
112 // Disabled for leaking memory: http://crbug.com/380537
113 IN_PROC_BROWSER_TEST_F(InputViewBrowserTest,
114 DISABLED_CompactKeysetTransitionTest) {
115 std::string id = InstallIMEExtension();
116 ASSERT_FALSE(id.empty());
117 RunTest(base::FilePath("keyset_transition_test.js"),
118 InputViewConfig(id, kCompactLayout));