Commit 6fbd33d2 authored by Julian Watson's avatar Julian Watson Committed by Commit Bot

crostini: use async in page tests

Bug: None
Change-Id: I2ffbdec3ccf5fc94118e2080df159bc78869c711
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2084034
Commit-Queue: Julian Watson <juwa@google.com>
Auto-Submit: Julian Watson <juwa@google.com>
Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746232}
parent a6ba460f
...@@ -69,32 +69,28 @@ suite('CrostiniPageTests', function() { ...@@ -69,32 +69,28 @@ suite('CrostiniPageTests', function() {
assertTrue(!!crostiniPage.$$('.subpage-arrow')); assertTrue(!!crostiniPage.$$('.subpage-arrow'));
}); });
test('ButtonDisabledDuringInstall', function() { test('ButtonDisabledDuringInstall', async function() {
const button = crostiniPage.$$('#enable'); const button = crostiniPage.$$('#enable');
assertTrue(!!button); assertTrue(!!button);
return flushAsync()
.then(() => { await flushAsync();
assertFalse(button.disabled); assertFalse(button.disabled);
cr.webUIListenerCallback('crostini-installer-status-changed', true); cr.webUIListenerCallback('crostini-installer-status-changed', true);
return flushAsync();
}) await flushAsync();
.then(() => {
assertTrue(button.disabled); assertTrue(button.disabled);
cr.webUIListenerCallback( cr.webUIListenerCallback('crostini-installer-status-changed', false);
'crostini-installer-status-changed', false);
return flushAsync(); await flushAsync();
})
.then(() => {
assertFalse(button.disabled); assertFalse(button.disabled);
}); });
}); });
});
suite('SubPageDetails', function() { suite('SubPageDetails', function() {
/** @type {?SettingsCrostiniSubPageElement} */ /** @type {?SettingsCrostiniSubPageElement} */
let subpage; let subpage;
setup(function() { setup(async function() {
setCrostiniPrefs(true); setCrostiniPrefs(true);
loadTimeData.overrideValues({ loadTimeData.overrideValues({
showCrostiniExportImport: true, showCrostiniExportImport: true,
...@@ -118,7 +114,7 @@ suite('CrostiniPageTests', function() { ...@@ -118,7 +114,7 @@ suite('CrostiniPageTests', function() {
assertTrue(!!subpage); assertTrue(!!subpage);
}); });
return Promise.all([pageLoadPromise, eventPromise]); await Promise.all([pageLoadPromise, eventPromise]);
}); });
test('Sanity', function() { test('Sanity', function() {
...@@ -130,14 +126,14 @@ suite('CrostiniPageTests', function() { ...@@ -130,14 +126,14 @@ suite('CrostiniPageTests', function() {
assertTrue(!!subpage.$$('#crostini-port-forwarding')); assertTrue(!!subpage.$$('#crostini-port-forwarding'));
}); });
test('SharedPaths', function() { test('SharedPaths', async function() {
assertTrue(!!subpage.$$('#crostini-shared-paths')); assertTrue(!!subpage.$$('#crostini-shared-paths'));
subpage.$$('#crostini-shared-paths').click(); subpage.$$('#crostini-shared-paths').click();
return flushAsync().then(() => {
await flushAsync();
subpage = crostiniPage.$$('settings-crostini-shared-paths'); subpage = crostiniPage.$$('settings-crostini-shared-paths');
assertTrue(!!subpage); assertTrue(!!subpage);
}); });
});
test('ContainerUpgrade', function() { test('ContainerUpgrade', function() {
assertTrue(!!subpage.$$('#container-upgrade cr-button')); assertTrue(!!subpage.$$('#container-upgrade cr-button'));
...@@ -148,133 +144,117 @@ suite('CrostiniPageTests', function() { ...@@ -148,133 +144,117 @@ suite('CrostiniPageTests', function() {
'requestCrostiniContainerUpgradeView')); 'requestCrostiniContainerUpgradeView'));
}); });
test('ContainerUpgradeButtonDisabledOnUpgradeDialog', function() { test('ContainerUpgradeButtonDisabledOnUpgradeDialog', async function() {
const button = subpage.$$('#container-upgrade cr-button'); const button = subpage.$$('#container-upgrade cr-button');
assertTrue(!!button); assertTrue(!!button);
return flushAsync()
.then(() => { await flushAsync();
assertFalse(button.disabled); assertFalse(button.disabled);
cr.webUIListenerCallback('crostini-upgrader-status-changed', true); cr.webUIListenerCallback('crostini-upgrader-status-changed', true);
return flushAsync();
}) await flushAsync();
.then(() => {
assertTrue(button.disabled); assertTrue(button.disabled);
cr.webUIListenerCallback('crostini-upgrader-status-changed', false); cr.webUIListenerCallback('crostini-upgrader-status-changed', false);
return flushAsync();
}) await flushAsync();
.then(() => {
assertFalse(button.disabled); assertFalse(button.disabled);
}); });
});
test('ContainerUpgradeButtonDisabledOnInstall', function() { test('ContainerUpgradeButtonDisabledOnInstall', async function() {
const button = subpage.$$('#container-upgrade cr-button'); const button = subpage.$$('#container-upgrade cr-button');
assertTrue(!!button); assertTrue(!!button);
return flushAsync()
.then(() => { await flushAsync();
assertFalse(button.disabled); assertFalse(button.disabled);
cr.webUIListenerCallback('crostini-installer-status-changed', true); cr.webUIListenerCallback('crostini-installer-status-changed', true);
return flushAsync();
}) await flushAsync();
.then(() => {
assertTrue(button.disabled); assertTrue(button.disabled);
cr.webUIListenerCallback( cr.webUIListenerCallback('crostini-installer-status-changed', false);
'crostini-installer-status-changed', false);
return flushAsync(); await flushAsync();
})
.then(() => {
assertFalse(button.disabled); assertFalse(button.disabled);
}); });
});
test('Export', function() { test('Export', async function() {
assertTrue(!!subpage.$$('#crostini-export-import')); assertTrue(!!subpage.$$('#crostini-export-import'));
subpage.$$('#crostini-export-import').click(); subpage.$$('#crostini-export-import').click();
return flushAsync().then(() => {
await flushAsync();
subpage = crostiniPage.$$('settings-crostini-export-import'); subpage = crostiniPage.$$('settings-crostini-export-import');
assertTrue(!!subpage.$$('#export cr-button')); assertTrue(!!subpage.$$('#export cr-button'));
subpage.$$('#export cr-button').click(); subpage.$$('#export cr-button').click();
assertEquals( assertEquals(
1, crostiniBrowserProxy.getCallCount('exportCrostiniContainer')); 1, crostiniBrowserProxy.getCallCount('exportCrostiniContainer'));
}); });
});
test('Import', function() { test('Import', async function() {
assertTrue(!!subpage.$$('#crostini-export-import')); assertTrue(!!subpage.$$('#crostini-export-import'));
subpage.$$('#crostini-export-import').click(); subpage.$$('#crostini-export-import').click();
return flushAsync()
.then(() => { await flushAsync();
subpage = crostiniPage.$$('settings-crostini-export-import'); subpage = crostiniPage.$$('settings-crostini-export-import');
subpage.$$('#import cr-button').click(); subpage.$$('#import cr-button').click();
return flushAsync();
}) await flushAsync();
.then(() => { subpage = subpage.$$('settings-crostini-import-confirmation-dialog');
subpage =
subpage.$$('settings-crostini-import-confirmation-dialog');
subpage.$$('cr-dialog cr-button[id="continue"]').click(); subpage.$$('cr-dialog cr-button[id="continue"]').click();
assertEquals( assertEquals(
1, 1, crostiniBrowserProxy.getCallCount('importCrostiniContainer'));
crostiniBrowserProxy.getCallCount('importCrostiniContainer'));
});
}); });
test('ExportImportButtonsGetDisabledOnOperationStatus', function() { test('ExportImportButtonsGetDisabledOnOperationStatus', async function() {
assertTrue(!!subpage.$$('#crostini-export-import')); assertTrue(!!subpage.$$('#crostini-export-import'));
subpage.$$('#crostini-export-import').click(); subpage.$$('#crostini-export-import').click();
return flushAsync()
.then(() => { await flushAsync();
subpage = crostiniPage.$$('settings-crostini-export-import'); subpage = crostiniPage.$$('settings-crostini-export-import');
assertFalse(subpage.$$('#export cr-button').disabled); assertFalse(subpage.$$('#export cr-button').disabled);
assertFalse(subpage.$$('#import cr-button').disabled); assertFalse(subpage.$$('#import cr-button').disabled);
cr.webUIListenerCallback( cr.webUIListenerCallback(
'crostini-export-import-operation-status-changed', true); 'crostini-export-import-operation-status-changed', true);
return flushAsync();
}) await flushAsync();
.then(() => {
subpage = crostiniPage.$$('settings-crostini-export-import'); subpage = crostiniPage.$$('settings-crostini-export-import');
assertTrue(subpage.$$('#export cr-button').disabled); assertTrue(subpage.$$('#export cr-button').disabled);
assertTrue(subpage.$$('#import cr-button').disabled); assertTrue(subpage.$$('#import cr-button').disabled);
cr.webUIListenerCallback( cr.webUIListenerCallback(
'crostini-export-import-operation-status-changed', false); 'crostini-export-import-operation-status-changed', false);
return flushAsync();
}) await flushAsync();
.then(() => {
subpage = crostiniPage.$$('settings-crostini-export-import'); subpage = crostiniPage.$$('settings-crostini-export-import');
assertFalse(subpage.$$('#export cr-button').disabled); assertFalse(subpage.$$('#export cr-button').disabled);
assertFalse(subpage.$$('#import cr-button').disabled); assertFalse(subpage.$$('#import cr-button').disabled);
}); });
});
test('ExportImportButtonsDisabledOnWhenInstallingCrostini', function() { test(
'ExportImportButtonsDisabledOnWhenInstallingCrostini',
async function() {
assertTrue(!!subpage.$$('#crostini-export-import')); assertTrue(!!subpage.$$('#crostini-export-import'));
subpage.$$('#crostini-export-import').click(); subpage.$$('#crostini-export-import').click();
return flushAsync()
.then(() => { await flushAsync();
subpage = crostiniPage.$$('settings-crostini-export-import'); subpage = crostiniPage.$$('settings-crostini-export-import');
assertFalse(subpage.$$('#export cr-button').disabled); assertFalse(subpage.$$('#export cr-button').disabled);
assertFalse(subpage.$$('#import cr-button').disabled); assertFalse(subpage.$$('#import cr-button').disabled);
cr.webUIListenerCallback('crostini-installer-status-changed', true); cr.webUIListenerCallback('crostini-installer-status-changed', true);
return flushAsync();
}) await flushAsync();
.then(() => {
subpage = crostiniPage.$$('settings-crostini-export-import'); subpage = crostiniPage.$$('settings-crostini-export-import');
assertTrue(subpage.$$('#export cr-button').disabled); assertTrue(subpage.$$('#export cr-button').disabled);
assertTrue(subpage.$$('#import cr-button').disabled); assertTrue(subpage.$$('#import cr-button').disabled);
cr.webUIListenerCallback( cr.webUIListenerCallback('crostini-installer-status-changed', false);
'crostini-installer-status-changed', false);
return flushAsync(); await flushAsync();
})
.then(() => {
subpage = crostiniPage.$$('settings-crostini-export-import'); subpage = crostiniPage.$$('settings-crostini-export-import');
assertFalse(subpage.$$('#export cr-button').disabled); assertFalse(subpage.$$('#export cr-button').disabled);
assertFalse(subpage.$$('#import cr-button').disabled); assertFalse(subpage.$$('#import cr-button').disabled);
}); });
});
suite('SubPagePortForwarding', function() { suite('SubPagePortForwarding', function() {
/** @type {?SettingsCrostiniPortForwarding} */ /** @type {?SettingsCrostiniPortForwarding} */
let subpage; let subpage;
setup(function() { setup(async function() {
setCrostiniPrefs(true, { setCrostiniPrefs(true, {
forwardedPorts: [ forwardedPorts: [
{ {
...@@ -292,17 +272,14 @@ suite('CrostiniPageTests', function() { ...@@ -292,17 +272,14 @@ suite('CrostiniPageTests', function() {
] ]
}); });
return flushAsync() await flushAsync();
.then(() => {
settings.Router.getInstance().navigateTo( settings.Router.getInstance().navigateTo(
settings.routes.CROSTINI_PORT_FORWARDING); settings.routes.CROSTINI_PORT_FORWARDING);
return flushAsync();
}) await flushAsync();
.then(() => {
subpage = crostiniPage.$$('settings-crostini-port-forwarding'); subpage = crostiniPage.$$('settings-crostini-port-forwarding');
assertTrue(!!subpage); assertTrue(!!subpage);
}); });
});
test('Forwarded ports are shown', function() { test('Forwarded ports are shown', function() {
// Extra list item for the titles. // Extra list item for the titles.
...@@ -310,14 +287,12 @@ suite('CrostiniPageTests', function() { ...@@ -310,14 +287,12 @@ suite('CrostiniPageTests', function() {
3, subpage.shadowRoot.querySelectorAll('.list-item').length); 3, subpage.shadowRoot.querySelectorAll('.list-item').length);
}); });
test('AddPortSuccess', function() { test('AddPortSuccess', async function() {
return flushAsync() await flushAsync();
.then(() => {
subpage = crostiniPage.$$('settings-crostini-port-forwarding'); subpage = crostiniPage.$$('settings-crostini-port-forwarding');
subpage.$$('#addPort cr-button').click(); subpage.$$('#addPort cr-button').click();
return flushAsync();
}) await flushAsync();
.then(() => {
subpage = subpage.$$('settings-crostini-add-port-dialog'); subpage = subpage.$$('settings-crostini-add-port-dialog');
const portNumberInput = subpage.$$('#portNumberInput'); const portNumberInput = subpage.$$('#portNumberInput');
portNumberInput.value = '5000'; portNumberInput.value = '5000';
...@@ -325,19 +300,15 @@ suite('CrostiniPageTests', function() { ...@@ -325,19 +300,15 @@ suite('CrostiniPageTests', function() {
portLabelInput.value = 'Some Label'; portLabelInput.value = 'Some Label';
subpage.$$('cr-dialog cr-button[id="continue"]').click(); subpage.$$('cr-dialog cr-button[id="continue"]').click();
assertEquals( assertEquals(
1, 1, crostiniBrowserProxy.getCallCount('addCrostiniPortForward'));
crostiniBrowserProxy.getCallCount('addCrostiniPortForward'));
});
}); });
test('AddPortFail', function() { test('AddPortFail', async function() {
return flushAsync() await flushAsync();
.then(() => {
subpage = crostiniPage.$$('settings-crostini-port-forwarding'); subpage = crostiniPage.$$('settings-crostini-port-forwarding');
subpage.$$('#addPort cr-button').click(); subpage.$$('#addPort cr-button').click();
return flushAsync();
}) await flushAsync();
.then(() => {
subpage = subpage.$$('settings-crostini-add-port-dialog'); subpage = subpage.$$('settings-crostini-add-port-dialog');
const portNumberInput = subpage.$$('#portNumberInput'); const portNumberInput = subpage.$$('#portNumberInput');
portNumberInput.value = 'INVALID_PORT_NUMBER'; portNumberInput.value = 'INVALID_PORT_NUMBER';
...@@ -345,106 +316,92 @@ suite('CrostiniPageTests', function() { ...@@ -345,106 +316,92 @@ suite('CrostiniPageTests', function() {
portLabelInput.value = 'Some Label'; portLabelInput.value = 'Some Label';
subpage.$$('cr-dialog cr-button[id="continue"]').click(); subpage.$$('cr-dialog cr-button[id="continue"]').click();
assertEquals( assertEquals(
0, 0, crostiniBrowserProxy.getCallCount('addCrostiniPortForward'));
crostiniBrowserProxy.getCallCount('addCrostiniPortForward'));
portNumberInput.value = '65536'; portNumberInput.value = '65536';
subpage.$$('cr-dialog cr-button[id="continue"]').click(); subpage.$$('cr-dialog cr-button[id="continue"]').click();
assertEquals( assertEquals(
0, 0, crostiniBrowserProxy.getCallCount('addCrostiniPortForward'));
crostiniBrowserProxy.getCallCount('addCrostiniPortForward'));
portNumberInput.value = '65535'; portNumberInput.value = '65535';
subpage.$$('cr-dialog cr-button[id="continue"]').click(); subpage.$$('cr-dialog cr-button[id="continue"]').click();
assertEquals( assertEquals(
1, 1, crostiniBrowserProxy.getCallCount('addCrostiniPortForward'));
crostiniBrowserProxy.getCallCount('addCrostiniPortForward'));
});
}); });
test('AddPortCancel', function() { test('AddPortCancel', async function() {
return flushAsync() await flushAsync();
.then(() => {
subpage = crostiniPage.$$('settings-crostini-port-forwarding'); subpage = crostiniPage.$$('settings-crostini-port-forwarding');
subpage.$$('#addPort cr-button').click(); subpage.$$('#addPort cr-button').click();
return flushAsync();
}) await flushAsync();
.then(() => {
subpage = subpage.$$('settings-crostini-add-port-dialog'); subpage = subpage.$$('settings-crostini-add-port-dialog');
subpage.$$('cr-dialog cr-button[id="cancel"]').click(); subpage.$$('cr-dialog cr-button[id="cancel"]').click();
return flushAsync();
})
.then(() => { await flushAsync();
subpage = crostiniPage.$$('settings-crostini-port-forwarding'); subpage = crostiniPage.$$('settings-crostini-port-forwarding');
assertTrue(!!subpage); assertTrue(!!subpage);
}); });
}); });
});
test('Remove', function() { test('Remove', async function() {
assertTrue(!!subpage.$$('#remove cr-button')); assertTrue(!!subpage.$$('#remove cr-button'));
subpage.$$('#remove cr-button').click(); subpage.$$('#remove cr-button').click();
assertEquals( assertEquals(
1, crostiniBrowserProxy.getCallCount('requestRemoveCrostini')); 1, crostiniBrowserProxy.getCallCount('requestRemoveCrostini'));
setCrostiniPrefs(false); setCrostiniPrefs(false);
return test_util.eventToPromise('popstate', window).then(function() {
await test_util.eventToPromise('popstate', window);
assertEquals( assertEquals(
settings.Router.getInstance().getCurrentRoute(), settings.Router.getInstance().getCurrentRoute(),
settings.routes.CROSTINI); settings.routes.CROSTINI);
assertTrue(!!crostiniPage.$$('#enable')); assertTrue(!!crostiniPage.$$('#enable'));
}); });
});
test('RemoveHidden', function() { test('RemoveHidden', async function() {
// Elements are not destroyed when a dom-if stops being shown, but we can // Elements are not destroyed when a dom-if stops being shown, but we
// check if their rendered width is non-zero. This should be resilient // can check if their rendered width is non-zero. This should be
// against most formatting changes, since we're not relying on them having // resilient against most formatting changes, since we're not relying on
// any exact size, or on Polymer using any particular means of hiding // them having any exact size, or on Polymer using any particular means
// elements. // of hiding elements.
assertTrue(!!subpage.shadowRoot.querySelector('#remove').clientWidth); assertTrue(!!subpage.shadowRoot.querySelector('#remove').clientWidth);
cr.webUIListenerCallback('crostini-installer-status-changed', true); cr.webUIListenerCallback('crostini-installer-status-changed', true);
return flushAsync()
.then(() => { await flushAsync();
assertFalse( assertFalse(!!subpage.shadowRoot.querySelector('#remove').clientWidth);
!!subpage.shadowRoot.querySelector('#remove').clientWidth); cr.webUIListenerCallback('crostini-installer-status-changed', false);
cr.webUIListenerCallback(
'crostini-installer-status-changed', false); await flushAsync();
return flushAsync(); assertTrue(!!subpage.shadowRoot.querySelector('#remove').clientWidth);
})
.then(() => {
assertTrue(
!!subpage.shadowRoot.querySelector('#remove').clientWidth);
});
}); });
test('HideOnDisable', function() { test('HideOnDisable', async function() {
assertEquals( assertEquals(
settings.Router.getInstance().getCurrentRoute(), settings.Router.getInstance().getCurrentRoute(),
settings.routes.CROSTINI_DETAILS); settings.routes.CROSTINI_DETAILS);
setCrostiniPrefs(false); setCrostiniPrefs(false);
return test_util.eventToPromise('popstate', window).then(function() {
await test_util.eventToPromise('popstate', window);
assertEquals( assertEquals(
settings.Router.getInstance().getCurrentRoute(), settings.Router.getInstance().getCurrentRoute(),
settings.routes.CROSTINI); settings.routes.CROSTINI);
}); });
}); });
});
suite('SubPageSharedPaths', function() { suite('SubPageSharedPaths', function() {
let subpage; let subpage;
setup(function() { setup(async function() {
setCrostiniPrefs( setCrostiniPrefs(
true, {sharedPaths: {path1: ['termina'], path2: ['termina']}}); true, {sharedPaths: {path1: ['termina'], path2: ['termina']}});
return flushAsync()
.then(() => { await flushAsync();
settings.Router.getInstance().navigateTo( settings.Router.getInstance().navigateTo(
settings.routes.CROSTINI_SHARED_PATHS); settings.routes.CROSTINI_SHARED_PATHS);
return flushAsync();
}) await flushAsync();
.then(() => {
subpage = crostiniPage.$$('settings-crostini-shared-paths'); subpage = crostiniPage.$$('settings-crostini-shared-paths');
assertTrue(!!subpage); assertTrue(!!subpage);
}); });
});
test('Sanity', function() { test('Sanity', function() {
assertEquals( assertEquals(
...@@ -452,55 +409,54 @@ suite('CrostiniPageTests', function() { ...@@ -452,55 +409,54 @@ suite('CrostiniPageTests', function() {
assertEquals(2, subpage.shadowRoot.querySelectorAll('.list-item').length); assertEquals(2, subpage.shadowRoot.querySelectorAll('.list-item').length);
}); });
test('Remove', function() { test('Remove', async function() {
assertFalse(subpage.$.crostiniInstructionsRemove.hidden); assertFalse(subpage.$.crostiniInstructionsRemove.hidden);
assertFalse(subpage.$.crostiniList.hidden); assertFalse(subpage.$.crostiniList.hidden);
assertTrue(subpage.$.crostiniListEmpty.hidden); assertTrue(subpage.$.crostiniListEmpty.hidden);
assertTrue(!!subpage.$$('.list-item cr-icon-button')); assertTrue(!!subpage.$$('.list-item cr-icon-button'));
{
// Remove first shared path, still one left. // Remove first shared path, still one left.
subpage.$$('.list-item cr-icon-button').click(); subpage.$$('.list-item cr-icon-button').click();
return crostiniBrowserProxy.whenCalled('removeCrostiniSharedPath') const [vmName, path] =
.then(([vmName, path]) => { await crostiniBrowserProxy.whenCalled('removeCrostiniSharedPath');
assertEquals('termina', vmName); assertEquals('termina', vmName);
assertEquals('path1', path); assertEquals('path1', path);
setCrostiniPrefs(true, {sharedPaths: {path2: ['termina']}}); setCrostiniPrefs(true, {sharedPaths: {path2: ['termina']}});
return flushAsync(); }
})
.then(() => { await flushAsync();
Polymer.dom.flush(); Polymer.dom.flush();
assertEquals( assertEquals(1, subpage.shadowRoot.querySelectorAll('.list-item').length);
1, subpage.shadowRoot.querySelectorAll('.list-item').length);
assertFalse(subpage.$.crostiniInstructionsRemove.hidden); assertFalse(subpage.$.crostiniInstructionsRemove.hidden);
{
// Remove remaining shared path, none left. // Remove remaining shared path, none left.
crostiniBrowserProxy.resetResolver('removeCrostiniSharedPath'); crostiniBrowserProxy.resetResolver('removeCrostiniSharedPath');
subpage.$$('.list-item cr-icon-button').click(); subpage.$$('.list-item cr-icon-button').click();
return crostiniBrowserProxy.whenCalled('removeCrostiniSharedPath'); const [vmName, path] =
}) await crostiniBrowserProxy.whenCalled('removeCrostiniSharedPath');
.then(([vmName, path]) => {
assertEquals('termina', vmName); assertEquals('termina', vmName);
assertEquals('path2', path); assertEquals('path2', path);
setCrostiniPrefs(true, {sharedPaths: {}}); setCrostiniPrefs(true, {sharedPaths: {}});
return flushAsync(); }
})
.then(() => { await flushAsync();
Polymer.dom.flush(); Polymer.dom.flush();
assertEquals( assertEquals(0, subpage.shadowRoot.querySelectorAll('.list-item').length);
0, subpage.shadowRoot.querySelectorAll('.list-item').length);
// Verify remove instructions are hidden, and empty list message // Verify remove instructions are hidden, and empty list message
// is shown. // is shown.
assertTrue(subpage.$.crostiniInstructionsRemove.hidden); assertTrue(subpage.$.crostiniInstructionsRemove.hidden);
assertTrue(subpage.$.crostiniList.hidden); assertTrue(subpage.$.crostiniList.hidden);
assertFalse(subpage.$.crostiniListEmpty.hidden); assertFalse(subpage.$.crostiniListEmpty.hidden);
}); });
});
test('RemoveFailedRetry', function() { test('RemoveFailedRetry', async function() {
// Remove shared path fails. // Remove shared path fails.
crostiniBrowserProxy.removeSharedPathResult = false; crostiniBrowserProxy.removeSharedPathResult = false;
subpage.$$('.list-item cr-icon-button').click(); subpage.$$('.list-item cr-icon-button').click();
return crostiniBrowserProxy.whenCalled('removeCrostiniSharedPath')
.then(() => { await crostiniBrowserProxy.whenCalled('removeCrostiniSharedPath');
Polymer.dom.flush(); Polymer.dom.flush();
assertTrue(subpage.$$('#removeSharedPathFailedDialog').open); assertTrue(subpage.$$('#removeSharedPathFailedDialog').open);
...@@ -510,18 +466,15 @@ suite('CrostiniPageTests', function() { ...@@ -510,18 +466,15 @@ suite('CrostiniPageTests', function() {
subpage.$$('#removeSharedPathFailedDialog') subpage.$$('#removeSharedPathFailedDialog')
.querySelector('.action-button') .querySelector('.action-button')
.click(); .click();
return crostiniBrowserProxy.whenCalled('removeCrostiniSharedPath'); await crostiniBrowserProxy.whenCalled('removeCrostiniSharedPath');
})
.then(() => {
assertFalse(!!subpage.$$('#removeSharedPathFailedDialog')); assertFalse(!!subpage.$$('#removeSharedPathFailedDialog'));
}); });
}); });
});
suite('SubPageSharedUsbDevices', function() { suite('SubPageSharedUsbDevices', function() {
let subpage; let subpage;
setup(function() { setup(async function() {
setCrostiniPrefs(true, { setCrostiniPrefs(true, {
sharedUsbDevices: [ sharedUsbDevices: [
{shared: true, guid: '0001', name: 'usb_dev1'}, {shared: true, guid: '0001', name: 'usb_dev1'},
...@@ -530,32 +483,28 @@ suite('CrostiniPageTests', function() { ...@@ -530,32 +483,28 @@ suite('CrostiniPageTests', function() {
] ]
}); });
return flushAsync() await flushAsync();
.then(() => {
settings.Router.getInstance().navigateTo( settings.Router.getInstance().navigateTo(
settings.routes.CROSTINI_SHARED_USB_DEVICES); settings.routes.CROSTINI_SHARED_USB_DEVICES);
return flushAsync();
}) await flushAsync();
.then(() => {
subpage = crostiniPage.$$('settings-crostini-shared-usb-devices'); subpage = crostiniPage.$$('settings-crostini-shared-usb-devices');
assertTrue(!!subpage); assertTrue(!!subpage);
}); });
});
test('USB devices are shown', function() { test('USB devices are shown', function() {
assertEquals(3, subpage.shadowRoot.querySelectorAll('.toggle').length); assertEquals(3, subpage.shadowRoot.querySelectorAll('.toggle').length);
}); });
test('USB shared state is updated by toggling', function() { test('USB shared state is updated by toggling', async function() {
assertTrue(!!subpage.$$('.toggle')); assertTrue(!!subpage.$$('.toggle'));
subpage.$$('.toggle').click(); subpage.$$('.toggle').click();
return flushAsync()
.then(() => { await flushAsync();
Polymer.dom.flush(); Polymer.dom.flush();
return crostiniBrowserProxy.whenCalled(
'setCrostiniUsbDeviceShared'); const args =
}) await crostiniBrowserProxy.whenCalled('setCrostiniUsbDeviceShared');
.then(args => {
assertEquals('0001', args[0]); assertEquals('0001', args[0]);
assertEquals(false, args[1]); assertEquals(false, args[1]);
...@@ -564,9 +513,7 @@ suite('CrostiniPageTests', function() { ...@@ -564,9 +513,7 @@ suite('CrostiniPageTests', function() {
{shared: true, guid: '0001', name: 'usb_dev1'}, {shared: true, guid: '0001', name: 'usb_dev1'},
]); ]);
Polymer.dom.flush(); Polymer.dom.flush();
assertEquals( assertEquals(1, subpage.shadowRoot.querySelectorAll('.toggle').length);
1, subpage.shadowRoot.querySelectorAll('.toggle').length);
});
}); });
}); });
}); });
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