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

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

Issue 1997453006: MD Settings: About page, updating buttons based on current update status. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@about_page_main3
Patch Set: @private 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
« no previous file with comments | « chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9a7fb7bcfd1e54271be57dc8c688249d12c06bc7..fe0aa45ef9117ca583f480fa36dd08d95593788c 100644
--- a/chrome/test/data/webui/settings/about_page_tests.js
+++ b/chrome/test/data/webui/settings/about_page_tests.js
@@ -25,6 +25,17 @@ cr.define('settings_about_page', function() {
osFirmware: '',
osVersion: '',
};
+
+ /** @private {!UpdateStatus} */
+ this.updateStatus_ = UpdateStatus.UPDATED;
+
+ if (cr.isChromeOS) {
+ /** @private {!BrowserChannel} */
+ this.currentChannel_ = BrowserChannel.BETA;
+
+ /** @private {!BrowserChannel} */
+ this.targetChannel_ = BrowserChannel.BETA;
+ }
};
TestAboutPageBrowserProxy.prototype = {
@@ -35,6 +46,11 @@ cr.define('settings_about_page', function() {
this.versionInfo_ = versionInfo;
},
+ /** @param {!UpdateStatus} updateStatus */
+ setUpdateStatus: function(updateStatus) {
+ this.updateStatus_ = updateStatus;
+ },
+
/** @override */
pageReady: function() {
this.methodCalled('pageReady');
@@ -42,39 +58,59 @@ cr.define('settings_about_page', function() {
/** @override */
refreshUpdateStatus: function() {
+ cr.webUIListenerCallback(
+ 'update-status-changed', {status: this.updateStatus_});
this.methodCalled('refreshUpdateStatus');
},
/** @override */
- getCurrentChannel: function() {
- this.methodCalled('getCurrentChannel');
- return Promise.resolve(BrowserChannel.BETA);
+ openFeedbackDialog: function() {
+ this.methodCalled('openFeedbackDialog');
},
/** @override */
- getTargetChannel: function() {
- this.methodCalled('getTargetChannel');
- return Promise.resolve(BrowserChannel.BETA);
+ openHelpPage: function() {
+ this.methodCalled('openHelpPage');
},
+ };
+
+ if (cr.isChromeOS) {
+ /**
+ * @param {!BrowserChannel} current
+ * @param {!BrowserChannel} target
+ */
+ TestAboutPageBrowserProxy.prototype.setChannels = function(
+ current, target) {
+ this.currentChannel_ = current;
+ this.targetChannel_ = target;
+ };
/** @override */
- getVersionInfo: function() {
- this.methodCalled('getVersionInfo');
- return Promise.resolve(this.versionInfo_);
- },
+ TestAboutPageBrowserProxy.prototype.getCurrentChannel = function() {
+ this.methodCalled('getCurrentChannel');
+ return Promise.resolve(this.currentChannel_);
+ };
/** @override */
- openFeedbackDialog: function() {
- this.methodCalled('openFeedbackDialog');
- },
+ TestAboutPageBrowserProxy.prototype.getTargetChannel = function() {
+ this.methodCalled('getTargetChannel');
+ return Promise.resolve(this.targetChannel_);
+ };
/** @override */
- openHelpPage: function() {
- this.methodCalled('openHelpPage');
- },
- };
+ TestAboutPageBrowserProxy.prototype.getVersionInfo = function() {
+ this.methodCalled('getVersionInfo');
+ return Promise.resolve(this.versionInfo_);
+ };
+ }
+
function registerAboutPageTests() {
+ /** @param {!UpdateStatus} status */
+ function fireStatusChanged(status) {
+ cr.webUIListenerCallback('update-status-changed', {status: status});
+ }
+
suite('AboutPageTest', function() {
var page = null;
var browserProxy = null;
@@ -82,28 +118,27 @@ cr.define('settings_about_page', function() {
setup(function() {
browserProxy = new TestAboutPageBrowserProxy();
settings.AboutPageBrowserProxyImpl.instance_ = browserProxy;
+ return initNewPage();
+ });
+
+ /** @return {!Promise} */
+ function initNewPage() {
+ browserProxy.resetResolver('refreshUpdateStatus');
PolymerTest.clearBody();
page = document.createElement('settings-about-page');
document.body.appendChild(page);
return browserProxy.whenCalled('refreshUpdateStatus');
- });
+ }
/**
* Test that the status icon updates according to incoming
- * 'update-status-chanhed' events.
+ * 'update-status-changed' events.
*/
test('IconUpdates', function() {
- function fireStatusChanged(status) {
- cr.webUIListenerCallback('update-status-changed', {
- status: status, message: '', progress: 0,
- });
- }
-
var SPINNER_ICON = 'chrome://resources/images/throbber_small.svg';
var icon = page.$$('iron-icon');
assertTrue(!!icon);
- assertEquals(null, icon.getAttribute('icon'));
fireStatusChanged(UpdateStatus.CHECKING);
assertEquals(SPINNER_ICON, icon.src);
@@ -134,6 +169,129 @@ cr.define('settings_about_page', function() {
assertEquals(null, icon.getAttribute('icon'));
});
+ if (cr.isChromeOS) {
+ /**
+ * Test that all buttons update according to incoming
+ * 'update-status-changed' events for the case where target and current
+ * channel are the same.
+ */
+ test('ButtonsUpdate_SameChannel', function() {
+ var relaunch = page.$.relaunch;
+ var checkForUpdates = page.$.checkForUpdates;
+ var relaunchAndPowerwash = page.$.relaunchAndPowerwash;
+
+ assertTrue(!!relaunch);
+ assertTrue(!!relaunchAndPowerwash);
+ assertTrue(!!checkForUpdates);
+
+ function assertAllHidden() {
+ assertTrue(checkForUpdates.hidden);
+ assertTrue(relaunch.hidden);
+ assertTrue(relaunchAndPowerwash.hidden);
+ }
+
+ // Check that |UPDATED| status is ignored if the user has not
+ // explicitly checked for updates yet.
+ fireStatusChanged(UpdateStatus.UPDATED);
+ assertFalse(checkForUpdates.hidden);
+ assertTrue(relaunch.hidden);
+ assertTrue(relaunchAndPowerwash.hidden);
+
+ fireStatusChanged(UpdateStatus.CHECKING);
+ assertAllHidden();
+
+ fireStatusChanged(UpdateStatus.UPDATING);
+ assertAllHidden();
+
+ fireStatusChanged(UpdateStatus.NEARLY_UPDATED);
+ assertTrue(checkForUpdates.hidden);
+ assertFalse(relaunch.hidden);
+ assertTrue(relaunchAndPowerwash.hidden);
+
+ fireStatusChanged(UpdateStatus.UPDATED);
+ assertAllHidden();
+
+ fireStatusChanged(UpdateStatus.FAILED);
+ assertFalse(checkForUpdates.hidden);
+ assertTrue(relaunch.hidden);
+ assertTrue(relaunchAndPowerwash.hidden);
+
+ fireStatusChanged(UpdateStatus.DISABLED);
+ assertAllHidden();
+
+ fireStatusChanged(UpdateStatus.DISABLED_BY_ADMIN);
+ assertAllHidden();
+ });
+
+ /**
+ * Test that buttons update according to incoming
+ * 'update-status-changed' events for the case where the target channel
+ * is more stable than current channel.
+ */
+ test('ButtonsUpdate_BetaToStable', function() {
+ browserProxy.setChannels(BrowserChannel.BETA, BrowserChannel.STABLE);
+ browserProxy.setUpdateStatus(UpdateStatus.NEARLY_UPDATED);
+
+ return initNewPage().then(function() {
+ assertTrue(!!page.$.relaunch);
+ assertTrue(!!page.$.relaunchAndPowerwash);
+
+ assertTrue(page.$.relaunch.hidden);
+ assertFalse(page.$.relaunchAndPowerwash.hidden);
+ });
+ });
+
+ /**
+ * Test that buttons update according to incoming
+ * 'update-status-changed' events for the case where the target channel
+ * is less stable than current channel.
+ */
+ test('ButtonsUpdate_StableToBeta', function() {
+ browserProxy.setChannels(BrowserChannel.STABLE, BrowserChannel.BETA);
+ browserProxy.setUpdateStatus(UpdateStatus.NEARLY_UPDATED);
+
+ return initNewPage().then(function() {
+ assertTrue(!!page.$.relaunch);
+ assertTrue(!!page.$.relaunchAndPowerwash);
+
+ assertFalse(page.$.relaunch.hidden);
+ assertTrue(page.$.relaunchAndPowerwash.hidden);
+ });
+ });
+ }
+
+ if (!cr.isChromeOS) {
+ /*
+ * Test that the "Check for updates" button updates according to
+ * incoming 'update-status-changed' events.
+ */
+ test('ButtonsUpdate', function() {
+ var relaunch = page.$.relaunch;
+ assertTrue(!!relaunch);
+
+ fireStatusChanged(UpdateStatus.CHECKING);
+ assertTrue(relaunch.hidden);
+
+ fireStatusChanged(UpdateStatus.UPDATING);
+ assertTrue(relaunch.hidden);
+
+ fireStatusChanged(UpdateStatus.NEARLY_UPDATED);
+ assertFalse(relaunch.hidden);
+
+ fireStatusChanged(UpdateStatus.UPDATED);
+ assertTrue(relaunch.hidden);
+
+ fireStatusChanged(UpdateStatus.FAILED);
+ assertTrue(relaunch.hidden);
+
+ fireStatusChanged(UpdateStatus.DISABLED);
+ assertTrue(relaunch.hidden);
+
+ fireStatusChanged(UpdateStatus.DISABLED_BY_ADMIN);
+ assertTrue(relaunch.hidden);
+ });
+ }
+
test('GetHelp', function() {
assertTrue(!!page.$.help);
MockInteractions.tap(page.$.help);
« no previous file with comments | « chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698