OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2014 The Chromium Authors. All rights reserved. | |
3 * Use of this source code is governed by a BSD-style license that can be | |
4 * found in the LICENSE file. | |
5 */ | |
6 | |
7 #include "ash/shell.h" | |
8 #include "chrome/browser/chromeos/extensions/virtual_keyboard_browsertest.h" | |
9 #include "chrome/browser/extensions/crx_installer.h" | |
10 #include "chrome/browser/extensions/extension_service.h" | |
11 #include "chrome/browser/extensions/extension_test_notification_observer.h" | |
12 #include "chrome/browser/profiles/profile.h" | |
13 #include "chrome/browser/ui/browser.h" | |
14 #include "chrome/test/base/ui_test_utils.h" | |
15 #include "chromeos/ime/extension_ime_util.h" | |
16 #include "chromeos/ime/input_method_manager.h" | |
17 #include "content/public/browser/render_view_host.h" | |
18 #include "content/public/browser/site_instance.h" | |
19 #include "content/public/browser/web_contents.h" | |
20 #include "content/public/test/browser_test_utils.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/input_method.h" | |
26 | |
27 namespace { | |
28 | |
29 const base::FilePath kBaseKeyboardTestFramework = | |
30 base::FilePath(FILE_PATH_LITERAL("test_base.js")); | |
31 | |
32 const base::FilePath kExtensionName = | |
33 base::FilePath(FILE_PATH_LITERAL("GoogleKeyboardInput-xkb.crx")); | |
34 | |
35 const base::FilePath kInputViewTestDir = | |
36 base::FilePath(FILE_PATH_LITERAL("chromeos/virtual_keyboard/inputview/")); | |
kevers
2014/04/23 13:39:05
Nit: insert blank line before closing brace for na
rsadam
2014/04/23 14:28:53
Done.
| |
37 } // namespace | |
38 | |
39 class InputViewBrowserTest : public VirtualKeyboardBrowserTest { | |
40 public: | |
41 virtual base::FilePath GetTestDir() OVERRIDE { return kInputViewTestDir; } | |
42 | |
43 virtual base::FilePath GetBaseFrameWork() OVERRIDE { | |
44 return kBaseKeyboardTestFramework; | |
45 } | |
46 | |
47 // Installs the IME Extension keyboard |kExtensionName|. | |
48 void InstallIMEExtension() { | |
49 // Loads extension. | |
50 ExtensionService* service = browser()->profile()->GetExtensionService(); | |
51 scoped_refptr<extensions::CrxInstaller> installer = | |
52 extensions::CrxInstaller::CreateSilent(service); | |
53 base::FilePath path = | |
54 ui_test_utils::GetTestFilePath(kInputViewTestDir, kExtensionName); | |
55 ExtensionTestNotificationObserver observer(browser()); | |
56 observer.Watch(chrome::NOTIFICATION_CRX_INSTALLER_DONE, | |
57 content::Source<extensions::CrxInstaller>(installer.get())); | |
58 installer->set_allow_silent_install(true); | |
59 installer->set_creation_flags(extensions::Extension::FROM_WEBSTORE); | |
60 installer->InstallCrx(path); | |
61 // Wait for CRX to be installed. | |
62 observer.Wait(); | |
63 extensionId_ = installer->extension()->id(); | |
64 ASSERT_TRUE(service->GetExtensionById(extensionId_, false)); | |
65 | |
66 // Register extension with IME. | |
67 chromeos::input_method::InputMethodManager* ime = | |
68 chromeos::input_method::InputMethodManager::Get(); | |
69 ASSERT_TRUE(ime); | |
70 std::string id = chromeos::extension_ime_util::GetComponentInputMethodID( | |
71 extensionId_, "xkb:us::eng"); | |
72 ime->ChangeInputMethod(id); | |
73 LOG(ERROR) << "Changed input method!"; | |
74 } | |
75 | |
76 virtual GURL GetURL() OVERRIDE { | |
77 return GURL("chrome-extension://" + GetKeyboardExtensionId() + | |
78 "/inputview.html"); | |
79 } | |
80 | |
81 virtual std::string GetKeyboardExtensionId() OVERRIDE { return extensionId_; } | |
82 | |
83 private: | |
84 std::string extensionId_; | |
85 }; | |
86 | |
87 IN_PROC_BROWSER_TEST_F(InputViewBrowserTest, TypingTestTest) { | |
88 InstallIMEExtension(); | |
89 RunTest(base::FilePath(FILE_PATH_LITERAL("typing_test.js"))); | |
90 } | |
OLD | NEW |