484 Commits

Author SHA1 Message Date
insun
c7f2df0fd9 Add Player#getTrackSelector()
PiperOrigin-RevId: 310242733
2020-05-14 22:17:51 +01:00
tonihei
2e81186a33 Add timeout to TestExoPlayer runUntil methods.
If the condition isn't fulfilled, they currently block until the
test runner times out the test. Our usual approach is to timeout
in the test itself so that the error message is clearly showing the
blocked condition.

Also clean-up some documentation.

PiperOrigin-RevId: 309930198
2020-05-05 18:38:41 +01:00
andrewlewis
c926acb36d Add missing @Player.State in action schedule
PiperOrigin-RevId: 309735092
2020-05-05 18:37:38 +01:00
ibaker
b0a59a6b62 In-line one overload of assertOutput into assertAllBehaviours
Currently the assertOutput() overloads do quite different things.

Also stop returning FakeExtractorOutput from assertOutput (it's not
used).

PiperOrigin-RevId: 309030386
2020-05-01 19:47:48 +01:00
olly
a90f30a6cd TestDownloadManagerListener: Fix blockUntilIdle
PiperOrigin-RevId: 308985567
2020-05-01 19:46:39 +01:00
ibaker
922b8a2c15 Add option to FakeTrackOutput to de-duplicate repeated formats
Expose this through ExtractorAsserts via a new AssertionConfig object

PiperOrigin-RevId: 308980701
2020-05-01 19:46:30 +01:00
olly
8d450a9f9d Fix assertThat actual/expected order
PiperOrigin-RevId: 308844678
2020-05-01 19:45:38 +01:00
olly
2d494861ec Cleanup and document TestDownloadManagerListener
PiperOrigin-RevId: 308843488
2020-05-01 19:45:29 +01:00
olly
37d9e2f485 DownloadManagerTest: Improve thread interactions
- Remove assertReleased and replace it with a proper condition variable
  that's opened when Downloader.download or Download.remove finish. As
  far as I can tell assertReleased was basically implementing "sleep for
  10 seconds after the Downloader starts". Note fixing this properly
  also makes the tests run much faster!
- Use ConditionVariable instead of CountDownLatch(1).
- Use AtomicInteger instead of volatile int because it's clearer and
  allows removal of explanatory comments.

PiperOrigin-RevId: 308819204
2020-05-01 19:44:27 +01:00
olly
1c34029e87 ConditionVariable: Fix block(long) to correctly handle large timeouts
PiperOrigin-RevId: 308815613
2020-05-01 19:44:10 +01:00
olly
be07b3cad5 ConditionVariable: Improve documentation and allow clock injection
- Improve documentation explaining the benefits of ExoPlayer's ConditionVariable
  over the one that the platform provides
- Allow Clock injection
- Create TestUtil method for obtaining a ConditionVariable whose block(long)
  method times out correctly when used in a Robolectric test
- Add basic unit tests for ConditionVariable

PiperOrigin-RevId: 308812698
2020-05-01 19:44:01 +01:00
aquilescanta
b5112492be Add loadTaskId to LoadEventInfo
To be used by the LoadErrorHandlingPolicy.

PiperOrigin-RevId: 308657905
2020-05-01 19:43:34 +01:00
ibaker
9dac400734 Rename ExtractorAsserts "test everything" methods
This makes the distinction more clear between the methods that test
a specific behaviour (and are meant to be used with parameterized
tests) and those that test everything in one go.

Also add a TODO to FlacExtractorTest to migrate it when we can

PiperOrigin-RevId: 308228421
2020-04-27 10:41:49 +01:00
ibaker
0e6b318138 Remove ExtractorAsserts overloads that take a Context
Also mark the two assertOutput methods private, to make the API surface
smaller.

PiperOrigin-RevId: 308228186
2020-04-27 10:41:49 +01:00
aquilescanta
25f17acd21 Move LoadEventInfo creation to the caller
LoadEventInfo needs to also be sent to the LoadErrorHandlingPolicy.

PiperOrigin-RevId: 308066998
2020-04-27 10:41:33 +01:00
ibaker
cfa8e19f77 Use parameterization in most extractor tests
Part of what makes these tests hard to deal with (imo) is being
unable to easily run a specific config, or seeing exactly which one
failed (because you always see only the first failure).

I put the parameters as a method on ExtractorAsserts to
reduce the boiler-plate required in each test class.

I'll migrate the extension FlacExtractorTest in a follow-up CL

PiperOrigin-RevId: 307785380
2020-04-27 10:40:01 +01:00
aquilescanta
7839955f31 Separate encryption data into a new TrackOutput method
Allows media parser to populate crypto data.

PiperOrigin-RevId: 307616083
2020-04-27 10:19:13 +01:00
olly
fea4376779 Merge trick play tracks into main track groups
Issue: #6054
PiperOrigin-RevId: 307285068
2020-04-20 13:29:05 +01:00
ibaker
9937744f0e Improve the error message when an extractor dump file is not found
PiperOrigin-RevId: 307078446
2020-04-20 13:28:47 +01:00
tonihei
7350981ef9 Use higher level interface for method parameters where possible.
This makes it easier to use the helper methods because the player doesn't
have to be assigned to a SimpleExoPlayer in all cases.

PiperOrigin-RevId: 307039126
2020-04-20 13:28:16 +01:00
tonihei
ca2105d50c Wait with throwing stuck buffering error until pending load is finished
We currently check for shouldContinueLoading, which is the intention to load,
not playbackInfo.isLoading, which is the actual loading state, when detecting
stuck buffering issues.

They only differ if the LoadControl said stop loading (based on nextLoadPosition),
but there is still a load in flight (updating bufferedPosition). This may cause
the exception to be thrown in edge cases that are only temporary.

PiperOrigin-RevId: 307022608
2020-04-20 13:27:57 +01:00
ibaker
15bbd181e5 Add Format.label to the extractor test dumps
Needed to test issue:#7247

PiperOrigin-RevId: 307016276
2020-04-20 13:27:48 +01:00
christosts
91690f06ed Add Clock#currentTimeMillis()
PiperOrigin-RevId: 306602043
2020-04-15 17:42:19 +01:00
tonihei
76ad0bc4ff Fix NPE in AdaptiveBitrateTest due to missing Looper.
The new TestExoPlayer.Builder asserts that a Looper is present in
the constructor, although it can be set later for cases where no
such Looper exists.

PiperOrigin-RevId: 306403491
2020-04-15 17:42:18 +01:00
ibaker
af81238c92 Delete ExtractorAsserts.assertThrows
This doesn't seem to be used anywhere

PiperOrigin-RevId: 306391995
2020-04-15 17:42:18 +01:00
ibaker
2dafb8fd69 Disallow FakeTrackOutput.format() without sampleMetadata() in between
In general an extractor shouldn't be outputting multiple formats with
no samples in between.

PiperOrigin-RevId: 305674393
2020-04-09 16:44:31 +01:00
christosts
e7fd6a0e01 SimpleExoplayer Builder for testing
Create a Builder that creates SimpleExoPlayer instances with fake
components, suitable for testing.

Basically extracts the Builder from ExoPlayerTestRunner to a standalone
class that can be re-used.

PiperOrigin-RevId: 305458419
2020-04-08 21:48:08 +01:00
kimvde
c13f41af0d Remove deprecated members in DefaultTrackSelector
PiperOrigin-RevId: 304986313
2020-04-06 13:28:28 +01:00
olly
b6ebd48506 Remaining thread name cleanup
PiperOrigin-RevId: 303829900
2020-03-31 12:35:09 +01:00
gyumin
fd03949f85 Add DeviceComponent to Player interface
PiperOrigin-RevId: 303655497
2020-03-30 17:16:51 +01:00
tonihei
af05ceac61 Call onSeekProcessed immediately after seek command.
OnSeekProcessed is documented to be called as soon as all neccessary state changes
as a result of the seek have been made. As we now mask the state changes directly
when calling seekTo, we can also call this callback immediately without changing
the semantics of the method.

Our tests often use this callback as a way to wait for the internal player
to receive all pending commands and then report back. This is a special test
requirement for cases where we want to make sure no further updates happen as
a result of the player handling commands. To facilitate that, a new action is
added with a more descriptive name that achieves the same goal.

PiperOrigin-RevId: 303296210
2020-03-27 23:32:03 +00:00
andrewlewis
4454520e93 Add overlay FrameLayout to hosted tests
PiperOrigin-RevId: 303283147
2020-03-27 23:31:46 +00:00
olly
92c4088ac5 Remove dependency to self for testutils
PiperOrigin-RevId: 302446077
2020-03-25 13:03:20 +00:00
olly
dc33c0bdfb Improve logging II
- Show renderers with no tracks in EventLogger track logging
- Log renderer names in EventLogger track logging
- Add useful message to ExoPlaybackException instances (including
  renderer name for renderer errors)

PiperOrigin-RevId: 302421616
2020-03-25 13:03:12 +00:00
aquilescanta
aa9eb5abc9 Remove generics from DRM components
PiperOrigin-RevId: 301798563
2020-03-20 12:48:50 +00:00
tonihei
395a7031ac Add tests to cover two OOM scenarios.
We have two known scenarios where the app could create an OOM error and
we want to handle it gracefully:
 1. The app continues to allocate memory but doesn't make any progress
    in the buffered position. OOM should be prevented by the default
    load control and it should eventually throw an exception.
 2. An extractor tries to allocate a large amount of memory on the
    Loader thread based on information it read in faulty media files.
    In this case we should attempt to play remaining media and then
    throw an exception.

Both cases are already handled correctly, but we don't have any tests
ensuring that we don't introduce regressions.

PiperOrigin-RevId: 301585700
2020-03-19 00:50:31 +00:00
tonihei
71eec8ead1 Fix unrealistic FakeSampleStream.isReady
The FakeSampleStream is currently always ready even if it doesn't
have any samples to read. Fix that by checking for the conditions
under which read() will be successful.

PiperOrigin-RevId: 301371031
2020-03-19 00:49:18 +00:00
ibaker
cb414e8743 Change FakeRenderer to take a track type instead of a list of formats
The assertion about the expected formats doesn't really belong in a
fake, the assertions should be closer to the test method.

This gets in the way when I try and write a new test in
AnalyticsCollectorTest that doesn't use the expected, constant Format
(because i want to specify drmInitData) - but changing the expected
Format is tricky because it's hard-coded into the FakeVideoRenderer
inner class.

I replaced the assertion in FakeRenderer with assertions in test
methods that used to assert on the format count.

PiperOrigin-RevId: 301353072
2020-03-19 00:49:10 +00:00
olly
3acc85c2df Re-split ExoHostedTest.onTestFinished into logMetrics and assertPassed
This is a partial revert of <unknown commit>. The split and the order is important. For
example, as things are currently, if playback fails for a test that makes additional
assertions in onTestFinished, the visible reason the test failed is quite likely to
be one of the additional assertions, rather than the error that actually caused the
playback to fail. I think we probably also don't want to log metrics if playback
fails.

PiperOrigin-RevId: 300733109
2020-03-19 00:47:41 +00:00
bachinger
2028fdd756 add media item based playlist methods
After this change users of ExoPlayerImpl and SimpleExoPlayer can use the media item base playlist API which converts the media item to a media source.

It adds the media item based methods to the ExoPlayer instead of the Player interface. This avoids a big change in the CastPlayer which requires migrating the cast extension to the MediaItem of the core module (follow up CLs).

PiperOrigin-RevId: 300575567
2020-03-19 00:47:04 +00:00
bachinger
1e387601a6 update ExoPlayerTest to use get/setPlaybackSpeed
PiperOrigin-RevId: 300554337
2020-03-19 00:46:56 +00:00
ibaker
93e203f970 Tweak the assertions in MediaSourceTestRunner to give clearer failures
PiperOrigin-RevId: 300519989
2020-03-19 00:45:51 +00:00
tonihei
82599960c2 Add public API for pauseAtEndOfMediaItem
Also adds tests covering the internal implementation.

Issue:#5660
PiperOrigin-RevId: 300513548
2020-03-19 00:45:26 +00:00
bachinger
683cb0260e add get/setPlaybackSpeed and listener callback
This change deprecates the PlaybackParameters and remove the skipSilenceField from the PlaybackParameters. This implies that enabling and disabling skipping silences needs to be done on the Player.AudioComponent after this change.

After submission of the change, all Player API changes are done which are required to bring playbackSpeed and skipSilenceEnabled in the converged Player API state.

PiperOrigin-RevId: 300420843
2020-03-19 00:45:01 +00:00
aquilescanta
47b62e8c02 DataReader: replace InterruptedException with InterruptedIOException
PiperOrigin-RevId: 299092243
2020-03-10 10:19:45 +00:00
tonihei
b5976a55ff Upgrade Kotlin annotations and fix gradle warnings
The new version fixes some warnings in Gradle builds. Also
add missing indirect compileOnly dependencies to fix some more warnings

Issue:issue:#7007
PiperOrigin-RevId: 298855510
2020-03-10 10:19:19 +00:00
krocard
58f42e9f8b Annotate render's read source result
So that swich case has a warning if all case are not
covered.

PiperOrigin-RevId: 298574013
2020-03-10 10:17:48 +00:00
andrewlewis
9c1c74ecc4 Rename .unklen.dump -> .unknown_length.dump
PiperOrigin-RevId: 298334502
2020-03-10 10:16:54 +00:00
ibaker
2f4e88d5af Remove ByteBufferBackingArray suppression from metadata decoders
PiperOrigin-RevId: 298312222
2020-03-10 10:16:25 +00:00
tonihei
697165ce56 Enable window-period offset in tests by default.
This ensures all player interactions in tests automatically verify that
timestamps calculations are done correctly.

PiperOrigin-RevId: 297813324
2020-02-28 18:41:56 +00:00