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
fbf86572
authored
Mar 05, 2020
by
christosts
Committed by
Oliver Woodman
Mar 10, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix flaky AsynchronousMediaCodecAdapterTest
PiperOrigin-RevId: 299057572
parent
45178296
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
library/core/src/test/java/com/google/android/exoplayer2/mediacodec/AsynchronousMediaCodecAdapterTest.java
library/core/src/test/java/com/google/android/exoplayer2/mediacodec/AsynchronousMediaCodecAdapterTest.java
View file @
fbf86572
...
@@ -19,6 +19,7 @@ package com.google.android.exoplayer2.mediacodec;
...
@@ -19,6 +19,7 @@ package com.google.android.exoplayer2.mediacodec;
import
static
com
.
google
.
android
.
exoplayer2
.
testutil
.
TestUtil
.
assertBufferInfosEqual
;
import
static
com
.
google
.
android
.
exoplayer2
.
testutil
.
TestUtil
.
assertBufferInfosEqual
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertThrows
;
import
static
org
.
junit
.
Assert
.
assertThrows
;
import
static
org
.
robolectric
.
annotation
.
LooperMode
.
Mode
.
LEGACY
;
import
android.media.MediaCodec
;
import
android.media.MediaCodec
;
import
android.media.MediaFormat
;
import
android.media.MediaFormat
;
...
@@ -33,8 +34,10 @@ import org.junit.Before;
...
@@ -33,8 +34,10 @@ import org.junit.Before;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.robolectric.Shadows
;
import
org.robolectric.Shadows
;
import
org.robolectric.annotation.LooperMode
;
/** Unit tests for {@link AsynchronousMediaCodecAdapter}. */
/** Unit tests for {@link AsynchronousMediaCodecAdapter}. */
@LooperMode
(
LEGACY
)
@RunWith
(
AndroidJUnit4
.
class
)
@RunWith
(
AndroidJUnit4
.
class
)
public
class
AsynchronousMediaCodecAdapterTest
{
public
class
AsynchronousMediaCodecAdapterTest
{
private
AsynchronousMediaCodecAdapter
adapter
;
private
AsynchronousMediaCodecAdapter
adapter
;
...
@@ -96,7 +99,7 @@ public class AsynchronousMediaCodecAdapterTest {
...
@@ -96,7 +99,7 @@ public class AsynchronousMediaCodecAdapterTest {
()
->
adapter
.
getMediaCodecCallback
().
onInputBufferAvailable
(
codec
,
/* index=*/
1
));
()
->
adapter
.
getMediaCodecCallback
().
onInputBufferAvailable
(
codec
,
/* index=*/
1
));
// Wait until all tasks have been handled.
// Wait until all tasks have been handled.
Shadows
.
shadowOf
(
handlerThread
.
getLooper
()
).
idle
();
Shadows
.
shadowOf
(
looper
).
idle
();
assertThat
(
adapter
.
dequeueInputBufferIndex
()).
isEqualTo
(
1
);
assertThat
(
adapter
.
dequeueInputBufferIndex
()).
isEqualTo
(
1
);
}
}
...
@@ -113,7 +116,7 @@ public class AsynchronousMediaCodecAdapterTest {
...
@@ -113,7 +116,7 @@ public class AsynchronousMediaCodecAdapterTest {
adapter
.
flush
();
adapter
.
flush
();
// Wait until all tasks have been handled.
// Wait until all tasks have been handled.
Shadows
.
shadowOf
(
handlerThread
.
getLooper
()
).
idle
();
Shadows
.
shadowOf
(
looper
).
idle
();
assertThrows
(
assertThrows
(
IllegalStateException
.
class
,
IllegalStateException
.
class
,
()
->
{
()
->
{
...
@@ -165,7 +168,7 @@ public class AsynchronousMediaCodecAdapterTest {
...
@@ -165,7 +168,7 @@ public class AsynchronousMediaCodecAdapterTest {
()
->
adapter
.
getMediaCodecCallback
().
onOutputBufferAvailable
(
codec
,
/* index=*/
1
,
info1
));
()
->
adapter
.
getMediaCodecCallback
().
onOutputBufferAvailable
(
codec
,
/* index=*/
1
,
info1
));
// Wait until all tasks have been handled.
// Wait until all tasks have been handled.
Shadows
.
shadowOf
(
handlerThread
.
getLooper
()
).
idle
();
Shadows
.
shadowOf
(
looper
).
idle
();
assertThat
(
adapter
.
dequeueOutputBufferIndex
(
bufferInfo
)).
isEqualTo
(
1
);
assertThat
(
adapter
.
dequeueOutputBufferIndex
(
bufferInfo
)).
isEqualTo
(
1
);
assertBufferInfosEqual
(
info1
,
bufferInfo
);
assertBufferInfosEqual
(
info1
,
bufferInfo
);
}
}
...
@@ -183,7 +186,7 @@ public class AsynchronousMediaCodecAdapterTest {
...
@@ -183,7 +186,7 @@ public class AsynchronousMediaCodecAdapterTest {
adapter
.
flush
();
adapter
.
flush
();
// Wait until all tasks have been handled.
// Wait until all tasks have been handled.
Shadows
.
shadowOf
(
handlerThread
.
getLooper
()
).
idle
();
Shadows
.
shadowOf
(
looper
).
idle
();
assertThrows
(
IllegalStateException
.
class
,
()
->
adapter
.
dequeueOutputBufferIndex
(
bufferInfo
));
assertThrows
(
IllegalStateException
.
class
,
()
->
adapter
.
dequeueOutputBufferIndex
(
bufferInfo
));
}
}
...
@@ -220,7 +223,7 @@ public class AsynchronousMediaCodecAdapterTest {
...
@@ -220,7 +223,7 @@ public class AsynchronousMediaCodecAdapterTest {
adapter
.
flush
();
adapter
.
flush
();
// Wait until all tasks have been handled.
// Wait until all tasks have been handled.
Shadows
.
shadowOf
(
handlerThread
.
getLooper
()
).
idle
();
Shadows
.
shadowOf
(
looper
).
idle
();
assertThat
(
adapter
.
getOutputFormat
()).
isEqualTo
(
format
);
assertThat
(
adapter
.
getOutputFormat
()).
isEqualTo
(
format
);
}
}
...
@@ -233,7 +236,7 @@ public class AsynchronousMediaCodecAdapterTest {
...
@@ -233,7 +236,7 @@ public class AsynchronousMediaCodecAdapterTest {
adapter
.
shutdown
();
adapter
.
shutdown
();
// Wait until all tasks have been handled.
// Wait until all tasks have been handled.
Shadows
.
shadowOf
(
handlerThread
.
getLooper
()
).
idle
();
Shadows
.
shadowOf
(
looper
).
idle
();
assertThat
(
onCodecStartCalled
.
get
()).
isEqualTo
(
1
);
assertThat
(
onCodecStartCalled
.
get
()).
isEqualTo
(
1
);
}
}
}
}
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