Commit Graph

1057 Commits

Author SHA1 Message Date
Theodore Abshire fe7f42105f Fix presentationDelay being set to NaN.
In the DASH parser, if there was no suggestedPresentationDelay and
ignoreMinBufferTime was set to true, the parser would set the
presentationDelay to NaN. This was because Math.max() will return NaN
if undefined is passed into it.
This changes minBufferTime to default to 0, if ignoreMinBufferTime is
true.

Fixes #2015

Change-Id: I8fc61706a04d14fd729e2185ce993a8bc87e48e5
2019-07-01 11:53:30 -07:00
Jacob Trimble a27f50dd43 Avoid changing variant when switching text lang.
This fixes a TODO and fixes setting the "active" track when switching
languages when not displaying text.

Fixes #2010

Change-Id: Ic4cf4126ffb9b93a09af998e20f9da0e7af852fb
2019-06-27 18:40:28 +00:00
Jacob Trimble 47533d1173 Add an enumerable() method for loops.
This is a helper to aid in iterating over items.  This returns a list
of objects that contain:
- "item": The current value.
- "prev": The previous value in the list.
- "next": The next value in the list.
- "i": The zero-based index in the list.

Issue #1518

Change-Id: Id18ab977e3ae45dfbfd2b4137a1bffb6e53c6bce
2019-06-27 16:31:42 +00:00
Jacob Trimble 60d2f1cc82 Work around MediaSource duration bug.
Fixes #1967

Change-Id: Ie2a41cb17427316ce65cf180507c1fb1f2c6f11a
2019-06-26 20:57:30 +00: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
Jacob Trimble 010a60b8f1 Use objectContaining in text tests.
Instead of checking each property separately, just use
jasmine.objectContaining.  This also adds a utility for matching a
number that is close to an expected value.  This is required when
matching objects with toEqual().

Change-Id: I4de49cfaf254e0752beffc97c578a77f9ec8ee95
2019-06-26 18:54:13 +00:00
Jacob Trimble b235ca4fe7 Favor expect.not.toHaveBeenCalled.
Change-Id: I7009ff69bfca5ef8a38bcdff73a16a02cfa205b1
2019-06-26 18:53:00 +00:00
Jacob Trimble e2ba179201 Favor using toHaveBeenCalledTimes.
This gives better error messages than using toBe() or toEqual() with
the number of calls.

Change-Id: Ice353f1ebcc715da69416da2d983e919597f82d1
2019-06-26 18:52:36 +00:00
Jacob Trimble 2d4904cb75 Add tests for errors during clear buffer.
This error wasn't caught before, but was fixed in a recent CL.  This
adds a test to ensure we don't regress later.

Change-Id: I10e72303c39de82bb9a1f7cb4a6b171c46fdbecd
2019-06-26 17:50:01 +00:00
Jacob Trimble f6d0f15fa6 Refactor handling of destroy().
This changes several classes to use the Destroyer class to handle
destroy().  This also changes the behavior to not ignore destruction
and instead throw a new error.  This is more clear for callers and
ensures we propagate errors.

Change-Id: I756c085639558509c22e5c43d69ddf4acd28d46f
2019-06-19 20:39:20 +00:00
Jacob Trimble 52522c7dca Fix cases where errors weren't propagated.
This propagates errors in several places and fixes waiting for some
async calls.

Change-Id: Idf4519b473538c1fa00bfe63e634194610ba29f2
2019-06-19 20:35:30 +00:00
Jacob Trimble 5aed799cb9 Avoid PromiseMock in DASH live tests.
This converts them to be normal async tests instead of mocking the
clock and Promises.  This uses some internals on the DASH parser for
updates to allow the tests to complete quickly.

Issue #1379
Issue #1953

Change-Id: I6d21d124a290920e568b8a275221140e1b27941b
2019-06-19 20:30:43 +00:00
Jacob Trimble e31f4ec3c8 Fix playback rate errors on IE11.
Apparently calling play() causes the playbackRate to be set back to 1,
so we need to call play() before setting the rate.

Fixes: 135520981
Change-Id: Ibea1cbd7c0ee4605b10b0fee87a8b5c069e04fa3
2019-06-18 22:53:59 +00:00
Jacob Trimble e2fa4626b5 Decrease time it takes to run tests.
- Reduce times for "short delays".
- Remove backoff delay from networking tests.
- Avoid hard-coding delays in the library.
- Move Storage tests to integration tests since they use indexedDB (and
  take over 200ms each to run).

This reduces the time it takes to run unit tests (with --quick) from
50 seconds to about 6 seconds.  Now all but one unit test finish <100ms.

Change-Id: I88461472a87c4cf750a36d07d07422818e069a4d
2019-06-12 20:53:08 +00:00
Sandra Lokshina 0e317d64e0 Add tests for UI reconfiguration.
Change-Id: I695b8bd18a42db74fe3adb45b31aae2579448310
2019-06-11 22:20:13 +00:00
Jacob Trimble 3da809019b Enable additional ES6 linter rules.
Change-Id: I6861541b27153ba034364a5972a9b086de581cef
2019-06-11 18:35:09 +00:00
Jacob Trimble 1d33b748d8 Fix recent MediaSourceEngine test failure.
A recent refactoring caused a test failure on Chrome due to a Promise
getting rejected without a "catch" block and getting an unexpected
rejection error.  This adds the expectation first so we don't get that
error.

This also removes the empty "catch" blocks since we use async/await,
which introduces another Promise, so the "catch" block won't suppress
the unhandled rejections like we want.

Change-Id: Ib217b4b374668d800a0eeb1a9b8069269bccf261
2019-06-11 10:32:16 -07:00
Jacob Trimble 8130e7ca42 Refactor StatusPromise use in MSE test.
The StatusPromise isn't needed when just checking for resolve/reject;
we can use await or expectAsync for that.  So this removes the usages
of StatusPromise that only check for resolve/reject.

This also renames the destroy() variables to "d" to make them different
from the operational promises.

Change-Id: I48e807d84e56ee28b7489c572570e11e6325a4ed
2019-06-10 22:25:51 +00:00
Jacob Trimble f3f427eb0b Disallow naming variables "async".
Fixes #1588

Change-Id: I2e1fc04a18d3f52e4fc46aa7b7b558989d5bced2
2019-06-10 21:56:19 +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
Theodore Abshire b805d15444 Convert externs to ES6.
Issue #1157

Change-Id: Ib8ddecc7106fea8c24c10cfac406c4709a3f275b
2019-06-10 17:52:08 +00:00
Jacob Trimble 94a47ec61f Add a generic test filter.
This add a filterDescribe that can be used to filter groups of tests
based on platform support.  This consolidates the different test
filtering to one place.

Change-Id: I8f320fcf0edfa2d984433890fcfc3714e78b195b
2019-06-07 18:56:38 +00:00
Jacob Trimble 98aa050de9 Fix addEventListener on some platforms.
Some platforms (e.g. IE11 and Tizen) don't support passing an object as
the third argument to addEventListener.  When we do, it interprets it
as a "true" for the capture value and causes the listener to be called
at the wrong time.  This now detects whether the browser supports this
and calls the boolean version if not.

Fixes #1979

Change-Id: I05b3f5e536a9bcb5c275cac7f243a9ccc88f8149
2019-06-07 16:46:57 +00:00
Michelle Zhuo f67df3d7ad Use eventManager.listen() instead of addEventListener in UI
Issue #1924

Change-Id: I9870d4002fd5f0f99b5de164de41b107af1b3d9b
2019-06-05 16:25:26 -07:00
Joey Parrish b042a8198b Upgrade to Jasmine 3
This upgrades our version of Jasmine and drops the expectAsync
polyfill we added to compensate in Jasmine 2.  This also drops the
direct dependency on Jasmine, preferring the indirect version expected
by an upgraded version of karma-jasmine.

Closes #1949

Change-Id: Ibbdb26e9a20ab9b9d8b152678b65c63feed8633c
2019-06-05 20:43:33 +00:00
Joey Parrish 6a0b45596f Fix test scheme plugin
It's not clear how this mistake went undetected, but the build bot
passed it.  Without this fix, plenty of tests are failing.

Change-Id: I576e079b4f997cb2c89ca3ba4484312d42c7541d
2019-06-03 20:06:10 -07:00
Jacob Trimble 7ecce742d2 Misc test ES6 changes.
Issue #1157

Change-Id: I47f537bca5106b4ffca5db3182c8a268d2f3d24a
2019-06-03 22:00:21 +00:00
Joey Parrish d2013e7da1 Fix const violations w/ newer compiler
These modules are loaded by the tests w/ require() and assigned to
window, but the externs declare the namespaces as "const".  If they
are declared const, then assigning them in test/test/boot.js is a
problem for the newer compiler.  To work around this, assign them
using bracket notation.

Issue #1852

Change-Id: I2319ada7cdf502b5f1a5a3e65e9491c666404c89
2019-06-03 21:53:47 +00:00
Jacob Trimble 0d75c33b86 Convert cast tests to ES6.
Issue #1157

Change-Id: Iec39608591931afde22f3d7d7904e0dadc8ffd78
2019-06-03 11:52:25 -07:00
Jacob Trimble 799e96c05c Convert test utils to ES6.
This also removes the unused SimpleIDB type and removes the duplicate
code in Utils that appears in Waiter.

Issue #1157

Change-Id: Ib3cfc16212b9d169b360825a25a084c5ebd7b80f
2019-06-03 18:41:17 +00:00
Sandra Lokshina 382d16bcd7 Show spinner when buffering even if other controls are hidden.
Fixes #1921

Change-Id: If7cfac07e09893b3f087c033bd3bb2d7f66dc463
2019-06-03 18:31:08 +00:00
Joey Parrish 8569b1a2c7 Fix CastSender test flake
"CastSender init installs a callback if the cast API is not available"
would fail sometimes with an upgrade to Jasmine 3 (5/500 times).  The
failure had to do with the use of a global initialization callback.
It is not clear why upgrading Jasmine caused this issue to become more
apparent.

The test expected that the callback would not exist until an instance
had been created.  However, the callback, being global, might still be
around from another instance.  The callback would only be removed
after a successful initialization, so if an instance were created by
another test suite (such as the UI), and destroyed before being
initialized (a normal thing in a test environment with no cast API),
then the global callback would still exist when the CastSender tests
were run.

The best solution seems to be:
 - Decouple the global callback from any particular instance of
   CastSender, and use it to initialize any living instances of
   CastSender when invoked
 - Remove expectations on the prior existence of the global callback
   when the test begins
 - Don't rely on the global callback in the unit tests, since
   integration tests at the top level can overwrite the global
   callback when they load the compiled build

After the fix, the test passed in 500/500 complete test runs.

Change-Id: Id5f5775cf0860d5dfbd6aeb87fa11fd2f2a1297e
2019-06-03 16:53:36 +00:00
Jacob Trimble 3cdadc3db9 Convert HLS tests to ES6.
Issue #1157

Change-Id: I7997921809076fa5e36653f51af32ee11b50ab88
2019-06-03 15:29:26 +00:00
Chris Fillmore d846e58af6 Add originalUri as a property on shaka.extern.Response (#1972)
This property tracks the original request uri, which would be
useful to know in the event of a redirect.

Fixes #1971
2019-06-01 13:30:41 -07:00
Joey Parrish 615ce93178 Fix formatting of test failures/errors
Code in karma-jasmine's adapter will malform test failures when the
expectation message contains a stack trace, losing the failure message
and mixing up the stack trace of the failure.  To avoid this, we
modify shaka.util.Error not to create a stack trace.  This trace is
not available in production, and there is never any need for it in the
tests.

One test expectation had to be updated.  The previous version of
jasmineError would use the original error by reference.  Now that it's
capturing a few fields explicitly, the severity value doesn't update
when NetworkingEngine modifies the original.

Change-Id: If7af93a1a0357df9763dbf6a4afc45db2c8317df
2019-05-31 21:29:27 +00:00
Michelle Zhuo 8c8552ae7c Update media files to ES6
Issue #1157

Change-Id: I82213c9a20e7aa6e506732dc0295a61d2a67b1ec
2019-05-31 17:44:36 +00:00
Theodore Abshire 3de04a92d0 Convert simple abr manager unit to ES6.
Issue #1157

Change-Id: I55a732a76d89217b677c375d4000fef2947018ae
2019-05-31 02:11:54 +00:00
Jacob Trimble e966945f61 Convert DASH tests to ES6.
Issue #1157

Change-Id: Iee2c8daede491e832bc2fd790a6d6b15fb019619
2019-05-30 21:52:13 +00:00
Jacob Trimble 78d9fc840a Convert network tests to ES6.
Issue #1157

Change-Id: I30e39927c70d61f29d45698507b6ba809b33e2f3
2019-05-30 19:57:36 +00:00
Jacob Trimble 61d71df219 Convert media tests to ES6.
Issue #1157

Change-Id: I007f5dd43f297ca108cbb2caa7a9118527722350
2019-05-30 19:54:16 +00:00
Theodore Abshire 34e6ea4fba Convert FakeEvent and FakeEventTarget to ES6
Issue #1157

Change-Id: I027a1177fcd098f458b2cc3c3d92f93b43d26447
2019-05-30 17:11:12 +00:00
Theodore Abshire b59e4ce1a8 Make Player and CastProxy into ES6 classes.
CastProxy needs to be converted at the same time so that it can properly
adapt to the changes to Player's structure.
This only converts those classes to be ES6 classes, and does not make any
other ES6 conversions to them. That will be a follow-up CL.

Issue #1157

Change-Id: I0e0f2ce9a62639060a645969a9cc2ae6d0a400cd
2019-05-30 16:55:13 +00:00
Joey Parrish 92ef26cf56 Fix StreamingEngine test flake
"StreamingEngine switchVariant/switchTextStream will not clear buffers
if streams have not changed" would fail sometimes with an upgrade to
Jasmine 3 (14/500 runs).  Further investigation revealed that a race
would cause the presentation time to be accessed before it was set,
which led to a segment position of NaN, and a segment reference with
start and end time of NaN.  It is not clear why upgrading Jasmine
caused this race to become more apparent.

This fixes the problem at several levels:
 - An invalid segment position in the ManifestGenerator will cause a
   failed assertion.
 - An uninitialized presentation time in the StreamingEngine unit
   tests, which led to the invalid segment position, will cause a
   failed assertion.
 - The presentation time for the switchVariant test is now initialized
   properly.

After the fix, the test passed in 500/500 complete test runs.

Change-Id: I5c4c52a9e2a89edb61f7d99721be3df840bba30d
2019-05-30 05:39:33 -07:00
Jacob Trimble e46ecdbdfb Convert simple_fakes.js to ES6.
This changes how the spies are created.  This should still allow using
them as their base classes but still access the spies as a spy (i.e.
using their "calls" property).

Issue #1157

Change-Id: I36840bcc8f4491eedbe90019047228bc65a048a2
2019-05-29 16:35:06 +00:00
Sandra Lokshina 0e7c366e9d Convert more utils to es6.
Issue #1157.

Change-Id: I49092237b7fe7f98a22087b0ecf41f65005dbc61
2019-05-28 22:17:48 +00:00
Jacob Trimble 12d71f9ebd Convert ui and util tests to ES6.
Issue #1157

Change-Id: Ib4edb2eb06a302385ca7ca084367803356b8aae6
2019-05-24 20:54:48 +00:00
Jacob Trimble a0392286b2 Convert offline tests to ES6.
This also fixes some bugs in the errors that were thrown from the
offline code.

Issue #1157

Change-Id: Ia0a0df458e764df5693ea3e6c1f38f91712e5280
2019-05-22 16:34:20 +00:00
Jacob Trimble e59187adf5 Convert player tests to ES6.
Issue #1157

Change-Id: Ib405576ff77e324e5586b93cdbfddcde69d264ab
2019-05-22 16:14:19 +00:00
Joey Parrish 393b0ecea7 Fix HTTP test failures
This makes progress callbacks into a required parameter on all network
scheme plugins.  This does not mean that every plugin must make use of
the callback, but every caller must supply the callback.

In production, NetworkingEngine already supplies this callback
universally, so our HTTP plugins make use of it whenever progress data
is available.

Our tests, however, did not always supply this callback, leading to
test failures.  These failures were more likely to show up in Jasmine
3 than Jasmine 2 for some reason, which caused us to downgrade back to
Jasmine 2 recently.

By making the callback required, we can clean up this inconsistency
between test and production and give the HTTP plugins what they expect
in all cases.

Issue #1949

Change-Id: I8a6e1904e73cf7ca6ae8f3964261c339f404854d
2019-05-22 15:42:06 +00:00
Jacob Trimble a69047ba0d Convert text tests to ES6.
Issue #1157

Change-Id: I839d4ab38324a2247bb3c788837a16652d401595
2019-05-21 22:56:34 +00:00