Chromium Code Reviews| Index: chrome/browser/chromeos/extensions/input_view_browsertest.cc |
| diff --git a/chrome/browser/chromeos/extensions/input_view_browsertest.cc b/chrome/browser/chromeos/extensions/input_view_browsertest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5ad5542c5356952cecf25c374b257a4035580f1b |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/extensions/input_view_browsertest.cc |
| @@ -0,0 +1,90 @@ |
| +/* |
| + * 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.
|
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#include "ash/shell.h" |
| +#include "chrome/browser/chromeos/extensions/virtual_keyboard_browsertest.h" |
| +#include "chrome/browser/extensions/crx_installer.h" |
| +#include "chrome/browser/extensions/extension_service.h" |
| +#include "chrome/browser/extensions/extension_test_notification_observer.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/ui/browser.h" |
| +#include "chrome/test/base/ui_test_utils.h" |
| +#include "chromeos/ime/extension_ime_util.h" |
| +#include "chromeos/ime/input_method_manager.h" |
| +#include "content/public/browser/render_view_host.h" |
| +#include "content/public/browser/site_instance.h" |
| +#include "content/public/browser/web_contents.h" |
| +#include "content/public/test/browser_test_utils.h" |
| +#include "extensions/common/constants.h" |
| +#include "extensions/common/extension.h" |
| +#include "extensions/common/file_util.h" |
| +#include "ui/aura/client/aura_constants.h" |
| +#include "ui/base/ime/input_method.h" |
| + |
| +namespace { |
| + |
| +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.
|
| + base::FilePath(FILE_PATH_LITERAL("test_base.js")); |
| + |
| +const base::FilePath kExtensionName = |
| + 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.
|
| + |
| +const base::FilePath kInputViewTestDir = |
| + base::FilePath(FILE_PATH_LITERAL("chromeos/virtual_keyboard/inputview/")); |
| + |
| +} // namespace |
| + |
| +class InputViewBrowserTest : public VirtualKeyboardBrowserTest { |
| + public: |
| + virtual base::FilePath GetTestDir() OVERRIDE { return kInputViewTestDir; } |
| + |
| + virtual base::FilePath GetBaseFrameWork() OVERRIDE { |
| + return kBaseKeyboardTestFramework; |
| + } |
| + |
| + // Installs the IME Extension keyboard |kExtensionName|. |
| + void InstallIMEExtension() { |
| + // Loads extension. |
| + ExtensionService* service = browser()->profile()->GetExtensionService(); |
| + scoped_refptr<extensions::CrxInstaller> installer = |
| + 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
|
| + base::FilePath path = |
| + ui_test_utils::GetTestFilePath(kInputViewTestDir, kExtensionName); |
| + ExtensionTestNotificationObserver observer(browser()); |
| + observer.Watch(chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
| + content::Source<extensions::CrxInstaller>(installer.get())); |
| + installer->set_allow_silent_install(true); |
| + installer->set_creation_flags(extensions::Extension::FROM_WEBSTORE); |
| + installer->InstallCrx(path); |
| + // Wait for CRX to be installed. |
| + observer.Wait(); |
| + extensionId_ = installer->extension()->id(); |
| + ASSERT_TRUE(service->GetExtensionById(extensionId_, false)); |
| + |
| + // Register extension with IME. |
| + chromeos::input_method::InputMethodManager* ime = |
| + chromeos::input_method::InputMethodManager::Get(); |
| + ASSERT_TRUE(ime); |
| + std::string id = chromeos::extension_ime_util::GetComponentInputMethodID( |
| + extensionId_, "xkb:us::eng"); |
| + ime->ChangeInputMethod(id); |
| + } |
| + |
| + virtual GURL GetURL() OVERRIDE { |
| + return GURL("chrome-extension://" + GetKeyboardExtensionId() + |
| + "/inputview.html"); |
| + } |
| + |
| + virtual std::string GetKeyboardExtensionId() OVERRIDE { return extensionId_; } |
| + |
| + private: |
| + std::string extensionId_; |
| +}; |
| + |
| +IN_PROC_BROWSER_TEST_F(InputViewBrowserTest, TypingTest) { |
| + InstallIMEExtension(); |
| + 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
|
| +} |