Chromium Code Reviews| Index: chrome/test/data/webui/settings/android_apps_page_test.js |
| diff --git a/chrome/test/data/webui/settings/android_apps_page_test.js b/chrome/test/data/webui/settings/android_apps_page_test.js |
| index 95a80c2afb185f8cf16eeabf951dc6cd0098b879..8d7d8b675c2a85ceb09ceeb70f1beefb76d73538 100644 |
| --- a/chrome/test/data/webui/settings/android_apps_page_test.js |
| +++ b/chrome/test/data/webui/settings/android_apps_page_test.js |
| @@ -12,9 +12,6 @@ function TestAndroidAppsBrowserProxy() { |
| 'requestAndroidAppsInfo', |
| 'showAndroidAppsSettings', |
| ]); |
| - |
| - /** @private {!AndroidAppsInfo} */ |
| - this.androidAppsInfo_ = {appReady: false}; |
| } |
| TestAndroidAppsBrowserProxy.prototype = { |
| @@ -23,12 +20,19 @@ TestAndroidAppsBrowserProxy.prototype = { |
| /** @override */ |
| requestAndroidAppsInfo: function() { |
| this.methodCalled('requestAndroidAppsInfo'); |
| + cr.webUIListenerCallback('android-apps-info-update', {appReady: false}); |
| }, |
| /** override */ |
| showAndroidAppsSettings: function(keyboardAction) { |
| this.methodCalled('showAndroidAppsSettings'); |
| }, |
| + |
| + setAppReady: function(ready) { |
| + // We need to make sure to pass a new object here, otherwise the property |
| + // change event may not get fired in the listener. |
| + cr.webUIListenerCallback('android-apps-info-update', {appReady: ready}); |
| + }, |
| }; |
| /** @type {?SettingsAndroidAppsPageElement} */ |
| @@ -44,72 +48,101 @@ suite('AndroidAppsPageTests', function() { |
| PolymerTest.clearBody(); |
| androidAppsPage = document.createElement('settings-android-apps-page'); |
| document.body.appendChild(androidAppsPage); |
| + testing.Test.disableAnimationsAndTransitions(); |
| + }); |
| + |
| + teardown(function() { |
| + androidAppsPage.remove(); |
| + }); |
| + |
| + suite('Main Page', function() { |
| + setup(function() { |
| + androidAppsPage.prefs = {arc: {enabled: {value: false}}}; |
| + Polymer.dom.flush(); |
| + |
| + return androidAppsBrowserProxy.whenCalled('requestAndroidAppsInfo') |
| + .then(function() { |
| + androidAppsBrowserProxy.setAppReady(false); |
| + }); |
| + }); |
| + |
| + test('Enable', function() { |
| + var button = androidAppsPage.$$('#enable'); |
| + assertTrue(!!button); |
| + assertFalse(!!androidAppsPage.$$('.subpage-arrow')); |
| + |
| + MockInteractions.tap(button); |
| + Polymer.dom.flush(); |
| + assertTrue(androidAppsPage.prefs.arc.enabled.value); |
| + |
| + androidAppsBrowserProxy.setAppReady(true); |
| + Polymer.dom.flush(); |
| + assertTrue(!!androidAppsPage.$$('.subpage-arrow')); |
| + }); |
| }); |
| - teardown(function() { androidAppsPage.remove(); }); |
| - |
| - test('Enable', function() { |
| - return androidAppsBrowserProxy.whenCalled('requestAndroidAppsInfo') |
| - .then(function() { |
| - androidAppsPage.prefs = { |
| - arc: { |
| - enabled: { |
| - value: false, |
| - }, |
| - }, |
| - }; |
| - cr.webUIListenerCallback( |
| - 'android-apps-info-update', {appReady: false}); |
| - Polymer.dom.flush(); |
| - var control = androidAppsPage.$$('#enabled'); |
| - assertTrue(!!control); |
| - assertFalse(control.disabled); |
| - assertFalse(control.checked); |
| - var managed = androidAppsPage.$$('#manageApps'); |
| - assertTrue(!!managed); |
| - assertTrue(managed.hidden); |
| - |
| - MockInteractions.tap(control.$.control); |
| - Polymer.dom.flush(); |
| - assertTrue(control.checked); |
| - }); |
| + suite('SubPage', function() { |
| + var subpage; |
| + |
| + setup(function() { |
| + androidAppsPage.prefs = {arc: {enabled: {value: true}}}; |
| + return androidAppsBrowserProxy.whenCalled('requestAndroidAppsInfo') |
| + .then(function() { |
| + androidAppsBrowserProxy.setAppReady(true); |
| + var div = androidAppsPage.$$('#android-apps'); |
|
Dan Beam
2017/03/30 23:35:19
can you rename this to a more descriptive name? |
stevenjb
2017/03/31 16:33:23
Done.
|
| + MockInteractions.tap(div); |
| + Polymer.dom.flush(); |
| + subpage = androidAppsPage.$$('settings-android-apps-subpage'); |
| + assertTrue(!!subpage); |
| + }); |
| + }); |
| + |
| + test('Sanity', function() { |
| + assertTrue(!!subpage.$$('#manageApps')); |
| + assertTrue(!!subpage.$$('#remove')); |
| + }); |
| + |
| + test('Disable', function() { |
| + var dialog = subpage.$$('#confirmDisableDialog'); |
| + assertTrue(!!dialog); |
| + assertFalse(dialog.open); |
| + |
| + var remove = subpage.$$('#remove'); |
| + assertTrue(!!remove); |
| + MockInteractions.tap(remove); |
| + |
| + Polymer.dom.flush(); |
| + assertTrue(dialog.open); |
| + }); |
| }); |
| - test('Disable', function() { |
| - return androidAppsBrowserProxy.whenCalled('requestAndroidAppsInfo') |
| - .then(function() { |
| - androidAppsPage.prefs = { |
| - arc: { |
| - enabled: { |
| - value: true, |
| - }, |
| - }, |
| - }; |
| - cr.webUIListenerCallback( |
| - 'android-apps-info-update', {appReady: true}); |
| - Polymer.dom.flush(); |
| - var control = androidAppsPage.$$('#enabled'); |
| - assertTrue(!!control); |
| - assertFalse(control.disabled); |
| - assertTrue(control.checked); |
| - var managed = androidAppsPage.$$('#manageApps'); |
| - assertTrue(!!managed); |
| - assertFalse(managed.hidden); |
| - |
| - MockInteractions.tap(control.$.control); |
| - cr.webUIListenerCallback( |
| - 'android-apps-info-update', {appReady: false}); |
| - Polymer.dom.flush(); |
| - var dialog = androidAppsPage.$$('#confirmDisableDialog'); |
| - assertTrue(!!dialog); |
| - assertTrue(dialog.open); |
| - var actionButton = |
| - androidAppsPage.$$('dialog paper-button.action-button'); |
| - assertTrue(!!actionButton); |
| - MockInteractions.tap(actionButton); |
| - Polymer.dom.flush(); |
| - assertFalse(control.checked); |
| - assertTrue(managed.hidden); |
| - }); |
| + suite('Enforced', function() { |
| + var subpage; |
| + |
| + setup(function() { |
| + androidAppsPage.prefs = { |
| + arc: { |
| + enabled: { |
| + value: true, |
| + enforcement: chrome.settingsPrivate.Enforcement.ENFORCED |
| + } |
| + } |
| + }; |
| + return androidAppsBrowserProxy.whenCalled('requestAndroidAppsInfo') |
| + .then(function() { |
| + androidAppsBrowserProxy.setAppReady(true); |
| + var div = androidAppsPage.$$('#android-apps'); |
|
Dan Beam
2017/03/30 23:35:19
same nit re: div
stevenjb
2017/03/31 16:33:23
Done.
|
| + MockInteractions.tap(div); |
| + Polymer.dom.flush(); |
| + subpage = androidAppsPage.$$('settings-android-apps-subpage'); |
| + assertTrue(!!subpage); |
| + }); |
| + }); |
| + |
| + test('Sanity', function() { |
| + Polymer.dom.flush(); |
| + assertTrue(!!subpage.$$('#manageApps')); |
| + assertFalse(!!subpage.$$('#remove')); |
| + }); |
| }); |
| }); |