Chromium Code Reviews| 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/input_method_manager.h" | |
| 16 #include "content/public/browser/render_view_host.h" | |
| 17 #include "content/public/browser/site_instance.h" | |
| 18 #include "content/public/browser/web_contents.h" | |
| 19 #include "content/public/test/browser_test_utils.h" | |
| 20 #include "extensions/common/constants.h" | |
| 21 #include "extensions/common/extension.h" | |
| 22 #include "extensions/common/file_util.h" | |
| 23 #include "ui/aura/client/aura_constants.h" | |
| 24 #include "ui/base/ime/input_method.h" | |
| 25 | |
| 26 namespace { | |
| 27 | |
| 28 const base::FilePath kBaseKeyboardTestFramework = | |
| 29 base::FilePath(FILE_PATH_LITERAL("test_base.js")); | |
| 30 | |
| 31 const base::FilePath kExtensionName = | |
| 32 base::FilePath(FILE_PATH_LITERAL("GoogleKeyboardInput-xkb.crx")); | |
| 33 | |
| 34 const base::FilePath kInputViewTestDir = | |
| 35 base::FilePath(FILE_PATH_LITERAL("chromeos/virtual_keyboard/inputview/")); | |
| 36 } // namespace | |
| 37 | |
| 38 class InputViewBrowserTest : public VirtualKeyboardBrowserTest { | |
| 39 public: | |
| 40 virtual base::FilePath GetTestDir() OVERRIDE { return kInputViewTestDir; } | |
| 41 | |
| 42 virtual base::FilePath GetBaseFrameWork() OVERRIDE { | |
| 43 return kBaseKeyboardTestFramework; | |
| 44 } | |
| 45 | |
| 46 // Installs the IME Extension keyboard |kExtensionName|. | |
| 47 void InstallIMEExtension() { | |
| 48 // Loads extension. | |
| 49 ExtensionService* service = browser()->profile()->GetExtensionService(); | |
| 50 scoped_refptr<extensions::CrxInstaller> installer = | |
| 51 extensions::CrxInstaller::CreateSilent(service); | |
| 52 base::FilePath path = | |
| 53 ui_test_utils::GetTestFilePath(kInputViewTestDir, kExtensionName); | |
| 54 ExtensionTestNotificationObserver observer(browser()); | |
| 55 observer.Watch(chrome::NOTIFICATION_CRX_INSTALLER_DONE, | |
| 56 content::Source<extensions::CrxInstaller>(installer.get())); | |
| 57 installer->set_allow_silent_install(true); | |
| 58 installer->set_creation_flags(extensions::Extension::FROM_WEBSTORE); | |
| 59 installer->InstallCrx(path); | |
| 60 // Wait for CRX to be installed. | |
| 61 observer.Wait(); | |
| 62 extensionId_ = installer->extension()->id(); | |
| 63 ASSERT_TRUE(service->GetExtensionById(extensionId_, false)); | |
| 64 | |
| 65 // Register extension with IME. | |
| 66 chromeos::input_method::InputMethodManager* ime = | |
| 67 chromeos::input_method::InputMethodManager::Get(); | |
| 68 ASSERT_TRUE(ime); | |
| 69 ime->ChangeInputMethod("_comp_ime_" + extensionId_ + "xkb:us::eng"); | |
|
Shu Chen
2014/04/22 19:14:43
I think you can do this here to get the input meth
rsadam
2014/04/22 20:28:20
Done.
| |
| 70 LOG(ERROR) << "Changed input method!"; | |
| 71 } | |
| 72 | |
| 73 virtual GURL GetURL() OVERRIDE { | |
| 74 return GURL("chrome-extension://" + GetKeyboardExtensionId() + | |
| 75 "/inputview.html"); | |
| 76 } | |
| 77 | |
| 78 virtual std::string GetKeyboardExtensionId() OVERRIDE { return extensionId_; } | |
| 79 | |
| 80 private: | |
| 81 std::string extensionId_; | |
| 82 }; | |
| 83 | |
| 84 IN_PROC_BROWSER_TEST_F(InputViewBrowserTest, TypingTestTest) { | |
| 85 InstallIMEExtension(); | |
| 86 RunTest(base::FilePath(FILE_PATH_LITERAL("typing_test.js"))); | |
| 87 } | |
| OLD | NEW |