Commit Graph

55 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 0df39c62b6 Add content metadata methods to CastReceiver
This change adds the following methods on CastReceiver:
 - setContentMetadata(metadata)
 - clearContentMetadata()
 - setContentTitle(title)
 - setContentImage(imageUrl)
 - setContentArtist(artist)

These should be called from the CastReceiver's app data callback.

The title, image, and artist methods cover all the Cast content
metadata fields that have an effect in the Google Home App as of June
2020, and setContentMetadata can be used to set one of several object
formats with many more fields defined in the Cast SDK docs.

See https://developers.google.com/cast/docs/reference/messages and the
definitions of GenericMediaMetadata, MovieMediaMetadata,
TvShowMediaMetadata, and MusicTrackMediaMetadata for details.

This also uses these methods from our cast receiver demo, so our demo
will now set all possible metadata when casting our content library.

Closes #2606

Change-Id: I6386276449dbddd2501cd6e3e52206f7fb30b8fd
2020-06-04 20:59:08 +00:00
Joey Parrish a132592b20 Add regression test for Google Home scrubber fix
The fix for Google Home scrubber in 8c3775ce (Change-Id
Iceec95f18cf15325b7ee2350a0f30f31edc90560) did not come with a
regression test.  This change covers that fix with an automated test.

I have confirmed that the test fails without the fix.

Issue #2606

Change-Id: I13a2bcfb2fcca059db4e909d7c27fb68b0bfb409
2020-06-03 23:03:13 +00:00
Joey Parrish b48d35f16e Minor refactor and cleanup in cast tests
Details of the cleanup:
 - Don't replace the load() spy with a non-spy
 - Fix an out-of-date comment on an explicit delay in a test
 - Hoist expectMediaInfo helper to make it available for all tests
 - Simulate loading content before the "generic controls messages" to allow the
   use of expectMediaInfo
 - Don't do a substring comparison on a JSON blob, which is inherently
   unreliable, and compare the parsed object structure instead

Related to #2606

Change-Id: Ifb46e223ba800c0e10cbdfa6cb847faa8424cd3d
2020-06-03 23:03: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 e70a516228 Fix implicit string-to-number conversions in tests
This was caught by a compiler upgrade.

Issue #2528

Change-Id: Iae8c495e58347b5c4184bfcec15ff9a48abe6214
2020-04-29 11:25:16 -07: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 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 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 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
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 0d75c33b86 Convert cast tests to ES6.
Issue #1157

Change-Id: Iec39608591931afde22f3d7d7904e0dadc8ffd78
2019-06-03 11:52:25 -07: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 381274fbbd Enforce a consistent dot location.
Change-Id: Ic3b86c4c113023206bc37a117e96f672f351121b
2019-05-09 21:09:30 +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
Jacob Trimble c81389741f Prefer const over let.
A coming update to the Google eslint config will require using "const"
over "let".  This makes that one change to isolate the big changes.

Change-Id: I7d0974c3ae15c53cc45a6b07bf9f6586e2d34aca
2019-05-08 09:22:10 -07:00
Joey Parrish 7091275cbf Replace indexOf with includes, startsWith
This replaces almost every instance of indexOf on both String and
Array.  There are very few places where we really wanted an index.
Mostly, indexOf was used to check for inclusion.

Change-Id: I08e299768b6ffdb4bfc30b39b5d82a058c6d1b56
2018-09-14 19:10:56 +00:00
Aaron Vaage c17114e29f Change |manifestUri| to |assetUri|
In preparation to supporting non-manifest assets, let's change
|manifestUri| to |assetUri| as it is a more broad name.

Issue #816

Change-Id: Ibec761caa8acf173571592ce0a7029af0f60de68
2018-07-25 18:10:39 +00:00
Joey Parrish fd0449d8f7 Re-enable some disabled style rules
This re-enables the following style rules:
  - "block-spacing"
  - "brace-style"
  - "comma-dangle"
  - "comma-spacing"
  - "new-cap"
  - "no-multi-spaces"
  - "no-multiple-empty-lines"
  - "one-var"
  - "padded-blocks"
  - "prefer-rest-params"

Change-Id: I15d616e8d5b88b273ded6128b4f9ad86bdb26bd1
2018-07-09 19:44:56 +00:00
Michelle Zhuo 535de4db84 Refactor: Remove underscore from parameter names
Change-Id: Ie9e6fb59763f454f245175f23c6444f919ba8135
2018-05-08 19:21:51 +00:00
Joey Parrish f48f7fd9c4 Clean up uncaught Promise rejections
- Translate uncaught Promise rejections into test failures
   (Chrome only until the event is more widely implemented)

 - Clean up uncaught Promise rejection caused by exceptions thrown
   after destroy() in:
   - CastProxy
   - CastReceiver
   - NetworkingEngine
   - StreamingEngine

 - Clean up uncaught Promise rejection caused by test cases in:
   - CancelableChain unit tests
   - DrmEngine unit tests
   - StreamingEngine unit and integration tests
   - Player unit and integration tests

 - Speed up rejection in NetworkingEngine when we should not retry

 - Add --delay-tests to test.py, to aid in debugging uncaught
   Promise rejections and other types of async test pollution

Closes #1323

Change-Id: I5a8f5702a22430929babeb071bf6650c52c5ad17
2018-02-28 22:56:12 +00:00
Jacob Trimble 064089152b Remove spacing around object definitions.
This is an automated fix to be inline with Google style guides, this
was created with eslint's --fix option.

Change-Id: I860eecbc8152603e730aa17a1393f16d26b3b6fc
2018-02-21 13:35:00 -08:00
Jacob Trimble 624acc66b8 Add curly braces to all blocks.
Google style guide requires adding curly braces to all block statements
even if it is only has one line.  This fixes it by using eslint's
--fix flag followed by running clang-format to reformat the change.

Change-Id: Idc086c2aa8c02df5ef8b2140a11bfb9128eeb4bd
2018-02-21 11:23:34 -08:00
Jacob Trimble 61fc107be3 Convert 'var' to 'let'/'const' (1 of 9).
This is part of a change to convert all usages of 'var' with either
'let' or 'const'.  This takes a conservative approach for 'const' where
it will only be used for aliases and storing the "original" values in
tests.

Change-Id: I8f857a24e4c1ad336177d23dfed4f4a29d3262d2
2018-02-13 13:40:02 -08:00
Theodore Abshire be5c80eb6d Standardize feature support checks in tests
This replaces checkWhatever type functions, which are called at the
start of a test, with checkAndRun functions, which are a wrapper
around the test method. This change standardizes our tests, since
checkAndRun functions are used in the db engine tests but not
elsewhere.

Change-Id: I74c7ac6836bbaab15b57fd480dbd6105ddc5ee60
2018-01-26 16:55:44 +00:00
theodab c2ce686fb0 Send MediaInfo message with duration when casting
When casting, the cast dialogue contains information about the current
media, including volume, time, and duration. These values are
synchronized by different messages. We were sending over the
MediaStatus messages that synchronize current time, but were not
including duration in our MediaInfo messages. This caused the cast
dialogue progress bar to not display correctly.
This change makes it so that our MediaInfo messages now include
duration, and we now send over MediaInfo messages in situations where
we did not previously.

Closes #1174

Change-Id: Ic585f3befec9e44ef4e9895d04ddfad6cc5473b3
2018-01-19 22:19:58 +00:00
Joey Parrish 529e97fbf2 [ES6] Configure eslint with Google style checks
Some style rules are temporarily overridden until we can get in
compliance.

Issue #1157

Change-Id: Ie27be6ec6632b7786a1f9ebc32911ba9dcd42599
2018-01-18 00:01:05 +00:00
Joey Parrish a63352c8f3 [ES6] Enable stricter checks in eslint
This digests and organizes many of the automatic settings in eslint,
and changes several of them to be more strict.  This also fixes the
following errors:
  - array-callback-return
  - no-catch-shadow
  - no-multi-spaces
  - no-new
  - no-throw-literal
  - no-useless-call
  - no-useless-concat
  - no-useless-return

Several checks have been organized into a group of checks we should
use, but need more time to implement and fix.  Some other checks have
been delegated to the Closure compiler, which can more precisely
whitelist exceptions.

Issue #1157

Change-Id: I8fe4966959e08050f8159e6a1fee161e7d71177e
2018-01-17 21:56:41 +00:00
theodab 8ed316d3c2 Reduced frequency of some getters on cast updates
Not all values need to be updated twice a second. This change modifies
the list of player getters so that each value also includes an update
frequency, and only updates that property once in that many updates.
This acts as a configurable way to ensure that some properties update
in different amounts, without having to have multiple update timers or
compose multiple update messages in the same timeframe.

Change-Id: I90e75e3e73f6c633d91b1799307ec2b15587327b
2017-12-14 21:02:48 +00:00
theodab 95d2855b8f Fixed a problem with live-only getters on cast
Beforehand, the Chromecast would poll getPlayheadTimeAsDate and
getPresentationStartTimeAsDate for every update message, which are live-only
getters, even on VOD.
This would cause a lot of error messages in the debug output of the receiver;
we didn't notice this before because we mostly run the receiver in compiled
mode.
This also allowed users to poll those attributes for VODs without any error
messages when casting, since the results of the last update were cached.

This change adds a list of getters that require live; such getters are not added
to state update messages, and are set up with asserts in the sender.
This should solve the problem and slim down our update messages a bit at the
same time.

Change-Id: Ifc0b445def2d85b22fcb9af160dec2205d1faace
2017-08-28 17:57:58 +00:00
Jacob Trimble 30450f8cbb Fix Chromecast tests and add missing members.
There was a bug in the cast_utils test that meant that the new members
on Player weren't being detected.  The test should fail when we forget
to add a new member to the list in cast_utils.js.  This updates the
test and adds the new members to the list.

Change-Id: I27c25d07b409b8350b5709c3ce26696d72a6a11d
2017-08-18 17:51:52 +00:00
Joey Parrish 6834054906 Remove deprecated methods for v2.2
The getTracks and selectTrack methods have been deprecated since v2.1
and scheduled for removal in v2.2.

Change-Id: I938b3015262d71683ac871c05a9f4c74c96acf50
2017-08-10 18:56:09 +00:00
Jacob Trimble adb8da4764 Disallow unknown properties (1/5).
This is part of adding a new conformance rule to add additional type
safety.  This will disallow using properties of unknown types or using
unknown properties.

The first parts will be fixing errors caused by the new rule.  These
are backwards compatible, so can be applied before the rule is enabled.
Once all the errors and bugs are fixed, the rule will be enabled.

Change-Id: Iefde089b2f62ddfdf43944cda5badab438577561
2017-06-27 19:43:00 +00:00
Jacob Trimble d8a3d8d2f7 Change jasmine.Spy type definition.
The old definition using a union with a Function causes problems.  The
compiler tends to treat this as an unknown type, so we loose type
safety.  The new types ensure full type safety, at the cost of needing
to "convert" the spy when it is used as a function.

Change-Id: I98ebd9dffd9cb865d0cf5d03db0fb5d6ea001ed3
2017-06-27 12:18:48 -07:00
Joey Parrish 80251cdf91 Fix DRM test errors on IE and Edge
Somehow, errors thrown by CastReceiver unit test setup caused DRM
tests on IE and Edge to fail.  This cleans up the Cast tests to fix
these uncaught errors that somehow polluted the DRM tests.

Change-Id: I435ff994b0b70199eb5a8febd419296b59497920
2017-06-05 20:18:06 +00:00
Sandra Lokshina 843f020008 Chromecast: add support for Media Playback messages.
Media Playback messages are used by generic Chromecast controllers
(Google Home app and the likes). Supporting them is required by
the Chromecast SDK.

Closes #722.

Change-Id: I3c98fb9d63da81b59c2cc82a3e790332fc9bb56e
2017-04-11 19:00:54 +00:00
Jacob Trimble 575f2ad109 Add an indicator for critical errors.
This adds a severity field to Error objects.  This can be used to
detect whether an error is recoverable.  All the same errors are still
reported so the field can be ignored.

There are two possible values:
* RECOVERABLE means that the Player will try to recover from the error
* CRITICAL means the Player will be unable to continue and must call
  load() again

Closes #564

Change-Id: Ie2c5468340c13e7a288b99690ab65b7ecc0a6b29
2017-04-04 23:57:59 +00:00
Jacob Trimble b4d0fa4901 Expose license expiration times through Player.
This adds a method on Player to get the license expiration times for
the current EME sessions.  This also adds the expiration times to the
stored content structure for offline content.  This will update the
stored expiration while playing content (e.g. license duration changes
when playback starts).

Closes #727

Change-Id: I18770a79413423695bbb2ed5f31f6b19038a33d2
2017-04-03 18:25:43 +00:00
Jacob Trimble 67c874c2ca Fix some test contaminations.
There were two instances of tests not cleaning up correctly.  The
Dash Live tests didn't uninstall the Promise polyfill, which breaks
Promise.resolve for tests that don't expect it.  Also, in the
CastReceiver tests, it defines a property on window.  It needs to be
configurable, otherwise it cannot be set twice.  Somehow the resulting
exception is not being caught by jasmine.

Change-Id: I0691a7bcddf14fd455f034d63e12fc8046044750
2017-03-28 12:16:08 -07:00
Jacob Trimble 6ba6b0631c Consolidate usages of fake video elements.
There are several tests that use fake <video> elements.  All of them
have a createMockVideo method.  This consolidates all of them into a
fake class that also provides more type safety.

Change-Id: I132c3e4a75676594bcefb60d0b115c00ede03067
2017-03-03 19:57:08 +00:00
Sandra Lokshina 23a23b9b36 Make language selection explicit. Split text and variant selection.
Add UI options to select current audio and text language.
Split selectTrack() into selectText() and selectVariant().
Stop automatically disabling ABR manager when a variant is selected.
Add a warning if selectVariant() is called while abr is enabled.

Issue #412.
Issue #626.

Change-Id: I15f1c3c4fdc6d6b641f708fbef19dbcf10cbcfc6
2017-01-18 00:05:52 +00:00
Joey Parrish 5fb8b60422 Add support for Chromecast Ultra at 4k
Using a special API available on the Chromecast, determine if we can
do 4k.  If so, raise the hardware limit from 1080p to 4k.

Change-Id: I6e403cce5d9c43a22f1b76cf4d79661ac096dd82
2017-01-11 18:49:01 +00:00
Joey Parrish 2cfaf366e9 Add missing events and methods to cast proxy
The emsg, loading, and unloading events were present in v2.0.0.
The drmInfo, isInProgress, and keySystem method were also present in
v2.0.0.  The getPlayheadTimeAsDate method was introduced in v2.0.1.

None of these were proxied to the cast device until now.  All v2.0.x
events and methods are now being proxied.

Change-Id: I6fba60f4ca451053c1449cafcddd9c1006292ad9
2017-01-07 00:14:41 +00:00
Joey Parrish bcbf1c66ef Fix cast receiver idle behavior
When we replay a video without reloading, the idle card should disappear.

Closes #558

Change-Id: Ib2bca456ad90c8f2b4554f22f1edb920c69c8ada
2016-10-25 00:16:54 +00:00
Joey Parrish d0908fe743 Raise the async test timeout to 120s
All tests now have the same timeout value.  This should simplify the
process of addressing timeouts on Safari.

Change-Id: I3b455bd639758007ec8b2b86ef236c56e919c15a
2016-08-11 10:54:49 -07:00
Joey Parrish c6ea804e2a Closure cleanup
* Drop unnecessary type alternation in SegmentIndex unit tests
 * Drop unnecessary bind in StreamingEngine unit tests
 * Drop unnecessary expose annotations in Pssh
 * Add comments about quoted access in cast unit tests
 * Move afterAll() position in cast unit tests
 * Make return type for PublicPromise constructor more specific
 * Define a type for Util.eventLoop return value

Related to PR #421

Change-Id: I092a8ff366b4ac4ea868dd3f4fbe4e3d63a2167f
2016-07-24 16:33:28 -07:00
Joey Parrish f736a4d037 Merge pull request #457 from hochhaus/quote_properties
Quote properties on window in tests
2016-07-24 11:21:15 -07:00
Andy Hochhaus 060ca73ae3 Quote properties on window in tests 2016-07-23 14:49:33 -07:00
Andy Hochhaus 3023377d84 Remove extraneous semicolons 2016-07-23 14:41:14 -07:00