Commit a5c06556 authored by David Munro's avatar David Munro Committed by Commit Bot

crostini: Fix 2/3 of the the Crostini settings test flakes

Sometimes (when the system is under sufficient load, tests are running
slow enough, the system is tickled the right way by swarming, and other
things I haven't figured out yet), there is a chance that the Crostini
Settings Subpage will be attached to the DOM (or at least, the attached
method gets fired) *before* the SubPageDetails suite runs its setup to
navigate to the page. When this happens the request for crostini
installer status (fired by the subpage details attached event) happens
before we attach a listener in the suite setup, so our listener hangs
forever for a message that will never arrive.
That behaviour isn't actually required for the tests to run so move the
check from the suite setup into its own test, and check in a way that if
it fails it fails, instead of hanging forever.

Bug: chromium:1082575
Test: Browser tests
Change-Id: I590a0aab8b6e4e0bfba2497a1706667201dfa3b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2274404Reviewed-by: default avatarNicholas Verne <nverne@chromium.org>
Reviewed-by: default avatarDaniel Ng <danielng@google.com>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Commit-Queue: David Munro <davidmunro@google.com>
Cr-Commit-Position: refs/heads/master@{#783805}
parent 100d807e
...@@ -105,24 +105,17 @@ suite('CrostiniPageTests', function() { ...@@ -105,24 +105,17 @@ suite('CrostiniPageTests', function() {
showCrostiniDiskResize: true, showCrostiniDiskResize: true,
}); });
const eventPromise = new Promise((resolve) => { console.log('Navigating');
const v = cr.addWebUIListener(
'crostini-installer-status-changed', () => {
resolve(v);
});
}).then((v) => {
assertTrue(cr.removeWebUIListener(v));
});
settings.Router.getInstance().navigateTo(settings.routes.CROSTINI); settings.Router.getInstance().navigateTo(settings.routes.CROSTINI);
console.log('Clicking');
crostiniPage.$$('#crostini').click(); crostiniPage.$$('#crostini').click();
const pageLoadPromise = test_util.flushTasks().then(() => { console.log('Flushing page load');
subpage = crostiniPage.$$('settings-crostini-subpage'); await test_util.flushTasks();
assertTrue(!!subpage); subpage = crostiniPage.$$('settings-crostini-subpage');
}); assertTrue(!!subpage);
console.log('pageLoadPromise done');
await Promise.all([pageLoadPromise, eventPromise]);
}); });
suite('SubPageDefault', function() { suite('SubPageDefault', function() {
...@@ -187,6 +180,14 @@ suite('CrostiniPageTests', function() { ...@@ -187,6 +180,14 @@ suite('CrostiniPageTests', function() {
assertFalse(button.disabled); assertFalse(button.disabled);
}); });
test('InstallerStatusQueriedOnAttach', async function() {
// We navigated the page during setup, so this request should've been
// triggered by here.
assertTrue(
crostiniBrowserProxy.getCallCount(
'requestCrostiniInstallerStatus') >= 1);
});
test('Export', async 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();
......
...@@ -31,6 +31,7 @@ class TestCrostiniBrowserProxy extends TestBrowserProxy { ...@@ -31,6 +31,7 @@ class TestCrostiniBrowserProxy extends TestBrowserProxy {
'shutdownCrostini', 'shutdownCrostini',
'setCrostiniMicSharingEnabled', 'setCrostiniMicSharingEnabled',
'getCrostiniMicSharingEnabled', 'getCrostiniMicSharingEnabled',
'requestCrostiniInstallerStatus',
]); ]);
this.sharedUsbDevices = []; this.sharedUsbDevices = [];
this.removeSharedPathResult = true; this.removeSharedPathResult = true;
...@@ -124,6 +125,7 @@ class TestCrostiniBrowserProxy extends TestBrowserProxy { ...@@ -124,6 +125,7 @@ class TestCrostiniBrowserProxy extends TestBrowserProxy {
/** @override */ /** @override */
requestCrostiniInstallerStatus() { requestCrostiniInstallerStatus() {
this.methodCalled('requestCrostiniInstallerStatus');
cr.webUIListenerCallback('crostini-installer-status-changed', false); cr.webUIListenerCallback('crostini-installer-status-changed', false);
} }
......
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