Commit 4c097c39 authored by Ahmed Fakhry's avatar Ahmed Fakhry Committed by Commit Bot

Hide option to remap internal search when no internal KB is connected

To avoid confusion when there is no internal keyboard connected:
- We should not show the option to remap the internal "Search"
key since that key doesn't exist.
- We should also avoid labeling the options to remap the external
meta keys as "External Meta" or "External Command", and just say
"Meta" or "Command" as "External" here is redundant.

BUG=890522, 890950
TEST=Expanded existing tests.

Change-Id: If979b80217298a5f6bb18be478aa2c457859a351
Reviewed-on: https://chromium-review.googlesource.com/c/1253022Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599409}
parent 3561c3c6
...@@ -3916,9 +3916,15 @@ ...@@ -3916,9 +3916,15 @@
<message name="IDS_SETTINGS_KEYBOARD_KEY_EXTERNAL_COMMAND" desc="In Device Settings, the dropdown list item for the external Command key on Apple keyboards."> <message name="IDS_SETTINGS_KEYBOARD_KEY_EXTERNAL_COMMAND" desc="In Device Settings, the dropdown list item for the external Command key on Apple keyboards.">
External Command External Command
</message> </message>
<message name="IDS_SETTINGS_KEYBOARD_KEY_COMMAND" desc="In Device Settings, the dropdown list item for the external Command key on Apple keyboards when there's no internal keyboard on the device.">
Command
</message>
<message name="IDS_SETTINGS_KEYBOARD_KEY_EXTERNAL_META" desc="In Device Settings, the dropdown list item for the external Meta key (Search key on ChromeOS keyboards, and Windows key on Windows keyboards)."> <message name="IDS_SETTINGS_KEYBOARD_KEY_EXTERNAL_META" desc="In Device Settings, the dropdown list item for the external Meta key (Search key on ChromeOS keyboards, and Windows key on Windows keyboards).">
External Meta External Meta
</message> </message>
<message name="IDS_SETTINGS_KEYBOARD_KEY_META" desc="In Device Settings, the dropdown list item for the external Meta key (Search key on ChromeOS keyboards, and Windows key on Windows keyboards) when there's no internal keyboard on the device.">
Meta
</message>
<message name="IDS_SETTINGS_KEYBOARD_SEND_FUNCTION_KEYS" desc="In Device Settings, the checkbox label for interpreting the top-row keys as function keys instead."> <message name="IDS_SETTINGS_KEYBOARD_SEND_FUNCTION_KEYS" desc="In Device Settings, the checkbox label for interpreting the top-row keys as function keys instead.">
Treat top-row keys as function keys Treat top-row keys as function keys
</message> </message>
......
...@@ -13,13 +13,15 @@ ...@@ -13,13 +13,15 @@
<dom-module id="settings-keyboard"> <dom-module id="settings-keyboard">
<template> <template>
<style include="settings-shared"></style> <style include="settings-shared"></style>
<div class="settings-box first"> <template is="dom-if" if="[[hasInternalKeyboard_]]">
<div class="start">$i18n{keyboardKeySearch}</div> <div class="settings-box first" id="internalSearchKey">
<settings-dropdown-menu label="$i18n{keyboardKeySearch}" <div class="start">$i18n{keyboardKeySearch}</div>
pref="{{prefs.settings.language.xkb_remap_search_key_to}}" <settings-dropdown-menu label="$i18n{keyboardKeySearch}"
menu-options="[[keyMapTargets_]]"> pref="{{prefs.settings.language.xkb_remap_search_key_to}}"
</settings-dropdown-menu> menu-options="[[keyMapTargets_]]">
</div> </settings-dropdown-menu>
</div>
</template>
<div class="settings-box"> <div class="settings-box">
<div class="start">$i18n{keyboardKeyCtrl}</div> <div class="start">$i18n{keyboardKeyCtrl}</div>
<settings-dropdown-menu label="$i18n{keyboardKeyCtrl}" <settings-dropdown-menu label="$i18n{keyboardKeyCtrl}"
...@@ -68,8 +70,11 @@ ...@@ -68,8 +70,11 @@
</template> </template>
<template is="dom-if" if="[[showExternalMetaKey_]]"> <template is="dom-if" if="[[showExternalMetaKey_]]">
<div class="settings-box" id="externalMetaKey"> <div class="settings-box" id="externalMetaKey">
<div class="start">$i18n{keyboardKeyExternalMeta}</div> <div class="start">
<settings-dropdown-menu label="$i18n{keyboardKeyExternalMeta}" [[getExternalMetaKeyLabel_(hasInternalKeyboard_)]]
</div>
<settings-dropdown-menu
label="[[getExternalMetaKeyLabel_(hasInternalKeyboard_)]]"
pref="{{prefs.settings.language.remap_external_meta_key_to}}" pref="{{prefs.settings.language.remap_external_meta_key_to}}"
menu-options="[[keyMapTargets_]]"> menu-options="[[keyMapTargets_]]">
</settings-dropdown-menu> </settings-dropdown-menu>
...@@ -77,9 +82,11 @@ ...@@ -77,9 +82,11 @@
</template> </template>
<template is="dom-if" if="[[showAppleCommandKey_]]"> <template is="dom-if" if="[[showAppleCommandKey_]]">
<div class="settings-box" id="externalCommandKey"> <div class="settings-box" id="externalCommandKey">
<div class="start">$i18n{keyboardKeyExternalCommand}</div> <div class="start">
[[getExternalCommandKeyLabel_(hasInternalKeyboard_)]]
</div>
<settings-dropdown-menu <settings-dropdown-menu
label="$i18n{keyboardKeyExternalCommand}" label="[[getExternalCommandKeyLabel_(hasInternalKeyboard_)]]"
pref="{{prefs.settings.language.remap_external_command_key_to}}" pref="{{prefs.settings.language.remap_external_command_key_to}}"
menu-options="[[keyMapTargets_]]"> menu-options="[[keyMapTargets_]]">
</settings-dropdown-menu> </settings-dropdown-menu>
......
...@@ -39,6 +39,9 @@ Polymer({ ...@@ -39,6 +39,9 @@ Polymer({
/** @private Whether to show diamond key options. */ /** @private Whether to show diamond key options. */
showDiamondKey_: Boolean, showDiamondKey_: Boolean,
/** @private Whether this device has an internal keyboard. */
hasInternalKeyboard_: Boolean,
/** /**
* Whether to show a remapping option for external keyboard's Meta key * Whether to show a remapping option for external keyboard's Meta key
* (Search/Windows keys). This is true only when there's an external * (Search/Windows keys). This is true only when there's an external
...@@ -133,6 +136,7 @@ Polymer({ ...@@ -133,6 +136,7 @@ Polymer({
* @private * @private
*/ */
onShowKeysChange_: function(keyboardParams) { onShowKeysChange_: function(keyboardParams) {
this.hasInternalKeyboard_ = keyboardParams['hasInternalKeyboard'];
this.showCapsLock_ = keyboardParams['showCapsLock']; this.showCapsLock_ = keyboardParams['showCapsLock'];
this.showDiamondKey_ = keyboardParams['showDiamondKey']; this.showDiamondKey_ = keyboardParams['showDiamondKey'];
this.showExternalMetaKey_ = keyboardParams['showExternalMetaKey']; this.showExternalMetaKey_ = keyboardParams['showExternalMetaKey'];
...@@ -147,4 +151,15 @@ Polymer({ ...@@ -147,4 +151,15 @@ Polymer({
onShowLanguageInputTap_: function() { onShowLanguageInputTap_: function() {
settings.navigateTo(settings.routes.LANGUAGES); settings.navigateTo(settings.routes.LANGUAGES);
}, },
getExternalMetaKeyLabel_: function(hasInternalKeyboard) {
return loadTimeData.getString(
hasInternalKeyboard ? 'keyboardKeyExternalMeta' : 'keyboardKeyMeta');
},
getExternalCommandKeyLabel_: function(hasInternalKeyboard) {
return loadTimeData.getString(
hasInternalKeyboard ? 'keyboardKeyExternalCommand' :
'keyboardKeyCommand');
},
}); });
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
namespace { namespace {
struct KeyboardsStateResult { struct KeyboardsStateResult {
bool has_internal_keyboard = false;
bool has_external_non_apple_keyboard = false; bool has_external_non_apple_keyboard = false;
bool has_apple_keyboard = false; bool has_apple_keyboard = false;
}; };
...@@ -28,6 +29,8 @@ KeyboardsStateResult GetKeyboardsState() { ...@@ -28,6 +29,8 @@ KeyboardsStateResult GetKeyboardsState() {
KeyboardsStateResult result; KeyboardsStateResult result;
for (const ui::InputDevice& keyboard : for (const ui::InputDevice& keyboard :
ui::InputDeviceManager::GetInstance()->GetKeyboardDevices()) { ui::InputDeviceManager::GetInstance()->GetKeyboardDevices()) {
result.has_internal_keyboard = (keyboard.type == ui::INPUT_DEVICE_INTERNAL);
const ui::EventRewriterChromeOS::DeviceType type = const ui::EventRewriterChromeOS::DeviceType type =
ui::EventRewriterChromeOS::GetDeviceType(keyboard); ui::EventRewriterChromeOS::GetDeviceType(keyboard);
if (type == ui::EventRewriterChromeOS::kDeviceAppleKeyboard) { if (type == ui::EventRewriterChromeOS::kDeviceAppleKeyboard) {
...@@ -146,6 +149,8 @@ void KeyboardHandler::UpdateShowKeys() { ...@@ -146,6 +149,8 @@ void KeyboardHandler::UpdateShowKeys() {
base::Value(keyboards_state.has_external_non_apple_keyboard)); base::Value(keyboards_state.has_external_non_apple_keyboard));
keyboard_params.SetKey("showAppleCommandKey", keyboard_params.SetKey("showAppleCommandKey",
base::Value(keyboards_state.has_apple_keyboard)); base::Value(keyboards_state.has_apple_keyboard));
keyboard_params.SetKey("hasInternalKeyboard",
base::Value(keyboards_state.has_internal_keyboard));
FireWebUIListener(kShowKeysChangedName, keyboard_params); FireWebUIListener(kShowKeysChangedName, keyboard_params);
} }
......
...@@ -47,7 +47,8 @@ class KeyboardHandlerTest : public testing::Test { ...@@ -47,7 +47,8 @@ class KeyboardHandlerTest : public testing::Test {
bool GetLastShowKeysChangedMessage(bool* has_caps_lock_out, bool GetLastShowKeysChangedMessage(bool* has_caps_lock_out,
bool* has_diamond_key_out, bool* has_diamond_key_out,
bool* has_external_meta_key_out, bool* has_external_meta_key_out,
bool* has_apple_command_key_out) bool* has_apple_command_key_out,
bool* has_internal_search_out)
WARN_UNUSED_RESULT { WARN_UNUSED_RESULT {
for (auto it = web_ui_.call_data().rbegin(); for (auto it = web_ui_.call_data().rbegin();
it != web_ui_.call_data().rend(); ++it) { it != web_ui_.call_data().rend(); ++it) {
...@@ -70,6 +71,7 @@ class KeyboardHandlerTest : public testing::Test { ...@@ -70,6 +71,7 @@ class KeyboardHandlerTest : public testing::Test {
{"showDiamondKey", has_diamond_key_out}, {"showDiamondKey", has_diamond_key_out},
{"showExternalMetaKey", has_external_meta_key_out}, {"showExternalMetaKey", has_external_meta_key_out},
{"showAppleCommandKey", has_apple_command_key_out}, {"showAppleCommandKey", has_apple_command_key_out},
{"hasInternalKeyboard", has_internal_search_out},
}; };
for (const auto& pair : path_to_out_param) { for (const auto& pair : path_to_out_param) {
...@@ -92,7 +94,7 @@ class KeyboardHandlerTest : public testing::Test { ...@@ -92,7 +94,7 @@ class KeyboardHandlerTest : public testing::Test {
bool has_caps_lock = false; bool has_caps_lock = false;
bool ignored = false; bool ignored = false;
if (!GetLastShowKeysChangedMessage(&has_caps_lock, &ignored, &ignored, if (!GetLastShowKeysChangedMessage(&has_caps_lock, &ignored, &ignored,
&ignored)) { &ignored, &ignored)) {
ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName; ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName;
return false; return false;
} }
...@@ -106,7 +108,7 @@ class KeyboardHandlerTest : public testing::Test { ...@@ -106,7 +108,7 @@ class KeyboardHandlerTest : public testing::Test {
bool has_diamond_key = false; bool has_diamond_key = false;
bool ignored = false; bool ignored = false;
if (!GetLastShowKeysChangedMessage(&ignored, &has_diamond_key, &ignored, if (!GetLastShowKeysChangedMessage(&ignored, &has_diamond_key, &ignored,
&ignored)) { &ignored, &ignored)) {
ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName; ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName;
return false; return false;
} }
...@@ -120,7 +122,7 @@ class KeyboardHandlerTest : public testing::Test { ...@@ -120,7 +122,7 @@ class KeyboardHandlerTest : public testing::Test {
bool has_external_meta = false; bool has_external_meta = false;
bool ignored = false; bool ignored = false;
if (!GetLastShowKeysChangedMessage(&ignored, &ignored, &has_external_meta, if (!GetLastShowKeysChangedMessage(&ignored, &ignored, &has_external_meta,
&ignored)) { &ignored, &ignored)) {
ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName; ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName;
return false; return false;
} }
...@@ -134,13 +136,27 @@ class KeyboardHandlerTest : public testing::Test { ...@@ -134,13 +136,27 @@ class KeyboardHandlerTest : public testing::Test {
bool has_apple_command_key = false; bool has_apple_command_key = false;
bool ignored = false; bool ignored = false;
if (!GetLastShowKeysChangedMessage(&ignored, &ignored, &ignored, if (!GetLastShowKeysChangedMessage(&ignored, &ignored, &ignored,
&has_apple_command_key)) { &has_apple_command_key, &ignored)) {
ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName; ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName;
return false; return false;
} }
return has_apple_command_key; return has_apple_command_key;
} }
// Returns true if the last keys-changed message reported that the device has
// an internal keyboard and hence an internal Search key remap option.
// A failure is added if a message wasn't found.
bool HasInternalSearchKey() {
bool has_internal_search_key = false;
bool ignored = false;
if (!GetLastShowKeysChangedMessage(&ignored, &ignored, &ignored, &ignored,
&has_internal_search_key)) {
ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName;
return false;
}
return has_internal_search_key;
}
ws::InputDeviceClientTestApi input_device_client_test_api_; ws::InputDeviceClientTestApi input_device_client_test_api_;
content::TestWebUI web_ui_; content::TestWebUI web_ui_;
TestKeyboardHandler handler_; TestKeyboardHandler handler_;
...@@ -154,6 +170,7 @@ TEST_F(KeyboardHandlerTest, DefaultKeys) { ...@@ -154,6 +170,7 @@ TEST_F(KeyboardHandlerTest, DefaultKeys) {
base::CommandLine::ForCurrentProcess()->AppendSwitch( base::CommandLine::ForCurrentProcess()->AppendSwitch(
chromeos::switches::kHasChromeOSKeyboard); chromeos::switches::kHasChromeOSKeyboard);
handler_test_api_.Initialize(); handler_test_api_.Initialize();
EXPECT_FALSE(HasInternalSearchKey());
EXPECT_FALSE(HasCapsLock()); EXPECT_FALSE(HasCapsLock());
EXPECT_FALSE(HasDiamondKey()); EXPECT_FALSE(HasDiamondKey());
EXPECT_FALSE(HasExternalMetaKey()); EXPECT_FALSE(HasExternalMetaKey());
...@@ -164,6 +181,7 @@ TEST_F(KeyboardHandlerTest, NonChromeOSKeyboard) { ...@@ -164,6 +181,7 @@ TEST_F(KeyboardHandlerTest, NonChromeOSKeyboard) {
// If kHasChromeOSKeyboard isn't passed, we should assume there's a Caps Lock // If kHasChromeOSKeyboard isn't passed, we should assume there's a Caps Lock
// key. // key.
handler_test_api_.Initialize(); handler_test_api_.Initialize();
EXPECT_FALSE(HasInternalSearchKey());
EXPECT_TRUE(HasCapsLock()); EXPECT_TRUE(HasCapsLock());
EXPECT_FALSE(HasDiamondKey()); EXPECT_FALSE(HasDiamondKey());
EXPECT_FALSE(HasExternalMetaKey()); EXPECT_FALSE(HasExternalMetaKey());
...@@ -177,6 +195,7 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) { ...@@ -177,6 +195,7 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) {
input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{ input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{
{1, ui::INPUT_DEVICE_INTERNAL, "internal keyboard"}}); {1, ui::INPUT_DEVICE_INTERNAL, "internal keyboard"}});
handler_test_api_.Initialize(); handler_test_api_.Initialize();
EXPECT_TRUE(HasInternalSearchKey());
EXPECT_FALSE(HasCapsLock()); EXPECT_FALSE(HasCapsLock());
EXPECT_FALSE(HasDiamondKey()); EXPECT_FALSE(HasDiamondKey());
EXPECT_FALSE(HasExternalMetaKey()); EXPECT_FALSE(HasExternalMetaKey());
...@@ -186,6 +205,7 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) { ...@@ -186,6 +205,7 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) {
// Caps Lock and Meta keys now. // Caps Lock and Meta keys now.
input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{ input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{
{2, ui::INPUT_DEVICE_USB, "external keyboard"}}); {2, ui::INPUT_DEVICE_USB, "external keyboard"}});
EXPECT_FALSE(HasInternalSearchKey());
EXPECT_TRUE(HasCapsLock()); EXPECT_TRUE(HasCapsLock());
EXPECT_FALSE(HasDiamondKey()); EXPECT_FALSE(HasDiamondKey());
EXPECT_TRUE(HasExternalMetaKey()); EXPECT_TRUE(HasExternalMetaKey());
...@@ -195,6 +215,7 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) { ...@@ -195,6 +215,7 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) {
// the command key. // the command key.
input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{ input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{
{3, ui::INPUT_DEVICE_USB, "Apple Inc. Apple Keyboard"}}); {3, ui::INPUT_DEVICE_USB, "Apple Inc. Apple Keyboard"}});
EXPECT_FALSE(HasInternalSearchKey());
EXPECT_TRUE(HasCapsLock()); EXPECT_TRUE(HasCapsLock());
EXPECT_FALSE(HasDiamondKey()); EXPECT_FALSE(HasDiamondKey());
EXPECT_FALSE(HasExternalMetaKey()); EXPECT_FALSE(HasExternalMetaKey());
...@@ -205,6 +226,7 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) { ...@@ -205,6 +226,7 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) {
input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{ input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{
{2, ui::INPUT_DEVICE_USB, "external keyboard"}, {2, ui::INPUT_DEVICE_USB, "external keyboard"},
{3, ui::INPUT_DEVICE_USB, "Apple Inc. Apple Keyboard"}}); {3, ui::INPUT_DEVICE_USB, "Apple Inc. Apple Keyboard"}});
EXPECT_FALSE(HasInternalSearchKey());
EXPECT_TRUE(HasCapsLock()); EXPECT_TRUE(HasCapsLock());
EXPECT_FALSE(HasDiamondKey()); EXPECT_FALSE(HasDiamondKey());
EXPECT_TRUE(HasExternalMetaKey()); EXPECT_TRUE(HasExternalMetaKey());
...@@ -216,6 +238,7 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) { ...@@ -216,6 +238,7 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) {
// https://crbug.com/834594. // https://crbug.com/834594.
input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{ input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{
{4, ui::INPUT_DEVICE_USB, "Topre Corporation Realforce 87"}}); {4, ui::INPUT_DEVICE_USB, "Topre Corporation Realforce 87"}});
EXPECT_FALSE(HasInternalSearchKey());
EXPECT_TRUE(HasCapsLock()); EXPECT_TRUE(HasCapsLock());
EXPECT_FALSE(HasDiamondKey()); EXPECT_FALSE(HasDiamondKey());
EXPECT_TRUE(HasExternalMetaKey()); EXPECT_TRUE(HasExternalMetaKey());
...@@ -223,6 +246,7 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) { ...@@ -223,6 +246,7 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) {
// Disconnect the external keyboard and check that the key goes away. // Disconnect the external keyboard and check that the key goes away.
input_device_client_test_api_.SetKeyboardDevices({}); input_device_client_test_api_.SetKeyboardDevices({});
EXPECT_FALSE(HasInternalSearchKey());
EXPECT_FALSE(HasCapsLock()); EXPECT_FALSE(HasCapsLock());
EXPECT_FALSE(HasDiamondKey()); EXPECT_FALSE(HasDiamondKey());
EXPECT_FALSE(HasExternalMetaKey()); EXPECT_FALSE(HasExternalMetaKey());
......
...@@ -634,6 +634,7 @@ void AddDeviceStrings(content::WebUIDataSource* html_source) { ...@@ -634,6 +634,7 @@ void AddDeviceStrings(content::WebUIDataSource* html_source) {
{"keyboardKeyCtrl", IDS_SETTINGS_KEYBOARD_KEY_LEFT_CTRL}, {"keyboardKeyCtrl", IDS_SETTINGS_KEYBOARD_KEY_LEFT_CTRL},
{"keyboardKeyAlt", IDS_SETTINGS_KEYBOARD_KEY_LEFT_ALT}, {"keyboardKeyAlt", IDS_SETTINGS_KEYBOARD_KEY_LEFT_ALT},
{"keyboardKeyCapsLock", IDS_SETTINGS_KEYBOARD_KEY_CAPS_LOCK}, {"keyboardKeyCapsLock", IDS_SETTINGS_KEYBOARD_KEY_CAPS_LOCK},
{"keyboardKeyCommand", IDS_SETTINGS_KEYBOARD_KEY_COMMAND},
{"keyboardKeyDiamond", IDS_SETTINGS_KEYBOARD_KEY_DIAMOND}, {"keyboardKeyDiamond", IDS_SETTINGS_KEYBOARD_KEY_DIAMOND},
{"keyboardKeyEscape", IDS_SETTINGS_KEYBOARD_KEY_ESCAPE}, {"keyboardKeyEscape", IDS_SETTINGS_KEYBOARD_KEY_ESCAPE},
{"keyboardKeyBackspace", IDS_SETTINGS_KEYBOARD_KEY_BACKSPACE}, {"keyboardKeyBackspace", IDS_SETTINGS_KEYBOARD_KEY_BACKSPACE},
...@@ -641,6 +642,7 @@ void AddDeviceStrings(content::WebUIDataSource* html_source) { ...@@ -641,6 +642,7 @@ void AddDeviceStrings(content::WebUIDataSource* html_source) {
{"keyboardKeyExternalCommand", {"keyboardKeyExternalCommand",
IDS_SETTINGS_KEYBOARD_KEY_EXTERNAL_COMMAND}, IDS_SETTINGS_KEYBOARD_KEY_EXTERNAL_COMMAND},
{"keyboardKeyExternalMeta", IDS_SETTINGS_KEYBOARD_KEY_EXTERNAL_META}, {"keyboardKeyExternalMeta", IDS_SETTINGS_KEYBOARD_KEY_EXTERNAL_META},
{"keyboardKeyMeta", IDS_SETTINGS_KEYBOARD_KEY_META},
{"keyboardSendFunctionKeys", IDS_SETTINGS_KEYBOARD_SEND_FUNCTION_KEYS}, {"keyboardSendFunctionKeys", IDS_SETTINGS_KEYBOARD_SEND_FUNCTION_KEYS},
{"keyboardSendFunctionKeysDescription", {"keyboardSendFunctionKeysDescription",
ui::DeviceUsesKeyboardLayout2() ui::DeviceUsesKeyboardLayout2()
......
...@@ -610,15 +610,17 @@ cr.define('device_page_tests', function() { ...@@ -610,15 +610,17 @@ cr.define('device_page_tests', function() {
expectFalse(!!keyboardPage.$$('#capsLockKey')); expectFalse(!!keyboardPage.$$('#capsLockKey'));
expectFalse(!!keyboardPage.$$('#diamondKey')); expectFalse(!!keyboardPage.$$('#diamondKey'));
// Pretend the diamond key is available. // Pretend the diamond key is available, and no internal keyboard.
let keyboardParams = { let keyboardParams = {
'showCapsLock': false, 'showCapsLock': false,
'showDiamondKey': true, 'showDiamondKey': true,
'showExternalMetaKey': false, 'showExternalMetaKey': false,
'showAppleCommandKey': false, 'showAppleCommandKey': false,
'hasInternalKeyboard': false,
}; };
cr.webUIListenerCallback('show-keys-changed', keyboardParams); cr.webUIListenerCallback('show-keys-changed', keyboardParams);
Polymer.dom.flush(); Polymer.dom.flush();
expectFalse(!!keyboardPage.$$('#internalSearchKey'));
expectFalse(!!keyboardPage.$$('#capsLockKey')); expectFalse(!!keyboardPage.$$('#capsLockKey'));
expectTrue(!!keyboardPage.$$('#diamondKey')); expectTrue(!!keyboardPage.$$('#diamondKey'));
expectFalse(!!keyboardPage.$$('#externalMetaKey')); expectFalse(!!keyboardPage.$$('#externalMetaKey'));
...@@ -628,6 +630,7 @@ cr.define('device_page_tests', function() { ...@@ -628,6 +630,7 @@ cr.define('device_page_tests', function() {
keyboardParams['showCapsLock'] = true; keyboardParams['showCapsLock'] = true;
cr.webUIListenerCallback('show-keys-changed', keyboardParams); cr.webUIListenerCallback('show-keys-changed', keyboardParams);
Polymer.dom.flush(); Polymer.dom.flush();
expectFalse(!!keyboardPage.$$('#internalSearchKey'));
expectTrue(!!keyboardPage.$$('#capsLockKey')); expectTrue(!!keyboardPage.$$('#capsLockKey'));
expectTrue(!!keyboardPage.$$('#diamondKey')); expectTrue(!!keyboardPage.$$('#diamondKey'));
expectFalse(!!keyboardPage.$$('#externalMetaKey')); expectFalse(!!keyboardPage.$$('#externalMetaKey'));
...@@ -637,6 +640,7 @@ cr.define('device_page_tests', function() { ...@@ -637,6 +640,7 @@ cr.define('device_page_tests', function() {
keyboardParams['showExternalMetaKey'] = true; keyboardParams['showExternalMetaKey'] = true;
cr.webUIListenerCallback('show-keys-changed', keyboardParams); cr.webUIListenerCallback('show-keys-changed', keyboardParams);
Polymer.dom.flush(); Polymer.dom.flush();
expectFalse(!!keyboardPage.$$('#internalSearchKey'));
expectTrue(!!keyboardPage.$$('#capsLockKey')); expectTrue(!!keyboardPage.$$('#capsLockKey'));
expectTrue(!!keyboardPage.$$('#diamondKey')); expectTrue(!!keyboardPage.$$('#diamondKey'));
expectTrue(!!keyboardPage.$$('#externalMetaKey')); expectTrue(!!keyboardPage.$$('#externalMetaKey'));
...@@ -646,6 +650,17 @@ cr.define('device_page_tests', function() { ...@@ -646,6 +650,17 @@ cr.define('device_page_tests', function() {
keyboardParams['showAppleCommandKey'] = true; keyboardParams['showAppleCommandKey'] = true;
cr.webUIListenerCallback('show-keys-changed', keyboardParams); cr.webUIListenerCallback('show-keys-changed', keyboardParams);
Polymer.dom.flush(); Polymer.dom.flush();
expectFalse(!!keyboardPage.$$('#internalSearchKey'));
expectTrue(!!keyboardPage.$$('#capsLockKey'));
expectTrue(!!keyboardPage.$$('#diamondKey'));
expectTrue(!!keyboardPage.$$('#externalMetaKey'));
expectTrue(!!keyboardPage.$$('#externalCommandKey'));
// Add an internal keyboard.
keyboardParams['hasInternalKeyboard'] = true;
cr.webUIListenerCallback('show-keys-changed', keyboardParams);
Polymer.dom.flush();
expectTrue(!!keyboardPage.$$('#internalSearchKey'));
expectTrue(!!keyboardPage.$$('#capsLockKey')); expectTrue(!!keyboardPage.$$('#capsLockKey'));
expectTrue(!!keyboardPage.$$('#diamondKey')); expectTrue(!!keyboardPage.$$('#diamondKey'));
expectTrue(!!keyboardPage.$$('#externalMetaKey')); expectTrue(!!keyboardPage.$$('#externalMetaKey'));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment