Commit f04dd9c4 authored by Xiyuan Xia's avatar Xiyuan Xia Committed by Commit Bot

Fix display smoothness autotestPrivate api test flake (round 2)

It turns out the problem is not with the display smoothness
test itself. It is introduced by my CL:2132683 that attempts
to fix acceleratorTest. It wraps chrome.test.succeed() in a
setInterval callback. On slow bots, chrome.test.succeed() could
be called more than once. As a result, tests could be invoked
prematurely before the previous one finishes. This causes
the problem for startSmoothnessTrackingExplicitDisplay because
only one tracking per display is allowed hence it could only
run after the previous startSmoothnessTracking finishes.

This CL changes to setTimeout instead of setInterval to avoid
checking test end condition multiple times during getAppWindowList
call. It also moves chrome.test.succeed() out of timeout callback
to ensure it is only called once.

Bug: 1098886, 1108515
Change-Id: I8c04dc4d66f54bb28e8f3d407941083e89796b6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2316410Reviewed-by: default avatarJun Mukai <mukai@chromium.org>
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791667}
parent 33340286
...@@ -759,21 +759,29 @@ var defaultTests = [ ...@@ -759,21 +759,29 @@ var defaultTests = [
newAccelerator('w', false /* shift */, true /* control */); newAccelerator('w', false /* shift */, true /* control */);
chrome.autotestPrivate.activateAccelerator( chrome.autotestPrivate.activateAccelerator(
closeWindow, closeWindow,
function(success) { async function(success) {
chrome.test.assertTrue(success); chrome.test.assertTrue(success);
// Actual window close might happen sometime later after the // Actual window close might happen sometime later after the
// accelerator. So keep trying until window count drops to 1. // accelerator. So keep trying until window count drops to 1.
var timer = window.setInterval(() => { await new Promise(resolve => {
chrome.autotestPrivate.getAppWindowList(function(list) { function check() {
chrome.test.assertNoLastError(); chrome.autotestPrivate.getAppWindowList(function(list) {
chrome.test.assertNoLastError();
if (list.length != 1) if (list.length == 1) {
return; resolve();
return;
}
window.clearInterval(timer); window.setTimeout(check, 100);
chrome.test.succeed(); });
}); };
}, 100);
check();
});
chrome.test.succeed();
}); });
}); });
}); });
......
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