Commit f6b5a448 authored by Jack Steinberg's avatar Jack Steinberg Committed by Commit Bot

Change toast default duration to 3000ms,

and shorten non-default timeout tests

Change-Id: Ia9e6a14ff66a0f5d4b57ffb59808769bd90e578f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1675544
Commit-Queue: Jack Steinberg <jacksteinberg@chromium.org>
Reviewed-by: default avatarFergal Daly <fergal@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672007}
parent e8ef3660
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* @package * @package
*/ */
const DEFAULT_DURATION = 2000; const DEFAULT_DURATION = 3000;
function stylesheetFactory() { function stylesheetFactory() {
let stylesheet; let stylesheet;
......
...@@ -77,49 +77,50 @@ testToastElement((toast) => { ...@@ -77,49 +77,50 @@ testToastElement((toast) => {
}, 'calling `toggle()` with `force` parameter set to false on a shown toast closes the toast'); }, 'calling `toggle()` with `force` parameter set to false on a shown toast closes the toast');
testToastElementAsync((t, toast) => { testToastElementAsync((t, toast) => {
toast.show(); toast.show({duration: 50});
// time = 999 // time = 49
t.step_timeout(() => { t.step_timeout(() => {
assertToastShown(toast); assertToastShown(toast);
toast.show(); toast.show({duration: 50});
// time = 2000 // time = 98
t.step_timeout(() => { t.step_timeout(() => {
assertToastShown(toast); assertToastShown(toast);
// time = 3000 // time = 99
t.step_timeout(() => { t.step_timeout(() => {
assertToastNotShown(toast); assertToastNotShown(toast);
t.done(); t.done();
}, 1000); }, 1000);
}, 1001); }, 49);
}, 999); }, 49);
}, 'calling `show()` twice resets the timeout'); }, 'calling `show()` twice resets the timeout');
testToastElementAsync((t, toast) => { testToastElementAsync((t, toast) => {
toast.show(); toast.show({duration: 50});
// time = 999 // time = 48
t.step_timeout(() => { t.step_timeout(() => {
assertToastShown(toast); assertToastShown(toast);
toast.hide(); toast.hide();
// time = 1000 // time = 49
t.step_timeout(() => { t.step_timeout(() => {
assertToastNotShown(toast); assertToastNotShown(toast);
// time = 1500 // time = 50
t.step_timeout(() => { t.step_timeout(() => {
toast.show(); toast.show({duration: 2});
// time = 2500 // time = 51
t.step_timeout(() => { t.step_timeout(() => {
assertToastShown(toast); assertToastShown(toast);
toast.hide();
t.done(); t.done();
}, 1000);
}, 500);
}, 1); }, 1);
}, 999); }, 1);
}, 1);
}, 48);
}, 'calling `hide()` clears the timeout'); }, 'calling `hide()` clears the timeout');
</script> </script>
...@@ -71,32 +71,34 @@ async_test(t => { ...@@ -71,32 +71,34 @@ async_test(t => {
t.step_timeout(() => { t.step_timeout(() => {
assertToastShown(toast); assertToastShown(toast);
}, 1999); }, 2999);
t.step_timeout(() => { t.step_timeout(() => {
assertToastNotShown(toast); assertToastNotShown(toast);
t.done(); t.done();
}, 2000); }, 3000);
t.add_cleanup(function() { t.add_cleanup(function() {
toast.remove(); toast.remove();
}); });
}, 'showToast closes after default duration of 2000ms'); }, 'showToast closes after default duration of 3000ms');
// FIXME: find a way to virtualize time instead of waiting 3000ms
// BUG: https://github.com/web-platform-tests/wpt/issues/17489
async_test(t => { async_test(t => {
const toast = showToast('message', {duration: 1000}); const toast = showToast('message', {duration: 50});
t.step_timeout(() => { t.step_timeout(() => {
assertToastShown(toast); assertToastShown(toast);
}, 999); }, 49);
t.step_timeout(() => { t.step_timeout(() => {
assertToastNotShown(toast); assertToastNotShown(toast);
t.done(); t.done();
}, 1000); }, 50);
t.add_cleanup(function() { t.add_cleanup(function() {
toast.remove(); toast.remove();
}); });
}, 'showToast closes after user specified 1000ms'); }, 'showToast closes after user specified 50ms');
</script> </script>
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