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
a8675673
authored
May 13, 2021
by
aquilescanta
Committed by
Oliver Woodman
May 13, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add backward compatibility tests for PlaybackException
PiperOrigin-RevId: 373542819
parent
954a6730
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
1 deletions
library/common/src/test/java/com/google/android/exoplayer2/PlaybackExceptionTest.java
library/common/src/test/java/com/google/android/exoplayer2/PlaybackExceptionTest.java
View file @
a8675673
...
@@ -17,6 +17,8 @@ package com.google.android.exoplayer2;
...
@@ -17,6 +17,8 @@ package com.google.android.exoplayer2;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
android.os.Bundle
;
import
android.os.RemoteException
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
java.io.IOException
;
import
java.io.IOException
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -37,7 +39,71 @@ public class PlaybackExceptionTest {
...
@@ -37,7 +39,71 @@ public class PlaybackExceptionTest {
assertPlaybackExceptionsAreEqual
(
before
,
after
);
assertPlaybackExceptionsAreEqual
(
before
,
after
);
}
}
// TODO: Add test for backwards compatibility.
// Backward compatibility tests.
// The following tests prevent accidental modifications which break communication with older
// ExoPlayer versions hosted in other processes.
@Test
public
void
bundle_producesExpectedException
()
{
IOException
expectedCause
=
new
IOException
(
"cause message"
);
PlaybackException
expectedException
=
new
PlaybackException
(
"message"
,
expectedCause
,
PlaybackException
.
ERROR_CODE_AUDIO_TRACK_INIT_FAILED
,
/* timestampMs= */
1000
);
Bundle
bundle
=
new
Bundle
();
bundle
.
putInt
(
"0"
,
5001
);
// Error code
bundle
.
putLong
(
"1"
,
1000
);
// Timestamp.
bundle
.
putString
(
"2"
,
"message"
);
bundle
.
putString
(
"3"
,
expectedCause
.
getClass
().
getName
());
bundle
.
putString
(
"4"
,
"cause message"
);
assertPlaybackExceptionsAreEqual
(
expectedException
,
PlaybackException
.
CREATOR
.
fromBundle
(
bundle
));
}
@Test
public
void
exception_producesExpectedBundle
()
{
IllegalStateException
cause
=
new
IllegalStateException
(
"cause message"
);
PlaybackException
exception
=
new
PlaybackException
(
"message"
,
cause
,
PlaybackException
.
ERROR_CODE_DECODING_FAILED
,
/* timestampMs= */
2000
);
Bundle
bundle
=
exception
.
toBundle
();
assertThat
(
bundle
.
getInt
(
"0"
)).
isEqualTo
(
4002
);
// Error code.
assertThat
(
bundle
.
getLong
(
"1"
)).
isEqualTo
(
2000
);
// Timestamp.
assertThat
(
bundle
.
getString
(
"2"
)).
isEqualTo
(
"message"
);
assertThat
(
bundle
.
getString
(
"3"
)).
isEqualTo
(
cause
.
getClass
().
getName
());
assertThat
(
bundle
.
getString
(
"4"
)).
isEqualTo
(
"cause message"
);
}
@Test
public
void
bundleWithUnexpectedCause_producesRemoteExceptionCause
()
{
RemoteException
expectedCause
=
new
RemoteException
(
"cause message"
);
PlaybackException
expectedException
=
new
PlaybackException
(
"message"
,
expectedCause
,
PlaybackException
.
ERROR_CODE_AUDIO_TRACK_INIT_FAILED
,
/* timestampMs= */
1000
);
Bundle
bundle
=
new
Bundle
();
bundle
.
putInt
(
"0"
,
5001
);
// Error code
bundle
.
putLong
(
"1"
,
1000
);
// Timestamp.
bundle
.
putString
(
"2"
,
"message"
);
bundle
.
putString
(
"3"
,
"invalid cause class name"
);
bundle
.
putString
(
"4"
,
"cause message"
);
assertPlaybackExceptionsAreEqual
(
expectedException
,
PlaybackException
.
CREATOR
.
fromBundle
(
bundle
));
}
// Internal methods.
private
static
void
assertPlaybackExceptionsAreEqual
(
PlaybackException
a
,
PlaybackException
b
)
{
private
static
void
assertPlaybackExceptionsAreEqual
(
PlaybackException
a
,
PlaybackException
b
)
{
assertThat
(
a
).
hasMessageThat
().
isEqualTo
(
b
.
getMessage
());
assertThat
(
a
).
hasMessageThat
().
isEqualTo
(
b
.
getMessage
());
...
...
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