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 'getAndroidAppsInfo', |
| 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 getAndroidAppsInfo: function() { |
| 25 this.methodCalled('getAndroidAppsInfo'); |
| 26 return Promise.resolve(this.androidAppsInfo_); |
| 27 }, |
| 28 |
| 29 /** override */ |
| 30 showAndroidAppsSettings: function() { |
| 31 this.methodCalled('showAndroidAppsSettings'); |
| 32 }, |
| 33 }; |
| 34 |
| 35 /** @type {?SettingsAndroidAppsPageElement} */ |
| 36 var androidAppsPage = null; |
| 37 |
| 38 /** @type {?TestAndroidAppsBrowserProxy} */ |
| 39 var androidAppsBrowserProxy = null; |
| 40 |
| 41 suite('AndroidAppsPageTests', function() { |
| 42 setup(function() { |
| 43 androidAppsBrowserProxy = new TestAndroidAppsBrowserProxy(); |
| 44 settings.AndroidAppsBrowserProxyImpl.instance_ = androidAppsBrowserProxy; |
| 45 PolymerTest.clearBody(); |
| 46 androidAppsPage = document.createElement('settings-android-apps-page'); |
| 47 document.body.appendChild(androidAppsPage); |
| 48 }); |
| 49 |
| 50 teardown(function() { androidAppsPage.remove(); }); |
| 51 |
| 52 test('Enable', function() { |
| 53 return androidAppsBrowserProxy.whenCalled('getAndroidAppsInfo') |
| 54 .then(function() { |
| 55 androidAppsPage.prefs = { |
| 56 arc: { |
| 57 enabled: { |
| 58 value: false, |
| 59 }, |
| 60 }, |
| 61 }; |
| 62 Polymer.dom.flush(); |
| 63 var checkbox = androidAppsPage.$$('#enabledCheckbox'); |
| 64 assertTrue(!!checkbox); |
| 65 assertFalse(checkbox.disabled); |
| 66 assertFalse(checkbox.checked); |
| 67 MockInteractions.tap(checkbox.$.checkbox); |
| 68 Polymer.dom.flush(); |
| 69 assertTrue(checkbox.checked); |
| 70 }); |
| 71 }); |
| 72 |
| 73 test('Disable', function() { |
| 74 return androidAppsBrowserProxy.whenCalled('getAndroidAppsInfo') |
| 75 .then(function() { |
| 76 androidAppsPage.prefs = { |
| 77 arc: { |
| 78 enabled: { |
| 79 value: true, |
| 80 }, |
| 81 }, |
| 82 }; |
| 83 Polymer.dom.flush(); |
| 84 var checkbox = androidAppsPage.$$('#enabledCheckbox'); |
| 85 assertTrue(!!checkbox); |
| 86 assertFalse(checkbox.disabled); |
| 87 assertTrue(checkbox.checked); |
| 88 MockInteractions.tap(checkbox.$.checkbox); |
| 89 Polymer.dom.flush(); |
| 90 var dialog = androidAppsPage.$$('#confirmDisableDialog'); |
| 91 assertTrue(!!dialog); |
| 92 assertTrue(dialog.open); |
| 93 var actionButton = |
| 94 androidAppsPage.$$('dialog paper-button.action-button'); |
| 95 assertTrue(!!actionButton); |
| 96 MockInteractions.tap(actionButton); |
| 97 Polymer.dom.flush(); |
| 98 assertFalse(checkbox.checked); |
| 99 }); |
| 100 }); |
| 101 }); |
OLD | NEW |