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 f5e2daceb010e04a6ff2d0a821576192b512d6ca..95a80c2afb185f8cf16eeabf951dc6cd0098b879 100644 |
--- a/chrome/test/data/webui/settings/android_apps_page_test.js |
+++ b/chrome/test/data/webui/settings/android_apps_page_test.js |
@@ -12,6 +12,9 @@ |
'requestAndroidAppsInfo', |
'showAndroidAppsSettings', |
]); |
+ |
+ /** @private {!AndroidAppsInfo} */ |
+ this.androidAppsInfo_ = {appReady: false}; |
} |
TestAndroidAppsBrowserProxy.prototype = { |
@@ -20,18 +23,11 @@ |
/** @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}); |
}, |
}; |
@@ -48,99 +44,72 @@ |
PolymerTest.clearBody(); |
androidAppsPage = document.createElement('settings-android-apps-page'); |
document.body.appendChild(androidAppsPage); |
- testing.Test.disableAnimationsAndTransitions(); |
}); |
- teardown(function() { |
- androidAppsPage.remove(); |
+ 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('Main Page', function() { |
- setup(function() { |
- androidAppsPage.prefs = {arc: {enabled: {value: false}}}; |
- Polymer.dom.flush(); |
+ 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); |
- 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')); |
- }); |
- }); |
- |
- suite('SubPage', function() { |
- var subpage; |
- |
- setup(function() { |
- androidAppsPage.prefs = {arc: {enabled: {value: true}}}; |
- return androidAppsBrowserProxy.whenCalled('requestAndroidAppsInfo') |
- .then(function() { |
- androidAppsBrowserProxy.setAppReady(true); |
- MockInteractions.tap(androidAppsPage.$$('#android-apps')); |
- 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); |
- }); |
- }); |
- |
- 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); |
- MockInteractions.tap(androidAppsPage.$$('#android-apps')); |
- Polymer.dom.flush(); |
- subpage = androidAppsPage.$$('settings-android-apps-subpage'); |
- assertTrue(!!subpage); |
- }); |
- }); |
- |
- test('Sanity', function() { |
- Polymer.dom.flush(); |
- assertTrue(!!subpage.$$('#manageApps')); |
- assertFalse(!!subpage.$$('#remove')); |
- }); |
+ 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); |
+ }); |
}); |
}); |