Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Issue 906673002: Added layout test for |availablechange| event. (Closed)

Created:
5 years, 10 months ago by whywhat
Modified:
5 years, 10 months ago
Reviewers:
Peter Beverloo
CC:
blink-reviews
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Target Ref:
refs/heads/master
Project:
blink
Visibility:
Public.

Description

Added layout test for |availablechange| event. Depends on a Chromium change: https://codereview.chromium.org/905823004 BUG=412331

Patch Set 1 #

Total comments: 4

Patch Set 2 : Reupload to the original issue #

Patch Set 3 : Changed the way the tests run #

Patch Set 4 : Trying sync tests #

Patch Set 5 : Test of trybots, false assertion #

Patch Set 6 : Assert true #

Patch Set 7 : Async test #

Patch Set 8 : Trying only one test #

Patch Set 9 : The simplest async test? #

Unified diffs Side-by-side diffs Delta from patch set Stats (+26 lines, -0 lines) Patch
A LayoutTests/presentation/availablechange-event.html View 1 2 3 4 5 6 7 8 1 chunk +26 lines, -0 lines 0 comments Download

Messages

Total messages: 8 (2 generated)
whywhat
PTaL
5 years, 10 months ago (2015-02-06 20:19:44 UTC) #2
Peter Beverloo
lgtm https://codereview.chromium.org/906673002/diff/1/LayoutTests/presentation/availablechange-event.html File LayoutTests/presentation/availablechange-event.html (right): https://codereview.chromium.org/906673002/diff/1/LayoutTests/presentation/availablechange-event.html#newcode2 LayoutTests/presentation/availablechange-event.html:2: <html> nit: <title> with a brief description of ...
5 years, 10 months ago (2015-02-09 18:37:24 UTC) #3
whywhat
Please, take a look at https://codereview.chromium.org/919953003 where the new patch was uploaded for some reason.
5 years, 10 months ago (2015-02-13 16:57:11 UTC) #4
whywhat
Fixed in https://codereview.chromium.org/919953003 https://codereview.chromium.org/906673002/diff/1/LayoutTests/presentation/availablechange-event.html File LayoutTests/presentation/availablechange-event.html (right): https://codereview.chromium.org/906673002/diff/1/LayoutTests/presentation/availablechange-event.html#newcode2 LayoutTests/presentation/availablechange-event.html:2: <html> On 2015/02/09 18:37:24, Peter Beverloo ...
5 years, 10 months ago (2015-02-13 16:57:37 UTC) #5
Peter Beverloo
(Which issue are you using?) I guess the big open question is whether you want ...
5 years, 10 months ago (2015-02-16 23:06:16 UTC) #7
whywhat
5 years, 10 months ago (2015-02-17 20:06:56 UTC) #8
On 2015/02/16 23:06:16, Peter Beverloo wrote:
> (Which issue are you using?)
> 
> I guess the big open question is whether you want these tests to be
synchronous.
> 
> In your test runner implementation today, they are in fact synchronous, so the
> most recent PS should work well. However, in reality the Presentation API
won't
> be, so if you ever wanted to update these tests to be usable on other browsers
> as well -which is a large advantage of test harness- that'll make it more
> difficult.
> 
> The setTimeout trick you copied from Mounir earlier on made them asynchronous,
> but relied on the events to have been executed on the next execution loop. A
> more rigid implementation could be to use a promise like this:
> 
> =========================
> function ChangeScreenAvailability(available) {
>     return new Promise(function (resolve, reject) {
>         var listener = function(event) {
>             navigator.presentation.removeEventListener('availablechange',
> listener);
>             resolve(e.available);
>         };
> 
>         navigator.presentation.addEventListener('availablechange', listener);

The problem with resetting the listener is that the event will be fired with
available set to true (if it was set to true) per the spec. Which makes testing
devices becoming unavailable harder since two events would be fired: when the
handler is added and then when the availability set to false.

>         testRunner.setMockScreenAvailability(available);
>     });
> }
> 
> async_test(function(test) {
>     ChangeScreenAvailability(true).then(function (available) {
>         assert_true(available);
>         test.done();
>     }).catch(function (error) {
>         assert_unreached(error.message);
>     });
> 
> }, 'Test description.')
> =========================

I incorporated PhilipJ's proposal to unite the test cases as they depend on each
other. I think PS7 looks quite simple and is async.

> 
> Asynchronously checking that something *did not* happen is a bit harder. I
guess
> you could take the easy route here and move forward on the assumption that the
> test runner is in fact synchronous...

There's Test.unreached_func for that. As I saw in other tests, one sets it up as
the event handler and then calls setTimeout(test.step_func_done()) to finish the
test but give the event opportunity to misfire.

Given that the simplest async test still fails with the timeout, I'm going to
temporarily give up until the problem is resolved somehow.

Powered by Google App Engine
This is Rietveld 408576698