Commit 0b03ff26 authored by James Cook's avatar James Cook Committed by Commit Bot

Attempt to de-flake SetTimeDialogBrowserTest.All

A change for supervised users added a JS-to-C++ validation step when
closing the dialog, but the tests were not always waiting for the
appropriate browser proxy calls.

Bug: 1043598
Change-Id: I1f6ec812526a4e8f08427ce1b5605ea5c4340ba5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2036358Reviewed-by: default avatarAga Wronska <agawronska@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737997}
parent 0cee5a5b
......@@ -46,7 +46,6 @@ suite('SetTimeDialog', function() {
/** @override */
doneClicked() {
this.methodCalled('doneClicked');
cr.webUIListenerCallback('validation-complete');
}
}
......@@ -96,7 +95,7 @@ suite('SetTimeDialog', function() {
assertLE(now, maxDate);
});
test('SetDate', () => {
test('SetDate', async () => {
const dateInput = setTimeElement.$$('#dateInput');
assertTrue(!!dateInput);
......@@ -107,14 +106,16 @@ suite('SetTimeDialog', function() {
dateInput.valueAsDate = nextWeek;
setTimeElement.$$('#doneButton').click();
// The browser validates the change.
await testBrowserProxy.whenCalled('doneClicked');
cr.webUIListenerCallback('validation-complete');
// Verify the page sends a request to move time forward.
return testBrowserProxy.whenCalled('setTimeInSeconds')
.then(timeInSeconds => {
const timeInSeconds = await testBrowserProxy.whenCalled('setTimeInSeconds');
const todaySeconds = today.getTime() / 1000;
// The exact value isn't important (it depends on the current time).
assertGT(timeInSeconds, todaySeconds);
});
});
test('Revert invalid date on blur', () => {
const dateInput = setTimeElement.$$('#dateInput');
......@@ -138,7 +139,7 @@ suite('SetTimeDialog', function() {
expectEquals('Asia/Seoul', timezoneSelect.value);
});
test('SetDateAndTimezone', () => {
test('SetDateAndTimezone', async () => {
const dateInput = setTimeElement.$$('#dateInput');
assertTrue(!!dateInput);
......@@ -155,9 +156,9 @@ suite('SetTimeDialog', function() {
const updatedTime = new Date(originalTime.getTime() + 15 * 60 * 1000);
dateInput.focus();
dateInput.valueAsDate = updatedTime;
setTimeElement.$$('#doneButton').click();
dateInput.blur();
// Simulate timezone change.
// Simulate the user changing the time zone.
cr.webUIListenerCallback('system-timezone-changed', 'America/Los_Angeles');
expectEquals('America/Los_Angeles', timezoneSelect.value);
......@@ -169,17 +170,23 @@ suite('SetTimeDialog', function() {
// one, therefore even with the 15 minutes forwarded it should be smaller.
expectGT(updatedTime.getTime(), updatedTimeAndTimezone.getTime());
assertEquals(1, testBrowserProxy.getCallCount('setTimezone'));
// Close the dialog.
setTimeElement.$$('#doneButton').click();
// The browser validates the change.
await testBrowserProxy.whenCalled('doneClicked');
cr.webUIListenerCallback('validation-complete');
return testBrowserProxy.whenCalled('setTimeInSeconds')
.then(timeInSeconds => {
const timeInSeconds = await testBrowserProxy.whenCalled('setTimeInSeconds');
const todaySeconds = originalTime.getTime() / 1000;
// The exact value isn't important (it depends on the current time).
// timeInSeconds should be bigger, because this timestamp is seconds
// since epoch and it does not hold any information regarding the
// current timezone.
assertGT(timeInSeconds, todaySeconds);
});
expectGT(timeInSeconds, todaySeconds);
const newTimezone = await testBrowserProxy.whenCalled('setTimezone');
expectEquals('America/Los_Angeles', newTimezone);
});
suite('NullTimezone', () => {
......@@ -190,7 +197,7 @@ suite('SetTimeDialog', function() {
});
});
test('SetDateNullTimezone', () => {
test('SetDateNullTimezone', async () => {
const dateInput = setTimeElement.$$('#dateInput');
assertTrue(!!dateInput);
......@@ -208,11 +215,13 @@ suite('SetTimeDialog', function() {
dateInput.valueAsDate = twoDaysAgo;
setTimeElement.$$('#doneButton').click();
assertEquals(0, testBrowserProxy.getCallCount('setTimezone'));
// The browser validates the change.
await testBrowserProxy.whenCalled('doneClicked');
cr.webUIListenerCallback('validation-complete');
// Verify the page sends a request to move time backward.
return testBrowserProxy.whenCalled('setTimeInSeconds')
.then(newTimeSeconds => {
const newTimeSeconds =
await testBrowserProxy.whenCalled('setTimeInSeconds');
const todaySeconds = today.getTime() / 1000;
// Check that the current time is bigger than the new time, which
// is supposed to be two days ago. The exact value isn't
......@@ -220,7 +229,9 @@ suite('SetTimeDialog', function() {
// current time, which is constantly updated, therefore we only
// assert that one is bigger than the other.
assertGT(todaySeconds, newTimeSeconds);
});
// Verify the page didn't try to change the timezone.
assertEquals(0, testBrowserProxy.getCallCount('setTimezone'));
});
});
});
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