Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7386)

Unified Diff: chrome/test/data/webui/settings/about_page_tests.js

Issue 2010653003: MD Settings: About page, implementing channel switcher dialog. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webui/settings/about_page_tests.js
diff --git a/chrome/test/data/webui/settings/about_page_tests.js b/chrome/test/data/webui/settings/about_page_tests.js
index 4e50c4f9afa7b895d3cc7c9068718cdf47e936bd..9af8d3bb1847d5cca831eaa18d143288db1e3d0e 100644
--- a/chrome/test/data/webui/settings/about_page_tests.js
+++ b/chrome/test/data/webui/settings/about_page_tests.js
@@ -21,7 +21,8 @@ cr.define('settings_about_page', function() {
'getCurrentChannel',
'getTargetChannel',
'getVersionInfo',
- 'getRegulatoryInfo');
+ 'getRegulatoryInfo',
+ 'setChannel');
}
settings.TestBrowserProxy.call(this, methodNames);
@@ -125,6 +126,12 @@ cr.define('settings_about_page', function() {
this.methodCalled('getRegulatoryInfo');
return Promise.resolve(this.regulatoryInfo_);
};
+
+ /** @override */
+ TestAboutPageBrowserProxy.prototype.setChannel = function(
+ channel, isPowerwashAllowed) {
+ this.methodCalled('setChannel', [channel, isPowerwashAllowed]);
+ };
}
@@ -415,12 +422,119 @@ cr.define('settings_about_page', function() {
});
});
}
+
+ function registerChannelSwitcherDialogTests() {
+ /**
+ * Converts an event occurrence to a promise.
+ * @param {string} eventType
+ * @param {!HTMLElement} target
+ * @return {!Promise} A promise firing once the event occurs.
+ * TODO(dpapad); Share this code with certificate_manager_page_test.js
+ * identical helper method.
+ */
+ function eventToPromise(eventType, target) {
+ return new Promise(function(resolve, reject) {
+ target.addEventListener(eventType, resolve);
+ });
+ }
+
+ suite('ChannelSwitcherDialogTest', function() {
+ var dialog = null;
+ var radioButtons = null;
+ var browserProxy = null;
+ var currentChannel = BrowserChannel.BETA;
+
+ setup(function() {
+ browserProxy = new TestAboutPageBrowserProxy();
+ browserProxy.setChannels(currentChannel, currentChannel);
+ settings.AboutPageBrowserProxyImpl.instance_ = browserProxy;
+ PolymerTest.clearBody();
+ dialog = document.createElement('settings-channel-switcher-dialog');
+ document.body.appendChild(dialog);
+
+ radioButtons = dialog.shadowRoot.querySelectorAll(
+ 'paper-radio-button');
+ assertEquals(3, radioButtons.length);
+ return browserProxy.whenCalled('getCurrentChannel');
+ });
+
+ teardown(function() { dialog.remove(); });
+
+ test('Initialization', function() {
+ var radioGroup = dialog.$$('paper-radio-group');
+ assertTrue(!!radioGroup);
+ assertTrue(!!dialog.$.warning);
+ assertTrue(!!dialog.$.changeChannel);
+ assertTrue(!!dialog.$.changeChannelAndPowerwash);
+
+ // Check that upon initialization the radio button corresponding to
+ // the current release channel is pre-selected.
+ assertEquals(currentChannel, radioGroup.selected);
+ assertTrue(dialog.$.warning.hidden);
+
+ // Check that action buttons are hidden when current and target
+ // channel are the same.
+ assertTrue(dialog.$.changeChannel.hidden);
+ assertTrue(dialog.$.changeChannelAndPowerwash.hidden);
+ });
+
+ // Test case where user switches to a less stable channel.
+ test('ChangeChannel_LessStable', function() {
+ assertEquals(BrowserChannel.DEV, radioButtons.item(2).name);
+ MockInteractions.tap(radioButtons.item(2));
+ Polymer.dom.flush();
+
+ assertFalse(dialog.$.warning.hidden);
+ // Check that only the "Change channel" button becomes visible.
+ assertTrue(dialog.$.changeChannelAndPowerwash.hidden);
+ assertFalse(dialog.$.changeChannel.hidden);
+
+ var whenTargetChannelChangedFired = eventToPromise(
+ 'target-channel-changed', dialog);
+
+ MockInteractions.tap(dialog.$.changeChannel);
+ return browserProxy.whenCalled('setChannel').then(function(args) {
+ assertEquals(BrowserChannel.DEV, args[0]);
+ assertFalse(args[1]);
+ return whenTargetChannelChangedFired;
+ }).then(function(event) {
+ assertEquals(BrowserChannel.DEV, event.detail);
+ });
+ });
+
+ // Test case where user switches to a more stable channel.
+ test('ChangeChannel_MoreStable', function() {
+ assertEquals(BrowserChannel.STABLE, radioButtons.item(0).name);
+ MockInteractions.tap(radioButtons.item(0));
+ Polymer.dom.flush();
+
+ assertFalse(dialog.$.warning.hidden);
+ // Check that only the "Change channel and Powerwash" button becomes
+ // visible.
+ assertFalse(dialog.$.changeChannelAndPowerwash.hidden);
+ assertTrue(dialog.$.changeChannel.hidden);
+
+ var whenTargetChannelChangedFired = eventToPromise(
+ 'target-channel-changed', dialog);
+
+ MockInteractions.tap(dialog.$.changeChannelAndPowerwash);
+ return browserProxy.whenCalled('setChannel').then(function(args) {
+ assertEquals(BrowserChannel.STABLE, args[0]);
+ assertTrue(args[1]);
+ return whenTargetChannelChangedFired;
+ }).then(function(event) {
+ assertEquals(BrowserChannel.STABLE, event.detail);
+ });
+ });
+ });
+ }
}
return {
registerTests: function() {
if (cr.isChromeOS) {
registerDetailedBuildInfoTests();
+ registerChannelSwitcherDialogTests();
}
registerAboutPageTests();
},

Powered by Google App Engine
This is Rietveld 408576698