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
2397e7f6
authored
May 20, 2020
by
ibaker
Committed by
tonihei
May 21, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Replace TestUtil.joinByteArrays() with Guava's Bytes.concat()
PiperOrigin-RevId: 312481058
parent
9035f1d7
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
26 additions
and
40 deletions
library/common/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageDecoderTest.java
library/common/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageEncoderTest.java
library/core/src/test/java/com/google/android/exoplayer2/mediacodec/BatchBufferTest.java
library/core/src/test/java/com/google/android/exoplayer2/metadata/MetadataRendererTest.java
library/core/src/test/java/com/google/android/exoplayer2/metadata/icy/IcyDecoderTest.java
library/core/src/test/java/com/google/android/exoplayer2/source/SampleQueueTest.java
library/extractor/build.gradle
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeekerTest.java
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ts/AdtsReaderTest.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTrackOutput.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/TestUtil.java
library/common/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageDecoderTest.java
View file @
2397e7f6
...
...
@@ -17,13 +17,13 @@ package com.google.android.exoplayer2.metadata.emsg;
import
static
com
.
google
.
android
.
exoplayer2
.
testutil
.
TestUtil
.
createByteArray
;
import
static
com
.
google
.
android
.
exoplayer2
.
testutil
.
TestUtil
.
createMetadataInputBuffer
;
import
static
com
.
google
.
android
.
exoplayer2
.
testutil
.
TestUtil
.
joinByteArrays
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertThrows
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.metadata.Metadata
;
import
com.google.android.exoplayer2.metadata.MetadataInputBuffer
;
import
com.google.common.primitives.Bytes
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -34,7 +34,7 @@ public final class EventMessageDecoderTest {
@Test
public
void
decodeEventMessage
()
{
byte
[]
rawEmsgBody
=
joinByteArrays
(
Bytes
.
concat
(
createByteArray
(
117
,
114
,
110
,
58
,
116
,
101
,
115
,
116
,
0
),
// scheme_id_uri = "urn:test"
createByteArray
(
49
,
50
,
51
,
0
),
// value = "123"
createByteArray
(
0
,
0
,
11
,
184
),
// event_duration_ms = 3000
...
...
library/common/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageEncoderTest.java
View file @
2397e7f6
...
...
@@ -17,12 +17,12 @@ package com.google.android.exoplayer2.metadata.emsg;
import
static
com
.
google
.
android
.
exoplayer2
.
testutil
.
TestUtil
.
createByteArray
;
import
static
com
.
google
.
android
.
exoplayer2
.
testutil
.
TestUtil
.
createMetadataInputBuffer
;
import
static
com
.
google
.
android
.
exoplayer2
.
testutil
.
TestUtil
.
joinByteArrays
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.metadata.Metadata
;
import
com.google.android.exoplayer2.metadata.MetadataInputBuffer
;
import
com.google.common.primitives.Bytes
;
import
java.io.IOException
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -35,7 +35,7 @@ public final class EventMessageEncoderTest {
new
EventMessage
(
"urn:test"
,
"123"
,
3000
,
1000403
,
new
byte
[]
{
0
,
1
,
2
,
3
,
4
});
private
static
final
byte
[]
ENCODED_MESSAGE
=
joinByteArrays
(
Bytes
.
concat
(
createByteArray
(
117
,
114
,
110
,
58
,
116
,
101
,
115
,
116
,
0
),
// scheme_id_uri = "urn:test"
createByteArray
(
49
,
50
,
51
,
0
),
// value = "123"
createByteArray
(
0
,
0
,
11
,
184
),
// event_duration_ms = 3000
...
...
@@ -64,7 +64,7 @@ public final class EventMessageEncoderTest {
EventMessage
eventMessage1
=
new
EventMessage
(
"urn:test"
,
"123"
,
3000
,
1000402
,
new
byte
[]
{
4
,
3
,
2
,
1
,
0
});
byte
[]
expectedEmsgBody1
=
joinByteArrays
(
Bytes
.
concat
(
createByteArray
(
117
,
114
,
110
,
58
,
116
,
101
,
115
,
116
,
0
),
// scheme_id_uri = "urn:test"
createByteArray
(
49
,
50
,
51
,
0
),
// value = "123"
createByteArray
(
0
,
0
,
11
,
184
),
// event_duration_ms = 3000
...
...
library/core/src/test/java/com/google/android/exoplayer2/mediacodec/BatchBufferTest.java
View file @
2397e7f6
...
...
@@ -23,6 +23,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.testutil.TestUtil
;
import
com.google.common.primitives.Bytes
;
import
java.nio.ByteBuffer
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -153,7 +154,7 @@ public final class BatchBufferTest {
batchBuffer
.
commitNextAccessUnit
();
batchBuffer
.
flip
();
byte
[]
expected
=
TestUtil
.
joinByteArrays
(
TEST_ACCESS_UNIT
,
TEST_ACCESS_UNIT
);
byte
[]
expected
=
Bytes
.
concat
(
TEST_ACCESS_UNIT
,
TEST_ACCESS_UNIT
);
assertThat
(
batchBuffer
.
data
).
isEqualTo
(
ByteBuffer
.
wrap
(
expected
));
}
...
...
library/core/src/test/java/com/google/android/exoplayer2/metadata/MetadataRendererTest.java
View file @
2397e7f6
...
...
@@ -32,6 +32,7 @@ import com.google.android.exoplayer2.testutil.FakeSampleStream.FakeSampleStreamI
import
com.google.android.exoplayer2.testutil.TestUtil
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.common.primitives.Bytes
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
...
...
@@ -43,7 +44,7 @@ import org.junit.runner.RunWith;
public
class
MetadataRendererTest
{
private
static
final
byte
[]
SCTE35_TIME_SIGNAL_BYTES
=
TestUtil
.
joinByteArrays
(
Bytes
.
concat
(
TestUtil
.
createByteArray
(
0
,
// table_id.
0x80
,
// section_syntax_indicator, private_indicator, reserved, section_length(4).
...
...
@@ -170,7 +171,7 @@ public class MetadataRendererTest {
*/
private
static
byte
[]
encodeTxxxId3Frame
(
String
description
,
String
value
)
{
byte
[]
id3FrameData
=
TestUtil
.
joinByteArrays
(
Bytes
.
concat
(
"TXXX"
.
getBytes
(
ISO_8859_1
),
// ID for a 'user defined text information frame'
TestUtil
.
createByteArray
(
0
,
0
,
0
,
0
),
// Frame size (set later)
TestUtil
.
createByteArray
(
0
,
0
),
// Frame flags
...
...
@@ -186,7 +187,7 @@ public class MetadataRendererTest {
id3FrameData
[
frameSizeIndex
]
=
(
byte
)
frameSize
;
byte
[]
id3Bytes
=
TestUtil
.
joinByteArrays
(
Bytes
.
concat
(
"ID3"
.
getBytes
(
ISO_8859_1
),
// identifier
TestUtil
.
createByteArray
(
0x04
,
0x00
),
// version
TestUtil
.
createByteArray
(
0
),
// Tag flags
...
...
library/core/src/test/java/com/google/android/exoplayer2/metadata/icy/IcyDecoderTest.java
View file @
2397e7f6
...
...
@@ -26,7 +26,7 @@ import static org.junit.Assert.assertThrows;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.metadata.Metadata
;
import
com.google.android.exoplayer2.metadata.MetadataInputBuffer
;
import
com.google.
android.exoplayer2.testutil.TestUtil
;
import
com.google.
common.primitives.Bytes
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -54,7 +54,7 @@ public final class IcyDecoderTest {
public
void
decode_respectsLimit
()
{
byte
[]
icyTitle
=
"StreamTitle='test title';"
.
getBytes
(
UTF_8
);
byte
[]
icyUrl
=
"StreamURL='test_url';"
.
getBytes
(
UTF_8
);
byte
[]
paddedRawBytes
=
TestUtil
.
joinByteArrays
(
icyTitle
,
icyUrl
);
byte
[]
paddedRawBytes
=
Bytes
.
concat
(
icyTitle
,
icyUrl
);
MetadataInputBuffer
metadataBuffer
=
createMetadataInputBuffer
(
paddedRawBytes
);
// Stop before the stream URL.
metadataBuffer
.
data
.
limit
(
icyTitle
.
length
);
...
...
library/core/src/test/java/com/google/android/exoplayer2/source/SampleQueueTest.java
View file @
2397e7f6
...
...
@@ -43,6 +43,7 @@ import com.google.android.exoplayer2.upstream.DefaultAllocator;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.MediaSourceEventDispatcher
;
import
com.google.android.exoplayer2.util.ParsableByteArray
;
import
com.google.common.primitives.Bytes
;
import
java.io.IOException
;
import
java.util.Arrays
;
import
java.util.concurrent.atomic.AtomicReference
;
...
...
@@ -483,7 +484,7 @@ public final class SampleQueueTest {
byte
[]
sampleData
=
new
byte
[]
{
0
,
1
,
2
};
byte
[]
initializationVector
=
new
byte
[]
{
7
,
6
,
5
,
4
,
3
,
2
,
1
,
0
};
byte
[]
encryptedSampleData
=
TestUtil
.
joinByteArrays
(
Bytes
.
concat
(
new
byte
[]
{
0x08
,
// subsampleEncryption = false (1 bit), ivSize = 8 (7 bits).
},
...
...
library/extractor/build.gradle
View file @
2397e7f6
...
...
@@ -41,6 +41,7 @@ android {
dependencies
{
implementation
'androidx.annotation:annotation:'
+
androidxAnnotationVersion
implementation
project
(
modulePrefix
+
'library-common'
)
implementation
'com.google.guava:guava:'
+
guavaVersion
compileOnly
'org.checkerframework:checker-qual:'
+
checkerframeworkVersion
compileOnly
'org.checkerframework:checker-compat-qual:'
+
checkerframeworkVersion
compileOnly
'org.jetbrains.kotlin:kotlin-annotations-jvm:'
+
kotlinAnnotationsVersion
...
...
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeekerTest.java
View file @
2397e7f6
...
...
@@ -26,6 +26,7 @@ import com.google.android.exoplayer2.extractor.ExtractorInput;
import
com.google.android.exoplayer2.testutil.FakeExtractorInput
;
import
com.google.android.exoplayer2.testutil.TestUtil
;
import
com.google.android.exoplayer2.util.ParsableByteArray
;
import
com.google.common.primitives.Bytes
;
import
java.io.EOFException
;
import
java.io.IOException
;
import
java.util.Random
;
...
...
@@ -125,7 +126,7 @@ public final class DefaultOggSeekerTest {
public
void
skipToNextPage_success
()
throws
Exception
{
FakeExtractorInput
extractorInput
=
createInput
(
TestUtil
.
joinByteArrays
(
Bytes
.
concat
(
TestUtil
.
buildTestData
(
4000
,
random
),
new
byte
[]
{
'O'
,
'g'
,
'g'
,
'S'
},
TestUtil
.
buildTestData
(
4000
,
random
)),
...
...
@@ -138,7 +139,7 @@ public final class DefaultOggSeekerTest {
public
void
skipToNextPage_withOverlappingInput_success
()
throws
Exception
{
FakeExtractorInput
extractorInput
=
createInput
(
TestUtil
.
joinByteArrays
(
Bytes
.
concat
(
TestUtil
.
buildTestData
(
2046
,
random
),
new
byte
[]
{
'O'
,
'g'
,
'g'
,
'S'
},
TestUtil
.
buildTestData
(
4000
,
random
)),
...
...
@@ -151,8 +152,7 @@ public final class DefaultOggSeekerTest {
public
void
skipToNextPage_withInputShorterThanPeekLength_success
()
throws
Exception
{
FakeExtractorInput
extractorInput
=
createInput
(
TestUtil
.
joinByteArrays
(
new
byte
[]
{
'x'
,
'O'
,
'g'
,
'g'
,
'S'
}),
/* simulateUnknownLength= */
false
);
Bytes
.
concat
(
new
byte
[]
{
'x'
,
'O'
,
'g'
,
'g'
,
'S'
}),
/* simulateUnknownLength= */
false
);
skipToNextPage
(
extractorInput
);
assertThat
(
extractorInput
.
getPosition
()).
isEqualTo
(
1
);
}
...
...
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ts/AdtsReaderTest.java
View file @
2397e7f6
...
...
@@ -25,6 +25,7 @@ import com.google.android.exoplayer2.testutil.FakeExtractorOutput;
import
com.google.android.exoplayer2.testutil.FakeTrackOutput
;
import
com.google.android.exoplayer2.testutil.TestUtil
;
import
com.google.android.exoplayer2.util.ParsableByteArray
;
import
com.google.common.primitives.Bytes
;
import
java.util.Arrays
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -57,7 +58,7 @@ public class AdtsReaderTest {
TestUtil
.
createByteArray
(
0x20
,
0x00
,
0x20
,
0x00
,
0x00
,
0x80
,
0x0e
);
private
static
final
byte
[]
TEST_DATA
=
TestUtil
.
joinByteArrays
(
ID3_DATA_1
,
ID3_DATA_2
,
ADTS_HEADER
,
ADTS_CONTENT
);
Bytes
.
concat
(
ID3_DATA_1
,
ID3_DATA_2
,
ADTS_HEADER
,
ADTS_CONTENT
);
private
static
final
long
ADTS_SAMPLE_DURATION
=
23219L
;
...
...
@@ -94,7 +95,7 @@ public class AdtsReaderTest {
public
void
skipToNextSampleResetsState
()
throws
Exception
{
data
=
new
ParsableByteArray
(
TestUtil
.
joinByteArrays
(
Bytes
.
concat
(
ADTS_HEADER
,
ADTS_CONTENT
,
ADTS_HEADER
,
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTrackOutput.java
View file @
2397e7f6
...
...
@@ -27,6 +27,7 @@ import com.google.android.exoplayer2.util.Assertions;
import
com.google.android.exoplayer2.util.Function
;
import
com.google.android.exoplayer2.util.ParsableByteArray
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.common.primitives.Bytes
;
import
java.io.EOFException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
...
...
@@ -105,7 +106,7 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
throw
new
EOFException
();
}
newData
=
Arrays
.
copyOf
(
newData
,
bytesAppended
);
sampleData
=
TestUtil
.
joinByteArrays
(
sampleData
,
newData
);
sampleData
=
Bytes
.
concat
(
sampleData
,
newData
);
return
bytesAppended
;
}
...
...
@@ -113,7 +114,7 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
public
void
sampleData
(
ParsableByteArray
data
,
int
length
,
@SampleDataPart
int
sampleDataPart
)
{
byte
[]
newData
=
new
byte
[
length
];
data
.
readBytes
(
newData
,
0
,
length
);
sampleData
=
TestUtil
.
joinByteArrays
(
sampleData
,
newData
);
sampleData
=
Bytes
.
concat
(
sampleData
,
newData
);
}
@Override
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/TestUtil.java
View file @
2397e7f6
...
...
@@ -168,26 +168,6 @@ public class TestUtil {
return
byteArray
;
}
/**
* Concatenates the provided byte arrays.
*
* @param byteArrays The byte arrays to concatenate.
* @return The concatenated result.
*/
public
static
byte
[]
joinByteArrays
(
byte
[]...
byteArrays
)
{
int
length
=
0
;
for
(
byte
[]
byteArray
:
byteArrays
)
{
length
+=
byteArray
.
length
;
}
byte
[]
joined
=
new
byte
[
length
];
length
=
0
;
for
(
byte
[]
byteArray
:
byteArrays
)
{
System
.
arraycopy
(
byteArray
,
0
,
joined
,
length
,
byteArray
.
length
);
length
+=
byteArray
.
length
;
}
return
joined
;
}
/** Writes one byte long dummy test data to the file and returns it. */
public
static
File
createTestFile
(
File
directory
,
String
name
)
throws
IOException
{
return
createTestFile
(
directory
,
name
,
/* length= */
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