Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8a560429
authored
Dec 17, 2020
by
bachinger
Committed by
Christos Tsilopoulos
Dec 17, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix flaky test case
PiperOrigin-RevId: 347987861
parent
d9c058c6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
15 deletions
library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java
library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java
View file @
8a560429
...
...
@@ -7536,14 +7536,54 @@ public final class ExoPlayerTest {
.
isEqualTo
(
rendererStreamOffsetsUs
.
get
(
0
)
+
periodDurationUs
);
}
@Ignore
// See [internal: b/175773664]
@Test
public
void
mediaItemOfSources_correctInTimelineWindows
()
throws
Exception
{
SilenceMediaSource
.
Factory
factory
=
new
SilenceMediaSource
.
Factory
().
setDurationUs
(
C
.
msToUs
(
100_000
));
TimelineWindowDefinition
window1
=
new
TimelineWindowDefinition
(
/* periodCount= */
1
,
/* id= */
1
,
/* isSeekable= */
true
,
/* isDynamic= */
false
,
/* isLive= */
false
,
/* isPlaceholder= */
false
,
/* durationUs = */
100_000
,
/* defaultPositionUs = */
0
,
/* windowOffsetInFirstPeriodUs= */
0
,
AdPlaybackState
.
NONE
,
MediaItem
.
fromUri
(
"http://foo.bar/fake1"
));
FakeMediaSource
fakeMediaSource1
=
new
FakeMediaSource
(
new
FakeTimeline
(
window1
));
TimelineWindowDefinition
window2
=
new
TimelineWindowDefinition
(
/* periodCount= */
1
,
/* id= */
2
,
/* isSeekable= */
true
,
/* isDynamic= */
false
,
/* isLive= */
false
,
/* isPlaceholder= */
false
,
/* durationUs = */
100_000
,
/* defaultPositionUs = */
0
,
/* windowOffsetInFirstPeriodUs= */
0
,
AdPlaybackState
.
NONE
,
MediaItem
.
fromUri
(
"http://foo.bar/fake2"
));
FakeMediaSource
fakeMediaSource2
=
new
FakeMediaSource
(
new
FakeTimeline
(
window2
));
TimelineWindowDefinition
window3
=
new
TimelineWindowDefinition
(
/* periodCount= */
1
,
/* id= */
3
,
/* isSeekable= */
true
,
/* isDynamic= */
false
,
/* isLive= */
false
,
/* isPlaceholder= */
false
,
/* durationUs = */
100_000
,
/* defaultPositionUs = */
0
,
/* windowOffsetInFirstPeriodUs= */
0
,
AdPlaybackState
.
NONE
,
MediaItem
.
fromUri
(
"http://foo.bar/fake3"
));
FakeMediaSource
fakeMediaSource3
=
new
FakeMediaSource
(
new
FakeTimeline
(
window3
));
final
Player
[]
playerHolder
=
{
null
};
ActionSchedule
actionSchedule
=
new
ActionSchedule
.
Builder
(
TAG
)
.
pause
()
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
...
...
@@ -7553,10 +7593,10 @@ public final class ExoPlayerTest {
})
.
waitForPlaybackState
(
Player
.
STATE_READY
)
.
seek
(
/* positionMs= */
0
)
.
waitForPlaybackState
(
Player
.
STATE_ENDED
)
.
play
(
)
.
build
();
List
<
MediaItem
>
currentMediaItems
=
new
ArrayList
<>();
List
<
MediaItem
>
initialMediaItems
=
new
ArrayList
<>();
List
<
MediaItem
>
mediaItemsInTimeline
=
new
ArrayList
<>();
Player
.
EventListener
eventListener
=
new
Player
.
EventListener
()
{
@Override
...
...
@@ -7566,31 +7606,34 @@ public final class ExoPlayerTest {
}
Window
window
=
new
Window
();
for
(
int
i
=
0
;
i
<
timeline
.
getWindowCount
();
i
++)
{
initialMediaItems
.
add
(
timeline
.
getWindow
(
i
,
window
).
mediaItem
);
mediaItemsInTimeline
.
add
(
timeline
.
getWindow
(
i
,
window
).
mediaItem
);
}
}
@Override
public
void
onPositionDiscontinuity
(
int
reason
)
{
currentMediaItems
.
add
(
playerHolder
[
0
].
getCurrentMediaItem
());
if
(
reason
==
Player
.
DISCONTINUITY_REASON_SEEK
||
reason
==
Player
.
DISCONTINUITY_REASON_PERIOD_TRANSITION
)
{
currentMediaItems
.
add
(
playerHolder
[
0
].
getCurrentMediaItem
());
}
}
};
new
ExoPlayerTestRunner
.
Builder
(
context
)
.
setEventListener
(
eventListener
)
.
setActionSchedule
(
actionSchedule
)
.
setMediaSources
(
factory
.
setTag
(
"1"
).
createMediaSource
(),
factory
.
setTag
(
"2"
).
createMediaSource
(),
factory
.
setTag
(
"3"
).
createMediaSource
())
.
setMediaSources
(
fakeMediaSource1
,
fakeMediaSource2
,
fakeMediaSource3
)
.
build
()
.
start
()
.
blockUntilActionScheduleFinished
(
TIMEOUT_MS
)
.
blockUntilEnded
(
TIMEOUT_MS
);
assertThat
(
currentMediaItems
.
get
(
0
).
playbackProperties
.
tag
).
isEqualTo
(
"1"
);
assertThat
(
currentMediaItems
.
get
(
1
).
playbackProperties
.
tag
).
isEqualTo
(
"2"
);
assertThat
(
currentMediaItems
.
get
(
2
).
playbackProperties
.
tag
).
isEqualTo
(
"3"
);
assertThat
(
initialMediaItems
).
containsExactlyElementsIn
(
currentMediaItems
);
assertThat
(
currentMediaItems
.
get
(
0
).
playbackProperties
.
uri
.
toString
())
.
isEqualTo
(
"http://foo.bar/fake1"
);
assertThat
(
currentMediaItems
.
get
(
1
).
playbackProperties
.
uri
.
toString
())
.
isEqualTo
(
"http://foo.bar/fake2"
);
assertThat
(
currentMediaItems
.
get
(
2
).
playbackProperties
.
uri
.
toString
())
.
isEqualTo
(
"http://foo.bar/fake3"
);
assertThat
(
mediaItemsInTimeline
).
containsExactlyElementsIn
(
currentMediaItems
);
}
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment