OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 /** |
| 6 * @constructor |
| 7 * @implements {settings.AndroidAppsBrowserProxy} |
| 8 * @extends {settings.TestBrowserProxy} |
| 9 */ |
| 10 function TestAndroidAppsBrowserProxy() { |
| 11 settings.TestBrowserProxy.call(this, [ |
| 12 'requestAndroidAppsInfo', |
| 13 'showAndroidAppsSettings', |
| 14 ]); |
| 15 |
| 16 /** @private {!AndroidAppsInfo} */ |
| 17 this.androidAppsInfo_ = {appReady: false}; |
| 18 } |
| 19 |
| 20 TestAndroidAppsBrowserProxy.prototype = { |
| 21 __proto__: settings.TestBrowserProxy.prototype, |
| 22 |
| 23 /** @override */ |
| 24 requestAndroidAppsInfo: function() { |
| 25 this.methodCalled('requestAndroidAppsInfo'); |
| 26 }, |
| 27 |
| 28 /** override */ |
| 29 showAndroidAppsSettings: function(keyboardAction) { |
| 30 this.methodCalled('showAndroidAppsSettings'); |
| 31 }, |
| 32 }; |
| 33 |
| 34 /** @type {?SettingsAndroidAppsPageElement} */ |
| 35 var androidAppsPage = null; |
| 36 |
| 37 /** @type {?TestAndroidAppsBrowserProxy} */ |
| 38 var androidAppsBrowserProxy = null; |
| 39 |
| 40 suite('AndroidAppsPageTests', function() { |
| 41 setup(function() { |
| 42 androidAppsBrowserProxy = new TestAndroidAppsBrowserProxy(); |
| 43 settings.AndroidAppsBrowserProxyImpl.instance_ = androidAppsBrowserProxy; |
| 44 PolymerTest.clearBody(); |
| 45 androidAppsPage = document.createElement('settings-android-apps-page'); |
| 46 document.body.appendChild(androidAppsPage); |
| 47 }); |
| 48 |
| 49 teardown(function() { androidAppsPage.remove(); }); |
| 50 |
| 51 test('Enable', function() { |
| 52 return androidAppsBrowserProxy.whenCalled('requestAndroidAppsInfo') |
| 53 .then(function() { |
| 54 androidAppsPage.prefs = { |
| 55 arc: { |
| 56 enabled: { |
| 57 value: false, |
| 58 }, |
| 59 }, |
| 60 }; |
| 61 cr.webUIListenerCallback( |
| 62 'android-apps-info-update', {appReady: false}); |
| 63 Polymer.dom.flush(); |
| 64 var checkbox = androidAppsPage.$$('#enabledCheckbox'); |
| 65 assertTrue(!!checkbox); |
| 66 assertFalse(checkbox.disabled); |
| 67 assertFalse(checkbox.checked); |
| 68 var managed = androidAppsPage.$$('#manageApps'); |
| 69 assertTrue(!!managed); |
| 70 assertTrue(managed.hidden); |
| 71 |
| 72 MockInteractions.tap(checkbox.$.checkbox); |
| 73 Polymer.dom.flush(); |
| 74 assertTrue(checkbox.checked); |
| 75 }); |
| 76 }); |
| 77 |
| 78 test('Disable', function() { |
| 79 return androidAppsBrowserProxy.whenCalled('requestAndroidAppsInfo') |
| 80 .then(function() { |
| 81 androidAppsPage.prefs = { |
| 82 arc: { |
| 83 enabled: { |
| 84 value: true, |
| 85 }, |
| 86 }, |
| 87 }; |
| 88 cr.webUIListenerCallback( |
| 89 'android-apps-info-update', {appReady: true}); |
| 90 Polymer.dom.flush(); |
| 91 var checkbox = androidAppsPage.$$('#enabledCheckbox'); |
| 92 assertTrue(!!checkbox); |
| 93 assertFalse(checkbox.disabled); |
| 94 assertTrue(checkbox.checked); |
| 95 var managed = androidAppsPage.$$('#manageApps'); |
| 96 assertTrue(!!managed); |
| 97 assertFalse(managed.hidden); |
| 98 |
| 99 MockInteractions.tap(checkbox.$.checkbox); |
| 100 cr.webUIListenerCallback( |
| 101 'android-apps-info-update', {appReady: false}); |
| 102 Polymer.dom.flush(); |
| 103 var dialog = androidAppsPage.$$('#confirmDisableDialog'); |
| 104 assertTrue(!!dialog); |
| 105 assertTrue(dialog.open); |
| 106 var actionButton = |
| 107 androidAppsPage.$$('dialog paper-button.action-button'); |
| 108 assertTrue(!!actionButton); |
| 109 MockInteractions.tap(actionButton); |
| 110 Polymer.dom.flush(); |
| 111 assertFalse(checkbox.checked); |
| 112 assertTrue(managed.hidden); |
| 113 }); |
| 114 }); |
| 115 }); |
OLD | NEW |