Commit c298a0e0 authored by Daniel Classon's avatar Daniel Classon Committed by Commit Bot

[DevicePage] Add missing function to Device Page Browser Proxy

The initializeKeyboardWatcher WebUI event was missing from the Device
Page browser proxy. Add it in, and replace chrome.send in the Manage
A11y subpage.

Bug: None
Change-Id: I5cc568e52ab6c602b1af49794e60368aa9d9f170
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2399602
Commit-Queue: Daniel Classon <dclasson@google.com>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805468}
parent ee48012a
...@@ -97,6 +97,9 @@ cr.define('settings', function() { ...@@ -97,6 +97,9 @@ cr.define('settings', function() {
/** Initializes the keyboard WebUI handler. */ /** Initializes the keyboard WebUI handler. */
initializeKeyboard() {} initializeKeyboard() {}
/** Initializes the keyboard update watcher. */
initializeKeyboardWatcher() {}
/** Shows the Ash keyboard shortcut viewer. */ /** Shows the Ash keyboard shortcut viewer. */
showKeyboardShortcutViewer() {} showKeyboardShortcutViewer() {}
...@@ -216,6 +219,11 @@ cr.define('settings', function() { ...@@ -216,6 +219,11 @@ cr.define('settings', function() {
chrome.send('showKeyboardShortcutViewer'); chrome.send('showKeyboardShortcutViewer');
} }
/** @override */
initializeKeyboardWatcher() {
chrome.send('initializeKeyboardWatcher');
}
/** @override */ /** @override */
updateAndroidEnabled() { updateAndroidEnabled() {
chrome.send('updateAndroidEnabled'); chrome.send('updateAndroidEnabled');
......
...@@ -239,17 +239,26 @@ Polymer({ ...@@ -239,17 +239,26 @@ Polymer({
/** settings.RouteOriginBehavior override */ /** settings.RouteOriginBehavior override */
route_: settings.routes.MANAGE_ACCESSIBILITY, route_: settings.routes.MANAGE_ACCESSIBILITY,
/** @private {?settings.DevicePageBrowserProxy} */
deviceBrowserProxy_: null,
/** @override */
created() {
this.deviceBrowserProxy_ =
settings.DevicePageBrowserProxyImpl.getInstance();
},
/** @override */ /** @override */
attached() { attached() {
this.addWebUIListener( this.addWebUIListener(
'has-mouse-changed', this.set.bind(this, 'hasMouse_')); 'has-mouse-changed', this.set.bind(this, 'hasMouse_'));
this.addWebUIListener( this.addWebUIListener(
'has-touchpad-changed', this.set.bind(this, 'hasTouchpad_')); 'has-touchpad-changed', this.set.bind(this, 'hasTouchpad_'));
settings.DevicePageBrowserProxyImpl.getInstance().initializePointers(); this.deviceBrowserProxy_.initializePointers();
this.addWebUIListener( this.addWebUIListener(
'has-hardware-keyboard', this.set.bind(this, 'hasKeyboard_')); 'has-hardware-keyboard', this.set.bind(this, 'hasKeyboard_'));
chrome.send('initializeKeyboardWatcher'); this.deviceBrowserProxy_.initializeKeyboardWatcher();
}, },
/** @override */ /** @override */
......
...@@ -13,7 +13,7 @@ function isVisible(element) { ...@@ -13,7 +13,7 @@ function isVisible(element) {
suite('ManageAccessibilityPageTests', function() { suite('ManageAccessibilityPageTests', function() {
let page = null; let page = null;
let browserProxy = null; let deviceBrowserProxy = null;
/** @implements {settings.DevicePageBrowserProxy} */ /** @implements {settings.DevicePageBrowserProxy} */
class TestDevicePageBrowserProxy { class TestDevicePageBrowserProxy {
...@@ -41,6 +41,11 @@ suite('ManageAccessibilityPageTests', function() { ...@@ -41,6 +41,11 @@ suite('ManageAccessibilityPageTests', function() {
cr.webUIListenerCallback('has-mouse-changed', this.hasMouse_); cr.webUIListenerCallback('has-mouse-changed', this.hasMouse_);
cr.webUIListenerCallback('has-touchpad-changed', this.hasTouchpad_); cr.webUIListenerCallback('has-touchpad-changed', this.hasTouchpad_);
} }
/** @override */
initializeKeyboardWatcher() {
cr.webUIListenerCallback('has-hardware-keyboard', this.hasKeyboard_);
}
} }
function initPage() { function initPage() {
...@@ -49,11 +54,10 @@ suite('ManageAccessibilityPageTests', function() { ...@@ -49,11 +54,10 @@ suite('ManageAccessibilityPageTests', function() {
} }
setup(function() { setup(function() {
browserProxy = new TestDevicePageBrowserProxy(); deviceBrowserProxy = new TestDevicePageBrowserProxy();
settings.DevicePageBrowserProxyImpl.instance_ = browserProxy; settings.DevicePageBrowserProxyImpl.instance_ = deviceBrowserProxy;
PolymerTest.clearBody(); PolymerTest.clearBody();
}); });
teardown(function() { teardown(function() {
...@@ -68,19 +72,19 @@ suite('ManageAccessibilityPageTests', function() { ...@@ -68,19 +72,19 @@ suite('ManageAccessibilityPageTests', function() {
assertFalse(row.hidden); assertFalse(row.hidden);
// Has touchpad, doesn't have mouse ==> not hidden. // Has touchpad, doesn't have mouse ==> not hidden.
browserProxy.hasMouse = false; deviceBrowserProxy.hasMouse = false;
assertFalse(row.hidden); assertFalse(row.hidden);
// Doesn't have either ==> hidden. // Doesn't have either ==> hidden.
browserProxy.hasTouchpad = false; deviceBrowserProxy.hasTouchpad = false;
assertTrue(row.hidden); assertTrue(row.hidden);
// Has mouse, doesn't have touchpad ==> not hidden. // Has mouse, doesn't have touchpad ==> not hidden.
browserProxy.hasMouse = true; deviceBrowserProxy.hasMouse = true;
assertFalse(row.hidden); assertFalse(row.hidden);
// Has both ==> not hidden. // Has both ==> not hidden.
browserProxy.hasTouchpad = true; deviceBrowserProxy.hasTouchpad = true;
assertFalse(row.hidden); assertFalse(row.hidden);
}); });
...@@ -90,8 +94,8 @@ suite('ManageAccessibilityPageTests', function() { ...@@ -90,8 +94,8 @@ suite('ManageAccessibilityPageTests', function() {
}); });
initPage(); initPage();
// Add mouse and touchpad to show some hidden settings. // Add mouse and touchpad to show some hidden settings.
browserProxy.hasMouse = true; deviceBrowserProxy.hasMouse = true;
browserProxy.hasTouchpad = true; deviceBrowserProxy.hasTouchpad = true;
Polymer.dom.flush(); Polymer.dom.flush();
// Accessibility learn more link should be hidden. // Accessibility learn more link should be hidden.
......
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