Commit Graph

32 Commits

Author SHA1 Message Date
Joey Parrish 7e6a0f38ff fix: Correct license headers in misc. files
This corrects/normalizes license headers in misc. files, such as
config files, docs, build tools, tests, and externs.  This does not
affect the compiled output, and is only done for consistency.

Issue #2638

Change-Id: I9d8da2de55243b08d7df2b743aac73c6f15e858a
2020-06-09 16:13:56 -07:00
Joey Parrish d215994123 Fix renaming of ad-related shaka.ui.Element fields
This also changes the Element plugin renaming test to avoid a
hard-coded list of member names so we don't miss one in the future.

Change-Id: Ifeb3b951ea3422da5014f16d9dcb13e8b8c7fc45
2020-05-13 21:33:07 +00:00
Joey Parrish 9695c68bb7 Fix demo app close button
As an external, abstract interface, the constructor doesn't do
anything.  The members in it were parts of the base class
shaka.ui.Element, which implementations of IUIElement can still
inherit from.

However, I was wrong about this part of the extern being unnecessary.
It turns out to prevent the compiler from renaming those critical
parts of the base class.  Application-provided UI elements (such as
our demo's close button) break without these definitions being part of
the library build.

This reverts commit 89059f81e5 ("Remove
bogus parts of IUIElement interface") and adds a comment to the
interface definition that would have prevented me from making this
mistake in the first place.  It also adds a regression test to the UI
test suite.

Change-Id: I712d985a6287136d68dc0a888662badd7e306b9e
2020-05-12 19:05:13 +00:00
Joey Parrish a1b71197ef Minor style changes in UI tests
This removes double-newlines and adds comments to indicate what the
end of a describe block corresponds to.

Change-Id: I6832b52c3d849896d0c8e93bd8f27a22e665c3f6
2020-05-12 19:05:13 +00:00
Joey Parrish 4eefaa44cb Correct type info in tests
In many places in the tests, we used "Object" or "*" or just no type
at all for various fakes.  These were all flagged by the new Closure
Compiler version we are adopting.

In some other places, we mixed up similar types or had the wrong
nullability on a type.

In still others, types were missing fields.

These issues were caught by a compiler upgrade.

Issue #2528

Change-Id: I324e0b28f7e30a4102aa26ec2c9901fa9732211b
2020-04-30 16:00:17 +00:00
Joey Parrish 99de217c23 Remove periods from manifest structure
This removes periods from the internal manifest structure and cleans
up code and tests accordingly.  This leaves us unable to play
multi-period DASH & offline streams until the main period-flattening
algorithm is completed in shaka.util.Periods.

Three test cases have been disabled for the moment.

Multi-period playback will be restored in a smaller, more focused
follow-up commit, with disabled tests re-enabled.

Issue #1339 (flatten periods)
Issue #1698 (rapid period transitions issue)
Issue #856 (audio change causes bitrate change)
Closes #892 (refactor StreamingEngine)

Change-Id: I0cbf3b56bfdb51add15229df323b902f0b2e643a
2020-04-09 19:22:16 +00:00
Jacob Trimble 9e975a2f6d Don't fire 'adaptation' event when not switching.
Closes #2392

Change-Id: Ib3af4fa465bc8502dfe751856eda1a27e038b304
2020-02-18 15:38:40 -08:00
Jacob Trimble 011749e95f Standardize argument comments.
This changes the eslint rule to enforce a strict pattern for the
argument comments.  The comment must appear before the argument and
must be /* foo= */.  This still ignores line comments.

Change-Id: I3afb01c65e1088eda13facb3aeeaa7595a2f5aee
2020-01-06 19:40:52 +00:00
Joey Parrish a48f8792a9 Move test-only method to test utils
This method should probably never have been in the library, since it
creates a fixed-sized, muted element.

Change-Id: I53b474305465bef34d43ce40ec5e7dedceb20a25
2020-01-06 18:57:28 +00:00
Joey Parrish 64896d70b0 Use shorter license header
This reflects changes in Google's policy on JavaScript license
headers, which should be smaller to avoid increasing the size of the
binary unnecessarily.

This also updates the company name from "Google, Inc" to "Google LLC".

Change-Id: I3f8b9ed3700b6351f43173d50c94d35c333e82b4
2019-11-22 18:18:36 +00:00
Jacob Trimble 7764ff609f Don't put space before '=' in arg comment.
This standardizes how we handle the spacing in argument comments.  The
other way is much more common, so we standardized on that.  This add a
new linter rule to catch and automatically fix those issues.

Change-Id: I8ea54c47ae4d34cf8e1646e56c6ed8142b42afbe
2019-09-06 13:49:10 -07:00
Jacob Trimble 83de1ad634 Use toBe instead of toEqual for primitives.
This ensures that we get the expected types and that type coercion
doesn't convert between types.  This also ensures we are consistent
in how we check for equality of primitives in tests.

Change-Id: I9f3aacdf25ab1afe5e8d6e4b895b5299ee687d54
2019-06-26 18:57:18 +00:00
Sandra Lokshina 1f8dabc2e1 UI tests refactoring
This change splits ui tests into general tests and customization.
This is a base for adding more customization tests and creating a
suit for a11y tests.

Change-Id: Icd293ac382ec4a14e15b5be57bf194f83e45f89d
2019-06-10 21:55:52 +00:00
Jacob Trimble f130dffcef Enable eslint indentation rule.
This is a fully automated change.  The linter will fail because the
extra indentation caused line-length errors.  These won't be fixed
automatically.  They are fixed in a follow-up to make this one fully
automated.

Change-Id: I4d8cf9c998985add2bcd24a81c8d65495668c4f3
2019-05-13 22:31:09 +00:00
Jacob Trimble 0dd64074b9 Only allow one statement per line.
With the new style rule, we cannot have two statements on the same line.
So we can no longer have an "if" on a single line and we cannot have
an arrow function with a body on the same line as when it is used.
This is mostly a manual change.

Change-Id: I2285202dd5ecbad764308bc725e6d317ff2ee7f0
2019-05-13 22:11:50 +00:00
Jacob Trimble 47daf49f31 Use arrow functions for callbacks.
This is an automated change to convert use of "function" functions
to arrow functions.  This doesn't change all uses of bind() that
could be converted.  This also doesn't remove all "function" functions.

Change-Id: I40ac7d086bcef947a1be083359c8fd1d4499a9c3
2019-05-09 16:40:46 +00:00
Joey Parrish f3d6ccf29d Add a generic test waiter class
This is a centralized utility to replace the various waitFor() methods
spread out through a few utilities and suites.  This allows better
control over the formatting and type of debug info logged on failures,
as well as the timeout structure.

This utility has helped debug some tricky event timeouts in the UI
tests, and follow-up changes will put it into use throughout all test
suites.

Change-Id: I0072dcefa2c62e56e1c746f4e48cec1282934d9e
2019-05-07 18:40:31 +00:00
Joey Parrish 91a848cb05 Fix UI integration tests
Fix missing await.  These tests were not behaving correctly, in part
because they were running async processes synchronously.

Re-evaluate tracks.  Some of the failures in these tests were because
the Track objects were not re-evaluated after the tracks changed.  The
Player does not modify these object in-place, but generates new ones
when the track API is called.

Re-evaluate buttons. These buttons are remade when state changes, so
they need to be re-evaluated.  Before, we were recreating the map, but
still using old references that were no longer in the DOM.

Turn captions on before turning them off in UI test.  Otherwise, the
test assumptions are invalid.

Add missing caption event in UI.  The UI tests use this event, but it
was only dispatched on track changes, not visibility state changes.

Make sure text is being streamed so API change does something.

Use correct track API in each test.  Before, selectAudioLanguage was
used in text language tests.

Fixes b/131909906

Change-Id: Id58495da8f99e3c6f35c09d2d5762c99aaba30d1
2019-05-07 01:23:15 +00:00
Joey Parrish 02b06415ec Add missing player events
If changes are deferred because of StreamingEngine state, the Player
should still fire variantchanged and textchanged events after the
changes are applied.

Also, clean up Player event firing patterns.  The texttrackvisibility
and abrstatuschanged events should be fired asynchronously, just as
other state change events are.

The onEvent_ method was one line and only called from one place, so
it was inlined and removed.

The corresponding pattern of waiting on these events in the UI tests
was also changed.

b/131909906

Change-Id: I7f7d3b25ee336dbfe79c3214854722e1955acb6a
2019-05-06 22:30:38 +00:00
Joey Parrish 685e9d57cf Eliminate free calls of static methods
It is type-safe to alias a class, but not one of its static methods.
Aliasing the method without the class makes it a "free call" to invoke
the aliased method.

A "free call" is when you call a method without the context of its
instance of class.  There were several cases of this with static
methods.

This will be enforced by a future release of the compiler, which I
believe will lead into compiler support for "this" in static ES6
methods.  In ES6, you can use "this" in static methods to refer to the
class and call other static methods.  Closure compiler doesn't support
static "this" yet, but we will start using it as soon as it is
supported.

Change-Id: I4249db8b6dda9231ebba60ee0d4ad734a692c2fe
2019-05-03 18:43:35 +00:00
Sandra Lokshina b0f89441ef Avoid race between UI events and their listeners in UI integration tests
UI events can get in a race with the tests trying to listen to them.
This change creates all the listeners for the UI events first,
before invoking the behavior that should fire them.

Fixes b/131313069
Fixes b/131311532

Change-Id: I43bbeb4d1c6cebe90d92563bec5c62fd84ff259f
2019-05-03 16:10:31 +00:00
Jacob Trimble 9ae237cc3c Fix captions being displayed initially.
When the audio and text languages differ, we should display the captions
by default.  This also happens if the app calls setTextTrackVisibility
before calling load.  What happened is the text media state was being
created, but an update wasn't being scheduled.  This meant the text
segments never got appended.  This changes when the update gets
schedules.  This also removes an unnecessary call to set the initial
state during startup.

Issue #1696
Closes #1879

Change-Id: If3a1b9e2889fc0e487da0e7276ca837636bf2e54
2019-05-03 15:58:08 +00:00
Joey Parrish c0366cbf14 Replace 'canplaythrough' events with 'canplay'
I recently introduced two uses of the 'canplaythrough' event, but it
was pointed out to me that this implies that content is buffered
enough to avoid ever buffering again until the end.  Instead, we
should simply be using the 'canplay' event, which only implies that we
could start playback.

Change-Id: I3176f8c943ea7bf3f39967a616d9deffd5a4e791
2019-05-01 19:27:05 +00:00
Joey Parrish 56a48ec9b9 Fix resolution menu restoration
If the resolution menu sees audio-only content, it should be hidden.
But it should come back as soon as the audio-video content is seen.

This came up during work on #997 and #382

Change-Id: I3297847c905c867bcdd14cf7e525a408890a273a
2019-04-30 12:03:29 -07:00
Joey Parrish 91c57e1663 Drop periodreadyforstreaming event
This event was added just for the sake of the UI tests, but the video
element's canplaythrough event works in its place.

Change-Id: I6774fdfdfbd2b197cc93eae743829510b61bb0fa
2019-04-30 17:07:08 +00:00
Sandra Lokshina 7a15c1e94f UI: Dynamic layout construction.
Fixes #1674

Change-Id: I338917bbd43a6ddc837388fdc8beea9e3f7b0778
2019-04-29 21:17:39 +00:00
Sandra Lokshina 3721797cd2 Add abrstatuschanged event.
Add event to notify listeners when abr is being enabled/disabled.
The resolutions menu is listening for variantchanged events to
update itself. It's possible, however, that just enabled abr
will pick the same variant that's currently being played, in
which case, there'll be no variantchanged event. The resolution,
though, still needs to update to reflect the fact that 'Auto'
resolution is selected now and not a specific one.

Adding an event for when the abr state changes helps solve
this.

Fixes b/131099397

Change-Id: I63b218d7423cd0d389dd540c5ed05966e00b861c
2019-04-23 23:55:49 +00:00
Sandra Lokshina 48ba5c75c0 Add integration tests for the resolutions menu.
Change-Id: I86e8d675daf48a19b477f8d92e80fc706f189d90
2019-04-18 18:29:37 +00:00
Joey Parrish 4343e954aa Fix UI unit test cleanup
The UI unit tests were leaving players undestroyed, which caused
additional failures on Tizen in the src= tests.  This makes some
changes to the UI to allow discovery of the UI through the DOM, which
in turn enables automated (and thorough) cleanup of the UI in our
tests.

b/130554111

Change-Id: I8bfef07f670ce7ec5deafaf19314d7bfd2eb6eed
2019-04-17 21:28:24 +00:00
Sandra Lokshina 436e30dc11 Add integration tests for UI captions selection.
Change-Id: I59bd837a3542636c98fa8ecec6d6d0e7dfd64e23
2019-04-08 15:09:36 -07:00
Sandra Lokshina 493d459c47 Add a DOM util.
Change-Id: Ia0941868f20dbb42fa0fe02a639015ac244a65ed
2019-04-05 12:01:59 -07:00
Sandra Lokshina 3a2be7fe0a Add UI integration tests for the language menu.
Change-Id: Idbd3b2da9b7a0277798ecb344961aef153ad39f2
2019-04-05 16:44:13 +00:00