Commit aeeeb655 authored by Alex Danilo's avatar Alex Danilo Committed by Commit Bot

Test for persistence of feedback panel operations

To support testing, adds ProgressCenter function to inhibit file
operation completed messages being propagated to progress center panels.

Test copies a file, remembers the text written on the progress panel,
closes the foreground window, then opens a new foreground window and
verifies that a progress panel is created with the same text as the
original window.

Bug: 988137
Tests: --gtest_filter="*FilesAppBrowserTest.Test/transferInfoIsRemembered"
Change-Id: If48d4ba1c181bc615a6e71abfd3814d2ec239d83
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1898902
Commit-Queue: Alex Danilo <adanilo@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712821}
parent 138c81f2
...@@ -540,7 +540,8 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P( ...@@ -540,7 +540,8 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("transferDragAndDrop"), TestCase("transferDragAndDrop"),
TestCase("transferDragAndHover"), TestCase("transferDragAndHover"),
TestCase("transferFromDownloadsToDownloads"), TestCase("transferFromDownloadsToDownloads"),
TestCase("transferDeletedFile"))); TestCase("transferDeletedFile"),
TestCase("transferInfoIsRemembered")));
WRAPPED_INSTANTIATE_TEST_SUITE_P( WRAPPED_INSTANTIATE_TEST_SUITE_P(
RestorePrefs, /* restore_prefs.js */ RestorePrefs, /* restore_prefs.js */
......
...@@ -7,6 +7,11 @@ ...@@ -7,6 +7,11 @@
* @interface * @interface
*/ */
class ProgressCenter { class ProgressCenter {
/**
* Turns off sending updates when a file operation reaches 'completed' state.
* Used for testing UI that can be ephemeral otherwise.
*/
neverNotifyCompleted() {}
/** /**
* Updates the item in the progress center. * Updates the item in the progress center.
* If the item has a new ID, the item is added to the item list. * If the item has a new ID, the item is added to the item list.
......
...@@ -36,6 +36,7 @@ class MockProgressCenter { ...@@ -36,6 +36,7 @@ class MockProgressCenter {
requestCancel() {} requestCancel() {}
addPanel() {} addPanel() {}
removePanel() {} removePanel() {}
neverNotifyCompleted() {}
/** /**
* Returns the number of unique keys in |this.items|. * Returns the number of unique keys in |this.items|.
......
...@@ -28,6 +28,23 @@ class ProgressCenterImpl { ...@@ -28,6 +28,23 @@ class ProgressCenterImpl {
* @private @const {!Array<ProgressCenterPanelInterface>} * @private @const {!Array<ProgressCenterPanelInterface>}
*/ */
this.panels_ = []; this.panels_ = [];
/**
* Inhibit end of operation updates for testing.
* @private
*/
this.neverNotifyCompleted_ = false;
}
/**
* Turns off sending updates when a file operation reaches 'completed' state.
* Used for testing UI that can be ephemeral otherwise.
* @public
*/
neverNotifyCompleted() {
if (window.IN_TEST) {
this.neverNotifyCompleted_ = true;
}
} }
/** /**
...@@ -48,6 +65,10 @@ class ProgressCenterImpl { ...@@ -48,6 +65,10 @@ class ProgressCenterImpl {
} else { } else {
// Error item is not removed until user explicitly dismiss it. // Error item is not removed until user explicitly dismiss it.
if (item.state !== ProgressItemState.ERROR && index !== -1) { if (item.state !== ProgressItemState.ERROR && index !== -1) {
if (this.neverNotifyCompleted_) {
item.state = ProgressItemState.PROGRESSING;
return;
}
this.items_.splice(index, 1); this.items_.splice(index, 1);
} }
} }
......
...@@ -1005,3 +1005,10 @@ test.util.sync.recordEnumMetric = (name, value, validValues) => { ...@@ -1005,3 +1005,10 @@ test.util.sync.recordEnumMetric = (name, value, validValues) => {
test.util.sync.reload = () => { test.util.sync.reload = () => {
chrome.runtime.reload(); chrome.runtime.reload();
}; };
/**
* Tells background page progress center to never notify a completed operation.
*/
test.util.sync.progressCenterNeverNotifyCompleted = () => {
window.background.progressCenter.neverNotifyCompleted();
};
...@@ -277,9 +277,12 @@ class ProgressCenterPanel { ...@@ -277,9 +277,12 @@ class ProgressCenterPanel {
/** /**
* Timeout for hiding file operations in progress. * Timeout for hiding file operations in progress.
* @const @type {number} * @type {number}
*/ */
this.PENDING_TIME_MS_ = 2000; this.PENDING_TIME_MS_ = 2000;
if (window.IN_TEST) {
this.PENDING_TIME_MS_ = 0;
}
// Register event handlers. // Register event handlers.
element.addEventListener('click', this.onClick_.bind(this)); element.addEventListener('click', this.onClick_.bind(this));
......
...@@ -610,3 +610,47 @@ testcase.transferDeletedFile = async () => { ...@@ -610,3 +610,47 @@ testcase.transferDeletedFile = async () => {
// Check that only one line of text is shown. // Check that only one line of text is shown.
chrome.test.assertFalse(!!element.attributes['secondary-text']); chrome.test.assertFalse(!!element.attributes['secondary-text']);
}; };
/**
* Tests that transfer source/destination persists if app window is re-opened.
*/
testcase.transferInfoIsRemembered = async () => {
const entry = ENTRIES.hello;
// Open files app.
let appId = await setupAndWaitUntilReady(RootPath.DOWNLOADS, [entry], []);
// Select the file.
chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
'selectFile', appId, [entry.nameText]));
// Copy the file.
chrome.test.assertTrue(
await remoteCall.callRemoteTestUtil('execCommand', appId, ['copy']));
// Tell the background page to never finish the file copy.
await remoteCall.callRemoteTestUtil(
'progressCenterNeverNotifyCompleted', appId, []);
// Paste the file to begin a copy operation.
chrome.test.assertTrue(
await remoteCall.callRemoteTestUtil('execCommand', appId, ['paste']));
// The feedback panel should appear: record the feedback panel text.
let panel = await remoteCall.waitForElement(
appId, ['#progress-panel', 'xf-panel-item']);
const primaryText = panel.primaryText;
const secondaryText = panel.secondaryText;
// Close the Files app window.
await remoteCall.closeWindowAndWait(appId);
// Open a Files app window again.
appId = await setupAndWaitUntilReady(RootPath.DOWNLOADS);
// Check the feedback panel text is remembered.
panel = await remoteCall.waitForElement(
appId, ['#progress-panel', 'xf-panel-item']);
chrome.test.assertEq(primaryText, panel.primaryText);
chrome.test.assertEq(secondaryText, panel.secondaryText);
};
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