Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 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 "chromeos/ime/extension_ime_util.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::CharType kExtensionName[] = | |
| 29 FILE_PATH_LITERAL("GoogleKeyboardInput-xkb.crx"); | |
| 30 | |
| 31 const std::string kInputViewTestDir = "chromeos/virtual_keyboard/inputview/"; | |
|
Jeffrey Yasskin
2014/05/02 22:09:37
std::string is also an object with a non-trivial c
rsadam
2014/05/05 17:44:42
Done.
| |
| 32 const std::string kBaseKeyboardTestFramework = "test_base.js"; | |
| 33 | |
| 34 class InputViewHelper : public VirtualKeyboardBrowserTestHelper { | |
| 35 public: | |
| 36 explicit InputViewHelper(std::string id) { | |
| 37 set_base_framework(kBaseKeyboardTestFramework); | |
| 38 set_extension_id(id); | |
| 39 set_test_dir(kInputViewTestDir); | |
| 40 set_url("chrome-extension://" + id + "/inputview.html?id=us-altgr-intl"); | |
| 41 } | |
| 42 }; | |
| 43 | |
| 44 } // namespace | |
| 45 | |
| 46 class InputViewBrowserTest : public VirtualKeyboardBrowserTest { | |
| 47 public: | |
| 48 // Installs the IME Extension keyboard |kExtensionName|. | |
| 49 std::string InstallIMEExtension() { | |
| 50 // Loads extension. | |
| 51 base::FilePath path = ui_test_utils::GetTestFilePath( | |
| 52 base::FilePath(FILE_PATH_LITERAL(kInputViewTestDir)), | |
|
Jeffrey Yasskin
2014/05/02 22:09:37
This won't compile on windows.
rsadam
2014/05/05 17:44:42
These tests are chromeos only so I don't think tha
Jeffrey Yasskin
2014/05/08 00:04:16
You should probably do these the same way you did
| |
| 53 base::FilePath(FILE_PATH_LITERAL(kExtensionName))); | |
| 54 ExtensionService* service = browser()->profile()->GetExtensionService(); | |
| 55 scoped_refptr<extensions::CrxInstaller> installer = | |
| 56 extensions::CrxInstaller::CreateSilent(service); | |
| 57 | |
| 58 ExtensionTestNotificationObserver observer(browser()); | |
| 59 observer.Watch(chrome::NOTIFICATION_CRX_INSTALLER_DONE, | |
| 60 content::Source<extensions::CrxInstaller>(installer.get())); | |
| 61 installer->set_allow_silent_install(true); | |
| 62 installer->set_creation_flags(extensions::Extension::FROM_WEBSTORE); | |
| 63 installer->InstallCrx(path); | |
| 64 // Wait for CRX to be installed. | |
| 65 observer.Wait(); | |
| 66 std::string extensionId = installer->extension()->id(); | |
| 67 if (!service->GetExtensionById(extensionId, false)) | |
| 68 return ""; | |
| 69 | |
| 70 // Register extension with IME. | |
| 71 chromeos::input_method::InputMethodManager* ime = | |
| 72 chromeos::input_method::InputMethodManager::Get(); | |
| 73 std::string id = chromeos::extension_ime_util::GetComponentInputMethodID( | |
| 74 extensionId, "xkb:us::eng"); | |
| 75 ime->ChangeInputMethod(id); | |
| 76 return extensionId; | |
| 77 } | |
| 78 }; | |
| 79 | |
| 80 IN_PROC_BROWSER_TEST_F(InputViewBrowserTest, TypingTest) { | |
| 81 std::string id = InstallIMEExtension(); | |
| 82 ASSERT_FALSE(id.empty()); | |
| 83 RunTest(base::FilePath(FILE_PATH_LITERAL("typing_test.js")), | |
| 84 InputViewHelper(id)); | |
| 85 } | |
| OLD | NEW |