Commit Graph

99 Commits

Author SHA1 Message Date
Joey Parrish 1aed3f18c7 build: Fix linter error introduced by #3649 (#4147) 2022-04-21 16:09:13 -07:00
Nbcl adc3502d55 feat(ui): Add quality selection for audio-only content (#3649)
Replaces resolution menu with audio quality menu when content is audio-only.

Fixes: #2071
2022-04-21 15:43:51 -07:00
Joey Parrish fbbd63d96b test: Late load tests, fix Chromecast test flake (#4115)
This change fixes tests on Chromecast by loading tests later in the process.  Test scripts are now dynamically inserted by boot.js, rather than loaded by Karma.  The bootstrapping code then awaits the completion of that before starting the Karma frameworks (Jasmine) to run the tests.

This also removes the use of goog.provide/goog.require in tests and test utils.  We don't need to load test utils or library sources dynamically in each test, and this gives us more explicit control over script loading and ordering.

Closes #4094
2022-04-11 15:47:48 -07:00
Álvaro Velad Galván 57c73241a0 fix(performance): Eliminate use of ES6 generators (#4092)
See: https://github.com/shaka-project/shaka-player/issues/4062#issuecomment-1077826210

Co-authored-by: @joeyparrish

Issue #4062
2022-04-04 10:58:16 -07:00
Joey Parrish 1507b1e844 chore: Update URLs after moving projects (#4008) 2022-03-03 14:34:40 -08:00
Joey Parrish 76d4fd9553 test: Make screenshot comparisons more tolerant (#3916)
Instead of pixel-wise comparison with a change threshold, we now use a
structural similarity (ssim) module to decide how much a screenshot
has changed.  This better tolerates small rendering differences due to
differences in GPUs across machines.
2022-01-31 15:20:43 -08:00
Joey Parrish f6c6f4eb9c test: Fix flake in screenshot tests around native captions (#3915)
This fixes some missing cues in screenshot tests for native rendering in Safari.
2022-01-31 15:06:52 -08:00
Jacob Trimble cdeffbb9e6 fix(ui): Fix styling of UI text cues
First, the positioning of cues was incorrect.  We need to explicitly
set all the position attributes when we position elements with the
"absolute" position.

Second, if we position a text <span> manually, the background will fill
the whole region.  So to keep the background wrapping the text, we need
to add another <span> for the text.

Third, the background and font color should not be set on every <span>
element since it won't allow parent cues to set the inherited value.
So this moves the defaults to the top-level text element and allows
parent cue elements to override this.  It also would make app CSS
easier to override.  Because background color isn't inherited through
CSS, the default is set in JavaScript instead.

Fixes #3521
Fixes #3600
Closes #3713

Change-Id: I45fc88dcac4a0a062e1474087f24c80d98eef619
2021-11-03 17:31:25 +00:00
Theodore Abshire dd3748d599 fix: Enforce string-format of event data keys.
Previously, many events were being defined with a data dictionary
that used variable-type keys (e.g. {key: value}). This worked fine
in uncompiled mode, but in compiled mode it lead to those properties
being obfuscated.
This changes the FakeEvent constructor to take a map rather than an
object, so the compiler will force the keys to be strings.

Closes #3710

Change-Id: I67b1a391540a5ee21f0aaf940ae054d26f4c10a4
2021-10-25 12:40:32 -07:00
Nico afb93106a7 feat(ui): Add right-click context menu, statistics button (#3548)
Closes #2607
2021-08-04 22:16:56 -07:00
Nico 481b378a4b feat(ui): Add Quality, Language, Playback, Captions buttons to control panel (#3465) 2021-07-23 12:12:16 -07:00
Joey Parrish 2250324a4a fix: Fix enforcement of cue alignment styles
This uses flexbox once again to get proper positioning of cues.  To
compensate for the issues that originally made us remove flexbox, this
adds a wrapper span inside the flexbox element.

Summary of screenshot changes:
 - slight change to background sizing
   - ui-basic-cue
   - ui-cue-with-controls
   - ui-duplicate-cues
   - ui-end-time-edge-case
   - ui-flat-cue-bg
   - ui-two-basic-cues
 - background fills block with literal newline in text
   - ui-cue-with-newline
 - region anchored without padding
   - ui-region-position
 - new screenshots
   - *-nested-cues-with-linebreak
   - *-region-with-display-alignment  (regression test for this issue)

Closes #3379

Change-Id: I8c678721d96662e0f8940cda12df4f5b5e5baf1e
2021-07-09 17:19:42 +00:00
Joey Parrish 9674e1cd71 test: Skip fullscreen test on Tizen
This test requires fullscreen support, which is not available on
Tizen.  We should skip the test on any such platform.

This test was passing before the check for fullscreen support was
added to the library to fix #3441.

Change-Id: I6560a919257290540af3ce6a2b3da1a355da9ab9
2021-06-08 12:13:18 -07:00
Michelle Zhuo 95ba28b5af refactor: Remove IE 11 support
Issue #2339

Change-Id: I80ffa7b04f7afd943aa0f881d2a494dd35def732
2021-04-29 17:47:07 +00:00
Joey Parrish 8d9a975f78 test: Remove global Util alias
There was an alias to shaka.test.Util in a global context which was
affecting other tests.  The result was that these tests could refer to
"Util" without the namespace or their own alias, and everything would
work.

The problem with that is that when the file with the global alias was
removed or disabled, those other tests would fail because "Util" would
be undefined.

This removes the global alias and adds missing local aliases to the
test suites that were accidentally relying on the global one.

Change-Id: Ifca8c1ada0c3e46cb30a2039b5c4c2252d992d37
2021-04-29 16:48:23 +00:00
Joey Parrish 59ba807dfe test: Regression test for subtitle timing edge case
In issue #3151, some TVs showed subtitles stacked on one another when
one should have expired.  This only occurred on some platforms because
it required very specific values for video.currentTime at the exact
moment the UI text displayer calculated visibility.  Limited precision
on video.currentTime on some platforms may have exposed the edge case,
but it was always possible.

PR #3152 fixed the issue by correcting the visibility calculation.
Cue end times should be excluded from their visibility range, i.e.
(start, end].

This adds a new regression test for this edge case using our
screenshot-based layout tests.  Note that the behavior can only be
controlled when we control text display through the UI.  When using
native text display from the browser, the exact visibility and
interpretation of timing is entirely up to the browser.  As of Feb
2021, Chrome, Edge, and Safari all do it wrong, and Firefox does it
right.

Change-Id: I2cdb8a2a759960d5ed8ce8790bf9daaeb2a335eb
2021-02-11 20:20:15 +00:00
Joey Parrish 7544670ee5 chore: Upgrade eslint
The new eslint found many style errors which have now been corrected.

It also complains a lot about atomic update issues that do not seem to
exist, so that rule has been disabled.

This upgrade will allow us to adopt eslint's "id-denylist" instead of
the older "id-blacklist" rule, the name of which violates new Google
guidelines about respectful language.

Bug: 178203011

Change-Id: Ia65581b96e4dd1331f720fa396183dca020b9caf
2021-02-01 23:36:12 +00:00
Theodore Abshire 655493f441 Fix(ads): Fix bug w/ configuring UI during CS ads
Previously, the client-side ad container was put inside the controls
container, which was cleared when the UI was configured. This meant
that re-configuring the UI made client-side ads go away, basically.
This moves client-side ads to go into their own container, which
is never re-made or uprooted, even when the DOM is recreated, in
order to not break the IMA SDK.
This has the side-effect of fixing a bug where client-side ads were
not always cleared upon loading a new asset, and could show up
unexpectedly in future playbacks.

Fixes #2869
Fixes #2943

Change-Id: I3cf67b0b278764c10c6ff2f678316dc9cc85929e
2020-12-16 14:26:09 -08:00
Michelle Zhuo a9a1695d22 fix: support TTML background image's region positioning
In bitmap-based cues, the tts:origin of the region should specify
the position of the background image. Add support for that case.

Closes #2703

Change-Id: I83ebeac939550138f8eef5d0b4547ab54fd6cf6c
2020-11-03 16:55:52 -08:00
michellezhuo 648e12e9c1 build: add goog.require for compiler upgrade (Part 4)
Change-Id: I6b4a7209c7a3a9f6069351377dac32f22222c0fb
2020-10-12 16:54:08 +00:00
Michelle Zhuo 093103e646 build: test util refactor for compiler upgrade
Refactor the test util and relevant files for compiler upgrade.
In test files, a few files depending on each other formed a
dependency loop.
For example, test/Util has a few methods for waiting/delay that
uses Waiter, and those methods should be in Waiter.
This changes helps to break the dependency loop, and helps to
unblock the compiler upgrade.

Change-Id: Ie5ece145748bf2eafe3fa065b79cf2a81b1637e1
2020-10-09 22:49:11 +00:00
Joey Parrish 52d3e6651d test: Fix native text layout tests on IE/Edge
The native layout tests on IE & Edge were hanging.  This seems to have
been caused in part by peculiarities of the video stream we used in
the tests.

This replaces the video, which was 10s of 32x32 solid green, with
another which is 320x180.  The new file is only 9kB, so it's not much
larger than the old one.

The old video would somehow hang IE & Edge, seemingly due to its
unusual tiny frame size.  I just tried a larger frame somewhat
arbitrarily and found that it worked.  I have no model for why this
would be the case.

This also makes the tests somewhat more robust by seeking to the
beginning before a "wait for movement" step in the test setup.  This
seek to 0 fixed part of the problem early on, before I replaced the
video.  I don't know if it's strictly necessary in addition to
replacing the video, but I did it first and it makes logical sense to
do it, so I've left it in the commit.

Finally, the new video has the same aspect ratio as the screenshots
themselves, and completely fills the frame.  This was not true before,
which meant that the background color on the left and right sides
didn't exactly match the video frame color in the middle.  (And on IE,
the video frame color wasn't showing in the screenshots at all for
some reason.)  Now that the video has been replaced with something
that seems to behave better on IE & Edge, the screenshots also need to
be updated to match on all platforms.

Fixed: 165712112

Change-Id: I6156366b230b71fc52e095b62dd51be8f3e68b93
2020-08-20 17:30:06 +00:00
Joey Parrish 3a7d5b259a test(text): Add layout tests for native text display
In addition to the UI, text can also be displayed through the
browser's native display capabilities for subtitles.  So it's equally
important that we have layout tests for this, as well.

This expands our layout tests to run in both the UI and native display
contexts.

Change-Id: I65289eaa59fc9678ccede3a1ef3676c5b61ab740
2020-08-11 19:29:54 -07:00
Joey Parrish 565bb7d880 feat(text): Clarify and clean up text Cue contract
Changes:
 - Update comments on shaka.extern.Cue to clarify how fields should be
   used and interpreted
 - Add support for arbitrarily-deep nested cues in both text
   displayers
 - Stop adding whitespace between nested cues (parsers should emit
   exactly what they want displayed) and update tests to match
 - Remove obscure special cases from UITextDisplayer styles and make
   styling consistent with the Cue docs
 - Fix rendering for single line break (cue.spacer) elements
 - Add a layout test for deeply-nested cues
 - Remove reundant and identical set of UITextDisplayer unit tests
 - Update layout test for backgrounds to reflect the clarified rules
 - Update remaining UITextDisplayer unit tests to look for div instead
   of span for top-level cues
 - Updates screenshots for region-position, which changed slightly in
   appearance due to changes in whitespace rules
 - Updates screenshots for nested-cue-bg, to reflect simplified rules
   for applying backgrounds

TODO:
 - Temporarily breaks TTML output until the TTML parser can be updated
   to conform to the clarified rules in the Cue docs
 - Still more special cases around regions in UITextDisplayer
 - Rendering for multiple line break elements in UITextDisplayer
 - Support bold, italic, and underline in SimpleTextDisplayer
 - None of the displayers will honor the wrapLine field yet

Closes #2762 (extra vertical space seen for line breaks)
Issue #2761 (deeply-nested cues)

Change-Id: I02ac8213e4de67a65fb38d596d2c59536f3722ee
2020-08-11 14:30:40 +00:00
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 f692bfe7d6 test: Add regression tests for cue backgrounds
This adds two new layout tests for cue backgrounds, corresponding to
issue #2623 and PR #2624.

Change-Id: I2f07e46c31ac613792471dd8d65fef1676f6b6bf
2020-06-09 00:10:48 +00:00
Joey Parrish b839340220 Add screenshot-based layout tests for subtitles
This adds our first screenshot-based layout tests and the
infrastructure to use WebDriver for screenshots through Karma.
This new kind of test will be skipped in any non-WebDriver context.

There are many pieces to this system.

First, we update the Karma WebDriver launcher to a newly-released
version that lets us access the client spec object from the launcher.

Second, we build a Karma middleware plugin to respond to HTTP requests
from the tests.  We handle /screenshot/isSupported and return a bool
so tests can be skipped on non-WebDriver launchers.  We also handle
/screenshot/diff to take the screenshot and compare it to a known-good
version.

The screenshot is a full-page screenshot, since element screenshots
don't work consistently across all the browsers in our test lab.  The
screenshot is then cropped to a rectangle specified in the request.
This rectangle is measured to match a specific element, so in
practice, we are screenshotting just one element.

Browsers use sub-pixel rendering, effectively rendering at a scale
larger than the "pixels" seen by JS.  The screenshot comes in at this
scale, so the requested cropping rectangle is scaled to match, then
the cropped screenshot is scaled down to the JS-measured size.

Because of sub-pixel rendering, element offsets can be non-integer
numbers.  Normally, Karma puts the tests in a iframe, above which is a
variable-height banner showing which devices are connected to Karma
and what state they are in.  So this variation and the lack of integer
offsets means we can run into stability issues due to rounding errors.
To make offsets consistent and improve stability of the screenshots,
this banner is now disabled in our Karma config.

The cropping, scaling, and diffing of images is handled Karma-side by
a node module called Jimp.

Before we start the layout tests for UITextDisplayer, we use a node
module in the browser called fontfaceonload to wait for our web fonts
to be fully loaded.  This module is a polyfill that polls on IE and
uses a standard API in modern browsers to wait for our font to load.
This is all wrapped into a new test util called waitForFont.

Screenshots are stored in test/test/assets/screenshots/ and are
organized into folders by platform and browser and named according to
an identifier specified by each test case.  The new screenshot is
written to disk with the suffix "-new", and a diff image is written
with the suffix "-diff".  When a test fails, we can review the changes
in a browser with test/test/assets/screenshots/review.html.  The
known-good screenshots can be updated with the new tool
build/updateScreenshots.py.

Change-Id: Ib477fd3c459de466c6dc91e9a60d3e2579164b12
2020-05-26 22:38:04 +00: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
michellezhuo 562168a1f6 Set UITextDisplayer as TextDisplayFactory in default config
In player, SimpleTextDisplayer was set as the default TextDisplayer. In
our UI, it changes the configuration to use the UITextDisplayer, and
UITextDisplayer gets constructed with the player. Later in our demo, it
resets the config, so an extra SimpleTextDisplayer gets constructed.
This introduces an extra TextTrack created by SimpleTextDisplayer.

This change sets the UITextDisplayer as the default TextDisplayer in
player's default config.

Closes #2516

Change-Id: I3f653be9fad8b2edbc2fb9de84e8abb327dcfc51
2020-05-04 20:40:18 -07: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 c5b292a84e Fix cue types in tests
The tests for shaka.ui.TextDisplayer created some Cue objects to
verify their rendering.  These used string literals where they should
have been enums, and the newer compiler didn't like that.  It also
complained that we had assigned a number where there should have been
a string.  This fixes both issues.

This was caught by a compiler upgrade.

Issue #2528

Change-Id: Ie3f1e79ca1ed2745f55b270e13411966940cdf62
2020-04-29 22:16:47 +00:00
Sandra Lokshina 8cb5001984 Replace our skip button with the IMA's default one.
According to the agreement with the IMA team, we will
no longer hide their UI during ads. Instead we will
incorporate their elements into our layout.
(Some of the elements they expose are legally required
or business critical for partners for certain types of
ads).
This change replaces our skip button with the IMA one
and tweaks our layout to make it fit better.
We are keeping our ad counter and the 'Ad X of Y'
element.
Our skip button will stay in the library, and we will
use it for other (non IMA) ad integrations.

Change-Id: I648c6c65a34607685a409a264c2a03d74cc4d461
2020-04-22 21:03:11 +00:00
michellezhuo 030147c7f4 Avoid displaying duplicate vtt cues
Closes #2497

Change-Id: Ibc4de196f500d8685244217f9a056d8b12c05f8a
2020-04-20 22:58:45 +00:00
Joey Parrish 083099b127 Cleanup DOM after text displayer tests
These tests added a container to the DOM which was never cleaned up.
There is no impact to Shaka Player, and no performance impact to the
tests, but we should clean up after ourselves.

I found this by running the Karma/Jasmine tests in a foreground
browser tab at http://localhost:9876/debug.html .  After the tests
completed, I looked at the "Elements" panel in Chrome's dev tools.

Change-Id: Id81dddcb82b01eeb6445ddd701d2d3907c322a0d
2020-04-16 17:38:08 -07: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
Sandra Lokshina fcc27b144a Hide overflow menu while ads are playing.
Change-Id: Ia77f0996c919e78b0a08b90e878c5615dcccf5bf
2020-04-07 18:32:13 +00:00
Sandra Lokshina 8107d1dfb3 Restore original ad manager factory after ad UI tests.
We suspect this is related to test failures on the ad tests CL.

Change-Id: I90265153a128eec926cfdf3eb61b078cb4d98ae5
2020-04-03 17:53:24 +00:00
Theodore Abshire d1dce29e89 Added 'doubleClickForFullscreen' config to UI.
This configuration, which is true by default, lets a user optionally
disable the "go fullscreen on double-click" functionality.
This allows a developer to fully disable fullscreen mode, if they so
wish, or to retain the fullscreen button but disable other methods of
entering fullscreen.

Issue #2459

Change-Id: I196602fc9843e0fd799c78703de60f864e906841
2020-03-16 17:03:53 +00:00
Álvaro Velad Galván 935040a3b5 Add ebutts:linePadding to ttml parser (#2443)
https://tech.ebu.ch/docs/tech/tech3380v1_0_1.pdf Section 2.1

Resolves #2407
2020-03-13 11:22:19 -07:00
Sandra Lokshina 9a19821292 Add timeline ad UI tests.
Issue #2367.

Change-Id: I49042992f4462f35e48292e79a09fef779494faa
2020-03-11 18:52:16 +00:00
Sandra Lokshina 30131c3d7c Add more ad UI tests, augment loc string for ad position.
Issue #2367.

Change-Id: I562ef9e6c6a84a4a113792b647a5c663bcd822bf
2020-03-11 16:47:31 +00:00
Sandra Lokshina 6adc977022 Add tests for ad UI (adUIContainer, skip ad button).
This change creates mocks and fakes for ad testing and adds
tests for the ad container and skip button. Skip button
tests found a bug - this CL also fixes it.

Issue #2367.

Change-Id: I36cb293f9611fbc8592bdc32e156f17a7a78e010
2020-03-09 16:33:10 +00:00
Tanya Gelahova d6de4e710d Add support of fontSize in percentages and cell resolution unit for TTML captions (#2442)
Closes #2403
2020-03-06 08:53:24 -08:00
Jacob Trimble bc45564721 Remove deprecated ability to pass factories to load.
Player.load and Storage.store used to accept the manifest parser factory
directly.  But now they should only accept the MIME type string.  This
removes the deprecated functionality in preparation for v2.6.

Change-Id: I1b4c5a4a9f0b6edbea909d18111ddc87a39da331
2020-02-20 23:44:51 +00:00
Jacob Trimble 3f63021a2f Avoid using "new" with factories.
Instead of having the "factories" use "new" to construct them, now they
will be plain functions.

Closes #1521

Change-Id: Ia6151ad679a78a5c6db128d43094c82add0af348
2020-02-19 09:57:51 -08: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 702dc360e0 Fix destroying UI in some tests.
These tests were creating two UI instances in the same container.  This
caused the second one to replace the first without destroying the first.
This caused test contamination since there could be extra CastProxy
instances.  This wouldn't always happen since the no-longer-referenced
objects would be garbage-collected eventually; but depending on timing,
the CastSender tests might fail.

Change-Id: I7f4a008f56224ee33bee15c5e0370a225a5fc033
2020-02-14 23:11:15 +00:00
michellezhuo cfe1f89171 Add playback speed selection to UI
Closes #2362
Closes #1676

Change-Id: I10184dccab301be7382940e35e36d66dc7a5e2ad
2020-02-12 20:24:03 +00:00