| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/shell.h" | 5 #include "ash/shell.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "chrome/browser/chromeos/extensions/virtual_keyboard_browsertest.h" | 7 #include "chrome/browser/chromeos/extensions/virtual_keyboard_browsertest.h" |
| 8 #include "chrome/browser/extensions/crx_installer.h" | 8 #include "chrome/browser/extensions/crx_installer.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_test_notification_observer.h" | 10 #include "chrome/browser/extensions/extension_test_notification_observer.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 const base::FilePath::CharType kExtensionName[] = "GoogleKeyboardInput-xkb.crx"; | 28 const base::FilePath::CharType kExtensionName[] = "GoogleKeyboardInput-xkb.crx"; |
| 29 | 29 |
| 30 const base::FilePath::CharType kInputViewTestDir[] = | 30 const base::FilePath::CharType kInputViewTestDir[] = |
| 31 "chromeos/virtual_keyboard/inputview/"; | 31 "chromeos/virtual_keyboard/inputview/"; |
| 32 const base::FilePath::CharType kBaseKeyboardTestFramework[] = "test_base.js"; | 32 const base::FilePath::CharType kBaseKeyboardTestFramework[] = "test_base.js"; |
| 33 | 33 |
| 34 const char kDefaultLayout[] = "us"; | 34 const char kDefaultLayout[] = "us"; |
| 35 const char kCompactLayout[] = "us.compact"; | 35 const char kCompactLayout[] = "us.compact.qwerty"; |
| 36 | 36 |
| 37 struct InputViewConfig : public VirtualKeyboardBrowserTestConfig { | 37 struct InputViewConfig : public VirtualKeyboardBrowserTestConfig { |
| 38 explicit InputViewConfig(std::string id, std::string layout) { | 38 explicit InputViewConfig(std::string id, std::string layout) { |
| 39 base_framework_ = kBaseKeyboardTestFramework; | 39 base_framework_ = kBaseKeyboardTestFramework; |
| 40 extension_id_ = id; | 40 extension_id_ = id; |
| 41 test_dir_ = kInputViewTestDir; | 41 test_dir_ = kInputViewTestDir; |
| 42 url_ = "chrome-extension://" + id + "/inputview.html?id=" + layout; | 42 url_ = "chrome-extension://" + id + "/inputview.html?id=" + layout; |
| 43 } | 43 } |
| 44 }; | 44 }; |
| 45 | 45 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 60 observer.Watch(chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 60 observer.Watch(chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
| 61 content::Source<extensions::CrxInstaller>(installer.get())); | 61 content::Source<extensions::CrxInstaller>(installer.get())); |
| 62 installer->set_allow_silent_install(true); | 62 installer->set_allow_silent_install(true); |
| 63 installer->set_creation_flags(extensions::Extension::FROM_WEBSTORE); | 63 installer->set_creation_flags(extensions::Extension::FROM_WEBSTORE); |
| 64 installer->InstallCrx(path); | 64 installer->InstallCrx(path); |
| 65 // Wait for CRX to be installed. | 65 // Wait for CRX to be installed. |
| 66 observer.Wait(); | 66 observer.Wait(); |
| 67 std::string extensionId = installer->extension()->id(); | 67 std::string extensionId = installer->extension()->id(); |
| 68 if (!service->GetExtensionById(extensionId, false)) | 68 if (!service->GetExtensionById(extensionId, false)) |
| 69 return ""; | 69 return ""; |
| 70 | |
| 71 // Register extension with IME. | |
| 72 chromeos::input_method::InputMethodManager* ime = | |
| 73 chromeos::input_method::InputMethodManager::Get(); | |
| 74 std::string id = chromeos::extension_ime_util::GetComponentInputMethodID( | |
| 75 extensionId, "xkb:us::eng"); | |
| 76 ime->ChangeInputMethod(id); | |
| 77 return extensionId; | 70 return extensionId; |
| 78 } | 71 } |
| 79 }; | 72 }; |
| 80 | 73 |
| 81 IN_PROC_BROWSER_TEST_F(InputViewBrowserTest, TypingTest) { | 74 IN_PROC_BROWSER_TEST_F(InputViewBrowserTest, TypingTest) { |
| 82 std::string id = InstallIMEExtension(); | 75 std::string id = InstallIMEExtension(); |
| 83 ASSERT_FALSE(id.empty()); | 76 ASSERT_FALSE(id.empty()); |
| 84 RunTest(base::FilePath("typing_test.js"), | 77 RunTest(base::FilePath("typing_test.js"), |
| 85 InputViewConfig(id, kDefaultLayout)); | 78 InputViewConfig(id, kDefaultLayout)); |
| 86 } | 79 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 98 RunTest(base::FilePath("keyset_transition_test.js"), | 91 RunTest(base::FilePath("keyset_transition_test.js"), |
| 99 InputViewConfig(id, kDefaultLayout)); | 92 InputViewConfig(id, kDefaultLayout)); |
| 100 } | 93 } |
| 101 | 94 |
| 102 IN_PROC_BROWSER_TEST_F(InputViewBrowserTest, CompactKeysetTransitionTest) { | 95 IN_PROC_BROWSER_TEST_F(InputViewBrowserTest, CompactKeysetTransitionTest) { |
| 103 std::string id = InstallIMEExtension(); | 96 std::string id = InstallIMEExtension(); |
| 104 ASSERT_FALSE(id.empty()); | 97 ASSERT_FALSE(id.empty()); |
| 105 RunTest(base::FilePath("keyset_transition_test.js"), | 98 RunTest(base::FilePath("keyset_transition_test.js"), |
| 106 InputViewConfig(id, kCompactLayout)); | 99 InputViewConfig(id, kCompactLayout)); |
| 107 } | 100 } |
| OLD | NEW |