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
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.
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#3521Fixes#3600Closes#3713
Change-Id: I45fc88dcac4a0a062e1474087f24c80d98eef619
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
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
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
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
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
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
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#2869Fixes#2943
Change-Id: I3cf67b0b278764c10c6ff2f678316dc9cc85929e
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
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
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
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
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
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
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
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
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
This removes double-newlines and adds comments to indicate what the
end of a describe block corresponds to.
Change-Id: I6832b52c3d849896d0c8e93bd8f27a22e665c3f6
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
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
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
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
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
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
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
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
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
Instead of having the "factories" use "new" to construct them, now they
will be plain functions.
Closes#1521
Change-Id: Ia6151ad679a78a5c6db128d43094c82add0af348
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