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() { ...@@ -46,7 +46,6 @@ suite('SetTimeDialog', function() {
/** @override */ /** @override */
doneClicked() { doneClicked() {
this.methodCalled('doneClicked'); this.methodCalled('doneClicked');
cr.webUIListenerCallback('validation-complete');
} }
} }
...@@ -96,7 +95,7 @@ suite('SetTimeDialog', function() { ...@@ -96,7 +95,7 @@ suite('SetTimeDialog', function() {
assertLE(now, maxDate); assertLE(now, maxDate);
}); });
test('SetDate', () => { test('SetDate', async () => {
const dateInput = setTimeElement.$$('#dateInput'); const dateInput = setTimeElement.$$('#dateInput');
assertTrue(!!dateInput); assertTrue(!!dateInput);
...@@ -107,13 +106,15 @@ suite('SetTimeDialog', function() { ...@@ -107,13 +106,15 @@ suite('SetTimeDialog', function() {
dateInput.valueAsDate = nextWeek; dateInput.valueAsDate = nextWeek;
setTimeElement.$$('#doneButton').click(); 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. // Verify the page sends a request to move time forward.
return testBrowserProxy.whenCalled('setTimeInSeconds') const timeInSeconds = await testBrowserProxy.whenCalled('setTimeInSeconds');
.then(timeInSeconds => { const todaySeconds = today.getTime() / 1000;
const todaySeconds = today.getTime() / 1000; // The exact value isn't important (it depends on the current time).
// The exact value isn't important (it depends on the current time). assertGT(timeInSeconds, todaySeconds);
assertGT(timeInSeconds, todaySeconds);
});
}); });
test('Revert invalid date on blur', () => { test('Revert invalid date on blur', () => {
...@@ -138,7 +139,7 @@ suite('SetTimeDialog', function() { ...@@ -138,7 +139,7 @@ suite('SetTimeDialog', function() {
expectEquals('Asia/Seoul', timezoneSelect.value); expectEquals('Asia/Seoul', timezoneSelect.value);
}); });
test('SetDateAndTimezone', () => { test('SetDateAndTimezone', async () => {
const dateInput = setTimeElement.$$('#dateInput'); const dateInput = setTimeElement.$$('#dateInput');
assertTrue(!!dateInput); assertTrue(!!dateInput);
...@@ -155,9 +156,9 @@ suite('SetTimeDialog', function() { ...@@ -155,9 +156,9 @@ suite('SetTimeDialog', function() {
const updatedTime = new Date(originalTime.getTime() + 15 * 60 * 1000); const updatedTime = new Date(originalTime.getTime() + 15 * 60 * 1000);
dateInput.focus(); dateInput.focus();
dateInput.valueAsDate = updatedTime; 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'); cr.webUIListenerCallback('system-timezone-changed', 'America/Los_Angeles');
expectEquals('America/Los_Angeles', timezoneSelect.value); expectEquals('America/Los_Angeles', timezoneSelect.value);
...@@ -169,17 +170,23 @@ suite('SetTimeDialog', function() { ...@@ -169,17 +170,23 @@ suite('SetTimeDialog', function() {
// one, therefore even with the 15 minutes forwarded it should be smaller. // one, therefore even with the 15 minutes forwarded it should be smaller.
expectGT(updatedTime.getTime(), updatedTimeAndTimezone.getTime()); expectGT(updatedTime.getTime(), updatedTimeAndTimezone.getTime());
assertEquals(1, testBrowserProxy.getCallCount('setTimezone')); // Close the dialog.
setTimeElement.$$('#doneButton').click();
return testBrowserProxy.whenCalled('setTimeInSeconds')
.then(timeInSeconds => { // The browser validates the change.
const todaySeconds = originalTime.getTime() / 1000; await testBrowserProxy.whenCalled('doneClicked');
// The exact value isn't important (it depends on the current time). cr.webUIListenerCallback('validation-complete');
// timeInSeconds should be bigger, because this timestamp is seconds
// since epoch and it does not hold any information regarding the const timeInSeconds = await testBrowserProxy.whenCalled('setTimeInSeconds');
// current timezone. const todaySeconds = originalTime.getTime() / 1000;
assertGT(timeInSeconds, todaySeconds); // 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.
expectGT(timeInSeconds, todaySeconds);
const newTimezone = await testBrowserProxy.whenCalled('setTimezone');
expectEquals('America/Los_Angeles', newTimezone);
}); });
suite('NullTimezone', () => { suite('NullTimezone', () => {
...@@ -190,7 +197,7 @@ suite('SetTimeDialog', function() { ...@@ -190,7 +197,7 @@ suite('SetTimeDialog', function() {
}); });
}); });
test('SetDateNullTimezone', () => { test('SetDateNullTimezone', async () => {
const dateInput = setTimeElement.$$('#dateInput'); const dateInput = setTimeElement.$$('#dateInput');
assertTrue(!!dateInput); assertTrue(!!dateInput);
...@@ -208,19 +215,23 @@ suite('SetTimeDialog', function() { ...@@ -208,19 +215,23 @@ suite('SetTimeDialog', function() {
dateInput.valueAsDate = twoDaysAgo; dateInput.valueAsDate = twoDaysAgo;
setTimeElement.$$('#doneButton').click(); 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. // Verify the page sends a request to move time backward.
return testBrowserProxy.whenCalled('setTimeInSeconds') const newTimeSeconds =
.then(newTimeSeconds => { await testBrowserProxy.whenCalled('setTimeInSeconds');
const todaySeconds = today.getTime() / 1000; const todaySeconds = today.getTime() / 1000;
// Check that the current time is bigger than the new time, which // Check that the current time is bigger than the new time, which
// is supposed to be two days ago. The exact value isn't // is supposed to be two days ago. The exact value isn't
// important, checking it is difficult because it depends on the // important, checking it is difficult because it depends on the
// current time, which is constantly updated, therefore we only // current time, which is constantly updated, therefore we only
// assert that one is bigger than the other. // assert that one is bigger than the other.
assertGT(todaySeconds, newTimeSeconds); 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