Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2014 The Chromium Authors. All rights reserved. | |
|
Jeffrey Yasskin
2014/04/28 23:14:50
http://www.chromium.org/developers/coding-style sa
rsadam
2014/04/30 17:26:11
Done.
| |
| 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 = | |
|
Jeffrey Yasskin
2014/04/28 23:14:50
The style guide discourages global/static objects
rsadam
2014/04/30 17:26:11
Done.
| |
| 30 base::FilePath(FILE_PATH_LITERAL("test_base.js")); | |
| 31 | |
| 32 const base::FilePath kExtensionName = | |
| 33 base::FilePath(FILE_PATH_LITERAL("GoogleKeyboardInput-xkb.crx")); | |
|
Jeffrey Yasskin
2014/04/28 23:14:50
It's not great to check in the built .crx. Is its
rsadam
2014/04/29 23:10:12
The keyboard's language model is not open source a
Jeffrey Yasskin
2014/05/02 22:09:36
Ok.
| |
| 34 | |
| 35 const base::FilePath kInputViewTestDir = | |
| 36 base::FilePath(FILE_PATH_LITERAL("chromeos/virtual_keyboard/inputview/")); | |
| 37 | |
| 38 } // namespace | |
| 39 | |
| 40 class InputViewBrowserTest : public VirtualKeyboardBrowserTest { | |
| 41 public: | |
| 42 virtual base::FilePath GetTestDir() OVERRIDE { return kInputViewTestDir; } | |
| 43 | |
| 44 virtual base::FilePath GetBaseFrameWork() OVERRIDE { | |
| 45 return kBaseKeyboardTestFramework; | |
| 46 } | |
| 47 | |
| 48 // Installs the IME Extension keyboard |kExtensionName|. | |
| 49 void InstallIMEExtension() { | |
| 50 // Loads extension. | |
| 51 ExtensionService* service = browser()->profile()->GetExtensionService(); | |
| 52 scoped_refptr<extensions::CrxInstaller> installer = | |
| 53 extensions::CrxInstaller::CreateSilent(service); | |
|
Jeffrey Yasskin
2014/04/28 23:14:50
It'd be nice to share the common code here with ht
rsadam
2014/04/29 23:10:12
The ExtensionBrowserTest doesn't seem to support t
Jeffrey Yasskin
2014/05/02 22:09:36
You'd have to refactor it into a free function any
| |
| 54 base::FilePath path = | |
| 55 ui_test_utils::GetTestFilePath(kInputViewTestDir, kExtensionName); | |
| 56 ExtensionTestNotificationObserver observer(browser()); | |
| 57 observer.Watch(chrome::NOTIFICATION_CRX_INSTALLER_DONE, | |
| 58 content::Source<extensions::CrxInstaller>(installer.get())); | |
| 59 installer->set_allow_silent_install(true); | |
| 60 installer->set_creation_flags(extensions::Extension::FROM_WEBSTORE); | |
| 61 installer->InstallCrx(path); | |
| 62 // Wait for CRX to be installed. | |
| 63 observer.Wait(); | |
| 64 extensionId_ = installer->extension()->id(); | |
| 65 ASSERT_TRUE(service->GetExtensionById(extensionId_, false)); | |
| 66 | |
| 67 // Register extension with IME. | |
| 68 chromeos::input_method::InputMethodManager* ime = | |
| 69 chromeos::input_method::InputMethodManager::Get(); | |
| 70 ASSERT_TRUE(ime); | |
| 71 std::string id = chromeos::extension_ime_util::GetComponentInputMethodID( | |
| 72 extensionId_, "xkb:us::eng"); | |
| 73 ime->ChangeInputMethod(id); | |
| 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, TypingTest) { | |
| 88 InstallIMEExtension(); | |
| 89 RunTest(base::FilePath(FILE_PATH_LITERAL("typing_test.js"))); | |
|
Jeffrey Yasskin
2014/04/28 23:14:50
It would likely be easier to read this test if the
rsadam
2014/04/29 23:10:12
I have several follow patches that is likely to ma
Jeffrey Yasskin
2014/05/02 22:09:36
Hm, ok. I guess the startup overhead of a browser
| |
| 90 } | |
| OLD | NEW |