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
d6cddf9a
authored
Nov 22, 2021
by
samrobinson
Committed by
Ian Baker
Nov 22, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add a 120s timeout to transformer running within instrumentation tests.
PiperOrigin-RevId: 411526089
parent
1a1d27ae
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
14 deletions
libraries/transformer/src/androidTest/java/androidx/media3/transformer/AndroidTestUtil.java
libraries/transformer/src/androidTest/java/androidx/media3/transformer/RemoveAudioTransformationTest.java
libraries/transformer/src/androidTest/java/androidx/media3/transformer/RemoveVideoTransformationTest.java
libraries/transformer/src/androidTest/java/androidx/media3/transformer/RepeatedTranscodeTransformationTest.java
libraries/transformer/src/androidTest/java/androidx/media3/transformer/SefTransformationTest.java
libraries/transformer/src/androidTest/java/androidx/media3/transformer/TransformationTest.java
libraries/transformer/src/androidTest/java/androidx/media3/transformer/AndroidTestUtil.java
View file @
d6cddf9a
...
@@ -15,6 +15,9 @@
...
@@ -15,6 +15,9 @@
*/
*/
package
androidx
.
media3
.
transformer
;
package
androidx
.
media3
.
transformer
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertWithMessage
;
import
static
java
.
util
.
concurrent
.
TimeUnit
.
SECONDS
;
import
android.content.Context
;
import
android.content.Context
;
import
android.net.Uri
;
import
android.net.Uri
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
...
@@ -29,8 +32,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -29,8 +32,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
/** Utilities for instrumentation tests. */
/** Utilities for instrumentation tests. */
/* package */
final
class
AndroidTestUtil
{
/* package */
final
class
AndroidTestUtil
{
public
static
final
String
MP4_ASSET_URI
=
"asset:///media/mp4/sample.mp4"
;
public
static
final
String
MP4_ASSET_URI
_STRING
=
"asset:///media/mp4/sample.mp4"
;
public
static
final
String
SEF_ASSET_URI
=
"asset:///media/mp4/sample_sef_slow_motion.mp4"
;
public
static
final
String
SEF_ASSET_URI
_STRING
=
"asset:///media/mp4/sample_sef_slow_motion.mp4"
;
public
static
final
String
REMOTE_MP4_10_SECONDS_URI_STRING
=
public
static
final
String
REMOTE_MP4_10_SECONDS_URI_STRING
=
"https://storage.googleapis.com/exoplayer-test-media-1/mp4/android-screens-10s.mp4"
;
"https://storage.googleapis.com/exoplayer-test-media-1/mp4/android-screens-10s.mp4"
;
...
@@ -43,9 +46,19 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -43,9 +46,19 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
}
}
}
}
/** Transforms the {@code uriString} with the {@link Transformer}. */
/**
* Transforms the {@code uriString} with the {@link Transformer}.
*
* @param context The {@link Context}.
* @param transformer The {@link Transformer} that performs the transformation.
* @param uriString The uri (as a {@link String}) that will be transformed.
* @param timeoutSeconds The transformer timeout. An assertion confirms this is not exceeded.
* @return The {@link TransformationResult}.
* @throws Exception The cause of the transformation not completing.
*/
public
static
TransformationResult
runTransformer
(
public
static
TransformationResult
runTransformer
(
Context
context
,
Transformer
transformer
,
String
uriString
)
throws
Exception
{
Context
context
,
Transformer
transformer
,
String
uriString
,
int
timeoutSeconds
)
throws
Exception
{
AtomicReference
<
@NullableType
Exception
>
exceptionReference
=
new
AtomicReference
<>();
AtomicReference
<
@NullableType
Exception
>
exceptionReference
=
new
AtomicReference
<>();
CountDownLatch
countDownLatch
=
new
CountDownLatch
(
1
);
CountDownLatch
countDownLatch
=
new
CountDownLatch
(
1
);
...
@@ -80,7 +93,10 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -80,7 +93,10 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
exceptionReference
.
set
(
e
);
exceptionReference
.
set
(
e
);
}
}
});
});
countDownLatch
.
await
();
assertWithMessage
(
"Transformer timed out after "
+
timeoutSeconds
+
" seconds."
)
.
that
(
countDownLatch
.
await
(
timeoutSeconds
,
SECONDS
))
.
isTrue
();
@Nullable
Exception
exception
=
exceptionReference
.
get
();
@Nullable
Exception
exception
=
exceptionReference
.
get
();
if
(
exception
!=
null
)
{
if
(
exception
!=
null
)
{
throw
exception
;
throw
exception
;
...
...
libraries/transformer/src/androidTest/java/androidx/media3/transformer/RemoveAudioTransformationTest.java
View file @
d6cddf9a
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
*/
*/
package
androidx
.
media3
.
transformer
;
package
androidx
.
media3
.
transformer
;
import
static
androidx
.
media3
.
transformer
.
AndroidTestUtil
.
MP4_ASSET_URI
;
import
static
androidx
.
media3
.
transformer
.
AndroidTestUtil
.
MP4_ASSET_URI
_STRING
;
import
static
androidx
.
media3
.
transformer
.
AndroidTestUtil
.
runTransformer
;
import
static
androidx
.
media3
.
transformer
.
AndroidTestUtil
.
runTransformer
;
import
android.content.Context
;
import
android.content.Context
;
...
@@ -32,6 +32,6 @@ public class RemoveAudioTransformationTest {
...
@@ -32,6 +32,6 @@ public class RemoveAudioTransformationTest {
Context
context
=
ApplicationProvider
.
getApplicationContext
();
Context
context
=
ApplicationProvider
.
getApplicationContext
();
Transformer
transformer
=
Transformer
transformer
=
new
Transformer
.
Builder
().
setContext
(
context
).
setRemoveAudio
(
true
).
build
();
new
Transformer
.
Builder
().
setContext
(
context
).
setRemoveAudio
(
true
).
build
();
runTransformer
(
context
,
transformer
,
MP4_ASSET_URI
);
runTransformer
(
context
,
transformer
,
MP4_ASSET_URI
_STRING
,
/* timeoutSeconds= */
120
);
}
}
}
}
libraries/transformer/src/androidTest/java/androidx/media3/transformer/RemoveVideoTransformationTest.java
View file @
d6cddf9a
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
*/
*/
package
androidx
.
media3
.
transformer
;
package
androidx
.
media3
.
transformer
;
import
static
androidx
.
media3
.
transformer
.
AndroidTestUtil
.
MP4_ASSET_URI
;
import
static
androidx
.
media3
.
transformer
.
AndroidTestUtil
.
MP4_ASSET_URI
_STRING
;
import
static
androidx
.
media3
.
transformer
.
AndroidTestUtil
.
runTransformer
;
import
static
androidx
.
media3
.
transformer
.
AndroidTestUtil
.
runTransformer
;
import
android.content.Context
;
import
android.content.Context
;
...
@@ -32,6 +32,6 @@ public class RemoveVideoTransformationTest {
...
@@ -32,6 +32,6 @@ public class RemoveVideoTransformationTest {
Context
context
=
ApplicationProvider
.
getApplicationContext
();
Context
context
=
ApplicationProvider
.
getApplicationContext
();
Transformer
transformer
=
Transformer
transformer
=
new
Transformer
.
Builder
().
setContext
(
context
).
setRemoveVideo
(
true
).
build
();
new
Transformer
.
Builder
().
setContext
(
context
).
setRemoveVideo
(
true
).
build
();
runTransformer
(
context
,
transformer
,
MP4_ASSET_URI
);
runTransformer
(
context
,
transformer
,
MP4_ASSET_URI
_STRING
,
/* timeoutSeconds= */
120
);
}
}
}
}
libraries/transformer/src/androidTest/java/androidx/media3/transformer/RepeatedTranscodeTransformationTest.java
View file @
d6cddf9a
...
@@ -47,7 +47,11 @@ public final class RepeatedTranscodeTransformationTest {
...
@@ -47,7 +47,11 @@ public final class RepeatedTranscodeTransformationTest {
for
(
int
i
=
0
;
i
<
TRANSCODE_COUNT
;
i
++)
{
for
(
int
i
=
0
;
i
<
TRANSCODE_COUNT
;
i
++)
{
// Use a long video in case an error occurs a while after the start of the video.
// Use a long video in case an error occurs a while after the start of the video.
long
outputSizeBytes
=
long
outputSizeBytes
=
runTransformer
(
context
,
transformer
,
AndroidTestUtil
.
REMOTE_MP4_10_SECONDS_URI_STRING
)
runTransformer
(
context
,
transformer
,
AndroidTestUtil
.
REMOTE_MP4_10_SECONDS_URI_STRING
,
/* timeoutSeconds= */
120
)
.
outputSizeBytes
;
.
outputSizeBytes
;
if
(
previousOutputSizeBytes
!=
C
.
LENGTH_UNSET
)
{
if
(
previousOutputSizeBytes
!=
C
.
LENGTH_UNSET
)
{
assertWithMessage
(
"Unexpected output size on transcode "
+
i
+
" out of "
+
TRANSCODE_COUNT
)
assertWithMessage
(
"Unexpected output size on transcode "
+
i
+
" out of "
+
TRANSCODE_COUNT
)
...
...
libraries/transformer/src/androidTest/java/androidx/media3/transformer/SefTransformationTest.java
View file @
d6cddf9a
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
*/
*/
package
androidx
.
media3
.
transformer
;
package
androidx
.
media3
.
transformer
;
import
static
androidx
.
media3
.
transformer
.
AndroidTestUtil
.
SEF_ASSET_URI
;
import
static
androidx
.
media3
.
transformer
.
AndroidTestUtil
.
SEF_ASSET_URI
_STRING
;
import
static
androidx
.
media3
.
transformer
.
AndroidTestUtil
.
runTransformer
;
import
static
androidx
.
media3
.
transformer
.
AndroidTestUtil
.
runTransformer
;
import
android.content.Context
;
import
android.content.Context
;
...
@@ -32,6 +32,6 @@ public class SefTransformationTest {
...
@@ -32,6 +32,6 @@ public class SefTransformationTest {
Context
context
=
ApplicationProvider
.
getApplicationContext
();
Context
context
=
ApplicationProvider
.
getApplicationContext
();
Transformer
transformer
=
Transformer
transformer
=
new
Transformer
.
Builder
().
setContext
(
context
).
setFlattenForSlowMotion
(
true
).
build
();
new
Transformer
.
Builder
().
setContext
(
context
).
setFlattenForSlowMotion
(
true
).
build
();
runTransformer
(
context
,
transformer
,
SEF_ASSET_URI
);
runTransformer
(
context
,
transformer
,
SEF_ASSET_URI
_STRING
,
/* timeoutSeconds= */
120
);
}
}
}
}
libraries/transformer/src/androidTest/java/androidx/media3/transformer/TransformationTest.java
View file @
d6cddf9a
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
*/
*/
package
androidx
.
media3
.
transformer
;
package
androidx
.
media3
.
transformer
;
import
static
androidx
.
media3
.
transformer
.
AndroidTestUtil
.
MP4_ASSET_URI
;
import
static
androidx
.
media3
.
transformer
.
AndroidTestUtil
.
MP4_ASSET_URI
_STRING
;
import
static
androidx
.
media3
.
transformer
.
AndroidTestUtil
.
runTransformer
;
import
static
androidx
.
media3
.
transformer
.
AndroidTestUtil
.
runTransformer
;
import
android.content.Context
;
import
android.content.Context
;
...
@@ -31,6 +31,6 @@ public class TransformationTest {
...
@@ -31,6 +31,6 @@ public class TransformationTest {
public
void
transform
()
throws
Exception
{
public
void
transform
()
throws
Exception
{
Context
context
=
ApplicationProvider
.
getApplicationContext
();
Context
context
=
ApplicationProvider
.
getApplicationContext
();
Transformer
transformer
=
new
Transformer
.
Builder
().
setContext
(
context
).
build
();
Transformer
transformer
=
new
Transformer
.
Builder
().
setContext
(
context
).
build
();
runTransformer
(
context
,
transformer
,
MP4_ASSET_URI
);
runTransformer
(
context
,
transformer
,
MP4_ASSET_URI
_STRING
,
/* timeoutSeconds= */
120
);
}
}
}
}
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