Commit fd80700b authored by Omid Tourzan's avatar Omid Tourzan Committed by Commit Bot

[files-progress] Remove secondary message for not supported operations.

It fixes the issue of showing remaining time for not supported
operation.

Also fixes the issue when remaining time displayed if same (identical
panel item id) error panel gets updated or reused because not
dismissed yet.

Bug: 1137229
Change-Id: Ic09e621e8811322ad4602e5d4ecc8fef8f42929c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2463100Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Omid Tourzan <oto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816894}
parent 1f882220
...@@ -706,7 +706,10 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P( ...@@ -706,7 +706,10 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("transferDeletedFile"), TestCase("transferDeletedFile"),
TestCase("transferInfoIsRemembered"), TestCase("transferInfoIsRemembered"),
TestCase("transferToUsbHasDestinationText"), TestCase("transferToUsbHasDestinationText"),
TestCase("transferDismissedErrorIsRemembered"))); TestCase("transferDismissedErrorIsRemembered"),
TestCase("transferNotSupportedOperationHasNoRemainingTimeText"),
TestCase("transferUpdateSamePanelItem"),
TestCase("transferShowPendingMessageForZeroRemainingTime")));
WRAPPED_INSTANTIATE_TEST_SUITE_P( WRAPPED_INSTANTIATE_TEST_SUITE_P(
RestorePrefs, /* restore_prefs.js */ RestorePrefs, /* restore_prefs.js */
......
...@@ -896,5 +896,32 @@ test.util.sync.staticFakeCounter = (contentWindow, fakedApi) => { ...@@ -896,5 +896,32 @@ test.util.sync.staticFakeCounter = (contentWindow, fakedApi) => {
return fake.callCounter_; return fake.callCounter_;
}; };
/**
* Send progress item to Foreground page to display.
* @param {string} id Progress item id.
* @param {ProgressItemType} type Type of progress item.
* @param {ProgressItemState} state State of the progress item.
* @param {string} message Message of the progress item.
* @param {number} remainingTime The remaining time of the progress in second.
* @param {number} progressMax Max value of the progress.
* @param {number} progressValue Current value of the progress.
* @param {number} count Number of items being processed.
*/
test.util.sync.sendProgressItem =
(id, type, state, message, remainingTime, progressMax = 1,
progressValue = 0, count = 1) => {
const item = new ProgressCenterItem();
item.id = id;
item.type = type;
item.state = state;
item.message = message;
item.remainingTime = remainingTime;
item.progressMax = progressMax;
item.progressValue = progressValue;
item.itemCount = count;
background.progressCenter.updateItem(item);
};
// Register the test utils. // Register the test utils.
test.util.registerRemoteTestUtils(); test.util.registerRemoteTestUtils();
...@@ -519,6 +519,12 @@ class ProgressCenterPanel { ...@@ -519,6 +519,12 @@ class ProgressCenterPanel {
return str('PENDING_LABEL'); return str('PENDING_LABEL');
} }
// Return empty string for not supported operation (didn't set
// remainingTime) or 0 sec remainingTime in non progressing state.
if (!seconds) {
return '';
}
const hours = Math.floor(seconds / 3600); const hours = Math.floor(seconds / 3600);
const minutes = Math.floor((seconds % 3600) / 60); const minutes = Math.floor((seconds % 3600) / 60);
...@@ -633,6 +639,7 @@ class ProgressCenterPanel { ...@@ -633,6 +639,7 @@ class ProgressCenterPanel {
case 'error': case 'error':
panelItem.panelType = panelItem.panelTypeError; panelItem.panelType = panelItem.panelTypeError;
panelItem.primaryText = item.message; panelItem.primaryText = item.message;
panelItem.secondaryText = '';
// Make sure the panel is attached so it shows immediately. // Make sure the panel is attached so it shows immediately.
this.feedbackHost_.attachPanelItem(panelItem); this.feedbackHost_.attachPanelItem(panelItem);
break; break;
......
...@@ -1093,3 +1093,90 @@ testcase.transferDismissedErrorIsRemembered = async () => { ...@@ -1093,3 +1093,90 @@ testcase.transferDismissedErrorIsRemembered = async () => {
appId, ['#progress-panel', 'xf-panel-item']); appId, ['#progress-panel', 'xf-panel-item']);
chrome.test.assertEq('progress', progressPanel.attributes['indicator']); chrome.test.assertEq('progress', progressPanel.attributes['indicator']);
}; };
/**
* Tests no remaining time displayed for not supported operations like format.
*/
testcase.transferNotSupportedOperationHasNoRemainingTimeText = async () => {
const appId = await setupAndWaitUntilReady(RootPath.DOWNLOADS);
// Show a |format| progress panel.
await remoteCall.callRemoteTestUtil('sendProgressItem', null, [
'item-id-1',
/* ProgressItemType.FORMAT */ 'format',
/* ProgressItemState.PROGRESSING */ 'progressing', 'Formatting'
]);
// Check the progress panel is open.
let panel = await remoteCall.waitForElement(
appId, ['#progress-panel', 'xf-panel-item']);
// Check no remaining time shown for 'format' panel type.
chrome.test.assertEq('', panel.attributes['secondary-text']);
// Show a |format| error panel.
await remoteCall.callRemoteTestUtil('sendProgressItem', null, [
'item-id-2', /* ProgressItemType.FORMAT */ 'format',
/* ProgressItemState.ERROR */ 'error', 'Failed'
]);
// Check the progress panel is open.
panel = await remoteCall.waitForElement(
appId, ['#progress-panel', 'xf-panel-item#item-id-2']);
// Check no remaining time shown for 'format' error panel type.
chrome.test.assertEq('', panel.attributes['secondary-text']);
};
/**
* Tests updating same panel keeps same message.
* Use case: crbug/1137229
*/
testcase.transferUpdateSamePanelItem = async () => {
const appId = await setupAndWaitUntilReady(RootPath.DOWNLOADS);
// Show a |format| error in feedback panel.
await remoteCall.callRemoteTestUtil('sendProgressItem', null, [
'item-id', /* ProgressItemType.FORMAT */ 'format',
/* ProgressItemState.ERROR */ 'error', 'Failed'
]);
// Check the error panel is open.
let panel = await remoteCall.waitForElement(
appId, ['#progress-panel', 'xf-panel-item']);
// Dispatch another |format| feedback panel with the same id and panel type.
await remoteCall.callRemoteTestUtil('sendProgressItem', null, [
'item-id', /* ProgressItemType.FORMAT */ 'format',
/* ProgressItemState.ERROR */ 'error', 'Failed new message'
]);
// Check the progress panel is open.
panel = await remoteCall.waitForElement(
appId, ['#progress-panel', 'xf-panel-item']);
// Check secondary text is still empty for the error panel.
chrome.test.assertEq('', panel.attributes['secondary-text']);
};
/**
* Tests pending message shown when the remaining time is zero.
*/
testcase.transferShowPendingMessageForZeroRemainingTime = async () => {
const appId = await setupAndWaitUntilReady(RootPath.DOWNLOADS);
// Show a |copy| progress in feedback panel.
await remoteCall.callRemoteTestUtil('sendProgressItem', null, [
'item-id', /* ProgressItemType.COPY */ 'copy',
/* ProgressItemState.PROGRESSING */ 'progressing',
'Copying File1.txt to Downloads',
/* remainingTime*/ 0
]);
// Check the error panel is open.
const panel = await remoteCall.waitForElement(
appId, ['#progress-panel', 'xf-panel-item']);
// Check secondary text is pending message.
chrome.test.assertEq('Pending', panel.attributes['secondary-text']);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment