Commit 1a084a09 authored by Alex Danilo's avatar Alex Danilo Committed by Commit Bot

Extend unit test for all feedback panel item types

Extends panel item testing for all remaining panel types.

Exercises the signal callback handler for each panel type to verify
correct operation.

Bug: 1009318
Tests: browser_tests --gtest_filter="FileManagerJsTest.FilesDisplayPanel"
Change-Id: Iae4c25bd7707d7a6d869e5f81a5e0963b3d73307
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1865739
Commit-Queue: Alex Danilo <adanilo@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707693}
parent 7e5fd0e7
...@@ -55,22 +55,76 @@ async function testDisplayPanelChangingPanelTypes(done) { ...@@ -55,22 +55,76 @@ async function testDisplayPanelChangingPanelTypes(done) {
const panelItem = displayPanel.addPanelItem('testpanel'); const panelItem = displayPanel.addPanelItem('testpanel');
panelItem.panelType = panelItem.panelTypeProgress; panelItem.panelType = panelItem.panelTypeProgress;
// Setup the panel item signal (click) callback.
/** @type {?string} */
let signal = null;
panelItem.signalCallback = (name) => {
assert(typeof name === 'string');
signal = name;
};
// Verify the panel item indicator is progress. // Verify the panel item indicator is progress.
assertTrue( assertEquals(
panelItem.indicator === 'progress', panelItem.indicator, 'progress',
'Wrong panel indicator, got ' + panelItem.indicator); 'Wrong panel indicator, got ' + panelItem.indicator);
// Check cancel signal from the panel from a click.
/** @type {!HTMLElement} */
const cancel = assert(panelItem.secondaryButton);
cancel.click();
assertEquals(
signal, 'cancel', 'Expected signal name "cancel". Got ' + signal);
// Change the panel item to an error panel. // Change the panel item to an error panel.
panelItem.panelType = panelItem.panelTypeError; panelItem.panelType = panelItem.panelTypeError;
// Verify the panel item indicator is set to error. // Verify the panel item indicator is set to error.
assertTrue( assertEquals(
panelItem.indicator === 'status', panelItem.indicator, 'status',
'Wrong panel indicator, got ' + panelItem.indicator);
assertEquals(
panelItem.status, 'failure',
'Wrong panel status, got ' + panelItem.status);
// Check dismiss signal from the panel from a click.
/** @type {!HTMLElement} */
let dismiss = assert(panelItem.secondaryButton);
dismiss.click();
assertEquals(
signal, 'dismiss', 'Expected signal name "dismiss". Got ' + signal);
// Change the panel type to a done panel.
panelItem.panelType = panelItem.panelTypeDone;
// Verify the panel item indicator is set to done.
assertEquals(
panelItem.indicator, 'status',
'Wrong panel indicator, got ' + panelItem.indicator); 'Wrong panel indicator, got ' + panelItem.indicator);
assertTrue( assertEquals(
panelItem.status === 'failure', panelItem.status, 'success',
'Wrong panel status, got ' + panelItem.status); 'Wrong panel status, got ' + panelItem.status);
// Check the dimiss signal from the panel from a click.
signal = 'none';
dismiss = assert(panelItem.primaryButton);
dismiss.click();
assertEquals(
signal, 'dismiss', 'Expected signal name "dismiss". Got ' + signal);
// Change the type to a summary panel.
panelItem.panelType = panelItem.panelTypeSummary;
// Verify the panel item indicator is largeprogress.
assertEquals(
panelItem.indicator, 'largeprogress',
'Wrong panel indicator, got ' + panelItem.indicator);
// Check no signal emitted from the summary panel from a click.
const expand = assert(panelItem.primaryButton);
signal = 'none';
expand.click();
assertEquals(signal, 'none', 'Expected no signal. Got ' + signal);
done(); done();
} }
...@@ -101,7 +155,7 @@ async function testFilesDisplayPanelSummaryPanel(done) { ...@@ -101,7 +155,7 @@ async function testFilesDisplayPanelSummaryPanel(done) {
// Confirm multiple progress panels cause creation of a summary panel. // Confirm multiple progress panels cause creation of a summary panel.
const summaryContainer = displayPanel.shadowRoot.querySelector('#summary'); const summaryContainer = displayPanel.shadowRoot.querySelector('#summary');
let summaryPanelItem = summaryContainer.querySelector('xf-panel-item'); let summaryPanelItem = summaryContainer.querySelector('xf-panel-item');
assertTrue(summaryPanelItem.panelType === summaryPanelItem.panelTypeSummary); assertEquals(summaryPanelItem.panelType, summaryPanelItem.panelTypeSummary);
// Confirm the expected height of the summary panel. // Confirm the expected height of the summary panel.
bounds = summaryPanelItem.getBoundingClientRect(); bounds = summaryPanelItem.getBoundingClientRect();
...@@ -119,10 +173,10 @@ async function testFilesDisplayPanelSummaryPanel(done) { ...@@ -119,10 +173,10 @@ async function testFilesDisplayPanelSummaryPanel(done) {
let panelToRemove = displayPanel.findPanelItemById('testpanel1'); let panelToRemove = displayPanel.findPanelItemById('testpanel1');
displayPanel.removePanelItem(panelToRemove); displayPanel.removePanelItem(panelToRemove);
summaryPanelItem = summaryContainer.querySelector('xf-panel-item'); summaryPanelItem = summaryContainer.querySelector('xf-panel-item');
assertTrue(summaryPanelItem === null); assertEquals(summaryPanelItem, null);
// Confirm the reference to the removed panel item is gone. // Confirm the reference to the removed panel item is gone.
assertTrue(displayPanel.findPanelItemById('testpanel1') === null); assertEquals(displayPanel.findPanelItemById('testpanel1'), null);
// Add another panel item and confirm the expanded state persists by // Add another panel item and confirm the expanded state persists by
// checking the panel container is not hidden and there is a summary panel. // checking the panel container is not hidden and there is a summary panel.
...@@ -130,7 +184,7 @@ async function testFilesDisplayPanelSummaryPanel(done) { ...@@ -130,7 +184,7 @@ async function testFilesDisplayPanelSummaryPanel(done) {
progressPanel.panelType = progressPanel.panelTypeProgress; progressPanel.panelType = progressPanel.panelTypeProgress;
assertFalse(panelContainer.hasAttribute('hidden')); assertFalse(panelContainer.hasAttribute('hidden'));
summaryPanelItem = summaryContainer.querySelector('xf-panel-item'); summaryPanelItem = summaryContainer.querySelector('xf-panel-item');
assertTrue(summaryPanelItem.panelType === summaryPanelItem.panelTypeSummary); assertEquals(summaryPanelItem.panelType, summaryPanelItem.panelTypeSummary);
done(); done();
} }
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