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
e14617fc
authored
Feb 15, 2022
by
Dustin
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Merged Robo and non-Robo tests into one file
parent
4f09fc36
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
103 additions
and
133 deletions
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/AviExtractorRoboTest.java
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/AviExtractorTest.java
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/AviExtractorRoboTest.java
deleted
100644 → 0
View file @
4f09fc36
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
google
.
android
.
exoplayer2
.
extractor
.
avi
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.extractor.Extractor
;
import
com.google.android.exoplayer2.extractor.ExtractorInput
;
import
com.google.android.exoplayer2.extractor.PositionHolder
;
import
com.google.android.exoplayer2.testutil.FakeExtractorInput
;
import
com.google.android.exoplayer2.testutil.FakeExtractorOutput
;
import
com.google.android.exoplayer2.testutil.FakeTrackOutput
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
java.io.IOException
;
import
java.nio.ByteBuffer
;
import
java.util.Collections
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
@RunWith
(
AndroidJUnit4
.
class
)
public
class
AviExtractorRoboTest
{
@Test
public
void
parseStream_givenXvidStreamList
()
throws
IOException
{
final
AviExtractor
aviExtractor
=
new
AviExtractor
();
final
FakeExtractorOutput
fakeExtractorOutput
=
new
FakeExtractorOutput
();
aviExtractor
.
init
(
fakeExtractorOutput
);
final
ListBox
streamList
=
DataHelper
.
getVideoStreamList
();
aviExtractor
.
parseStream
(
streamList
,
0
);
FakeTrackOutput
trackOutput
=
fakeExtractorOutput
.
track
(
0
,
C
.
TRACK_TYPE_VIDEO
);
Assert
.
assertEquals
(
MimeTypes
.
VIDEO_MP4V
,
trackOutput
.
lastFormat
.
sampleMimeType
);
}
@Test
public
void
parseStream_givenAacStreamList
()
throws
IOException
{
final
AviExtractor
aviExtractor
=
new
AviExtractor
();
final
FakeExtractorOutput
fakeExtractorOutput
=
new
FakeExtractorOutput
();
aviExtractor
.
init
(
fakeExtractorOutput
);
final
ListBox
streamList
=
DataHelper
.
getAacStreamList
();
aviExtractor
.
parseStream
(
streamList
,
0
);
FakeTrackOutput
trackOutput
=
fakeExtractorOutput
.
track
(
0
,
C
.
TRACK_TYPE_VIDEO
);
Assert
.
assertEquals
(
MimeTypes
.
AUDIO_AAC
,
trackOutput
.
lastFormat
.
sampleMimeType
);
}
@Test
public
void
parseStream_givenNoStreamHeader
()
{
final
AviExtractor
aviExtractor
=
new
AviExtractor
();
final
FakeExtractorOutput
fakeExtractorOutput
=
new
FakeExtractorOutput
();
aviExtractor
.
init
(
fakeExtractorOutput
);
final
ListBox
streamList
=
new
ListBox
(
128
,
ListBox
.
TYPE_STRL
,
Collections
.
EMPTY_LIST
);
Assert
.
assertNull
(
aviExtractor
.
parseStream
(
streamList
,
0
));
}
@Test
public
void
parseStream_givenNoStreamFormat
()
{
final
AviExtractor
aviExtractor
=
new
AviExtractor
();
final
FakeExtractorOutput
fakeExtractorOutput
=
new
FakeExtractorOutput
();
aviExtractor
.
init
(
fakeExtractorOutput
);
final
ListBox
streamList
=
new
ListBox
(
128
,
ListBox
.
TYPE_STRL
,
Collections
.
singletonList
(
DataHelper
.
getVidsStreamHeader
()));
Assert
.
assertNull
(
aviExtractor
.
parseStream
(
streamList
,
0
));
}
@Test
public
void
readTracks_givenVideoTrack
()
throws
IOException
{
final
AviExtractor
aviExtractor
=
new
AviExtractor
();
aviExtractor
.
setAviHeader
(
DataHelper
.
createAviHeaderBox
());
final
FakeExtractorOutput
fakeExtractorOutput
=
new
FakeExtractorOutput
();
aviExtractor
.
init
(
fakeExtractorOutput
);
final
ByteBuffer
byteBuffer
=
DataHelper
.
getRiffHeader
(
0xdc
,
0xc8
);
final
ByteBuffer
aviHeader
=
DataHelper
.
createAviHeader
();
byteBuffer
.
putInt
(
aviHeader
.
capacity
());
byteBuffer
.
put
(
aviHeader
);
byteBuffer
.
putInt
(
ListBox
.
LIST
);
byteBuffer
.
putInt
(
byteBuffer
.
remaining
()
-
4
);
byteBuffer
.
putInt
(
ListBox
.
TYPE_STRL
);
final
StreamHeaderBox
streamHeaderBox
=
DataHelper
.
getVidsStreamHeader
();
byteBuffer
.
putInt
(
StreamHeaderBox
.
STRH
);
byteBuffer
.
putInt
(
streamHeaderBox
.
getSize
());
byteBuffer
.
put
(
streamHeaderBox
.
getByteBuffer
());
final
StreamFormatBox
streamFormatBox
=
DataHelper
.
getVideoStreamFormat
();
byteBuffer
.
putInt
(
StreamFormatBox
.
STRF
);
byteBuffer
.
putInt
(
streamFormatBox
.
getSize
());
byteBuffer
.
put
(
streamFormatBox
.
getByteBuffer
());
aviExtractor
.
state
=
AviExtractor
.
STATE_READ_TRACKS
;
final
ExtractorInput
input
=
new
FakeExtractorInput
.
Builder
().
setData
(
byteBuffer
.
array
()).
build
();
final
PositionHolder
positionHolder
=
new
PositionHolder
();
aviExtractor
.
read
(
input
,
positionHolder
);
Assert
.
assertEquals
(
AviExtractor
.
STATE_FIND_MOVI
,
aviExtractor
.
state
);
final
ChunkHandler
chunkHandler
=
aviExtractor
.
getVideoTrack
();
Assert
.
assertEquals
(
chunkHandler
.
getClock
().
durationUs
,
streamHeaderBox
.
getDurationUs
());
}
@Test
public
void
readSamples_fragmentedChunk
()
throws
IOException
{
AviExtractor
aviExtractor
=
AviExtractorTest
.
setupVideoAviExtractor
();
final
ChunkHandler
chunkHandler
=
aviExtractor
.
getVideoTrack
();
final
int
size
=
24
+
16
;
final
ByteBuffer
byteBuffer
=
AviExtractor
.
allocate
(
size
+
8
);
byteBuffer
.
putInt
(
chunkHandler
.
chunkId
);
byteBuffer
.
putInt
(
size
);
final
ExtractorInput
chunk
=
new
FakeExtractorInput
.
Builder
().
setData
(
byteBuffer
.
array
()).
setSimulatePartialReads
(
true
).
build
();
Assert
.
assertEquals
(
Extractor
.
RESULT_CONTINUE
,
aviExtractor
.
read
(
chunk
,
new
PositionHolder
()));
Assert
.
assertEquals
(
Extractor
.
RESULT_CONTINUE
,
aviExtractor
.
read
(
chunk
,
new
PositionHolder
()));
final
FakeTrackOutput
fakeTrackOutput
=
(
FakeTrackOutput
)
chunkHandler
.
trackOutput
;
Assert
.
assertEquals
(
size
,
fakeTrackOutput
.
getSampleData
(
0
).
length
);
}
}
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/AviExtractorTest.java
View file @
e14617fc
...
@@ -15,6 +15,8 @@
...
@@ -15,6 +15,8 @@
*/
*/
package
com
.
google
.
android
.
exoplayer2
.
extractor
.
avi
;
package
com
.
google
.
android
.
exoplayer2
.
extractor
.
avi
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.extractor.Extractor
;
import
com.google.android.exoplayer2.extractor.Extractor
;
import
com.google.android.exoplayer2.extractor.ExtractorInput
;
import
com.google.android.exoplayer2.extractor.ExtractorInput
;
...
@@ -26,9 +28,12 @@ import com.google.android.exoplayer2.testutil.FakeTrackOutput;
...
@@ -26,9 +28,12 @@ import com.google.android.exoplayer2.testutil.FakeTrackOutput;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
import
java.util.Collections
;
import
org.junit.Assert
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
@RunWith
(
AndroidJUnit4
.
class
)
public
class
AviExtractorTest
{
public
class
AviExtractorTest
{
@Test
@Test
...
@@ -492,4 +497,101 @@ public class AviExtractorTest {
...
@@ -492,4 +497,101 @@ public class AviExtractorTest {
aviExtractor
.
release
();
aviExtractor
.
release
();
//Nothing to assert on a method that does nothing
//Nothing to assert on a method that does nothing
}
}
@Test
public
void
parseStream_givenXvidStreamList
()
throws
IOException
{
final
AviExtractor
aviExtractor
=
new
AviExtractor
();
final
FakeExtractorOutput
fakeExtractorOutput
=
new
FakeExtractorOutput
();
aviExtractor
.
init
(
fakeExtractorOutput
);
final
ListBox
streamList
=
DataHelper
.
getVideoStreamList
();
aviExtractor
.
parseStream
(
streamList
,
0
);
FakeTrackOutput
trackOutput
=
fakeExtractorOutput
.
track
(
0
,
C
.
TRACK_TYPE_VIDEO
);
Assert
.
assertEquals
(
MimeTypes
.
VIDEO_MP4V
,
trackOutput
.
lastFormat
.
sampleMimeType
);
}
@Test
public
void
parseStream_givenAacStreamList
()
throws
IOException
{
final
AviExtractor
aviExtractor
=
new
AviExtractor
();
final
FakeExtractorOutput
fakeExtractorOutput
=
new
FakeExtractorOutput
();
aviExtractor
.
init
(
fakeExtractorOutput
);
final
ListBox
streamList
=
DataHelper
.
getAacStreamList
();
aviExtractor
.
parseStream
(
streamList
,
0
);
FakeTrackOutput
trackOutput
=
fakeExtractorOutput
.
track
(
0
,
C
.
TRACK_TYPE_VIDEO
);
Assert
.
assertEquals
(
MimeTypes
.
AUDIO_AAC
,
trackOutput
.
lastFormat
.
sampleMimeType
);
}
@Test
public
void
parseStream_givenNoStreamHeader
()
{
final
AviExtractor
aviExtractor
=
new
AviExtractor
();
final
FakeExtractorOutput
fakeExtractorOutput
=
new
FakeExtractorOutput
();
aviExtractor
.
init
(
fakeExtractorOutput
);
final
ListBox
streamList
=
new
ListBox
(
128
,
ListBox
.
TYPE_STRL
,
Collections
.
EMPTY_LIST
);
Assert
.
assertNull
(
aviExtractor
.
parseStream
(
streamList
,
0
));
}
@Test
public
void
parseStream_givenNoStreamFormat
()
{
final
AviExtractor
aviExtractor
=
new
AviExtractor
();
final
FakeExtractorOutput
fakeExtractorOutput
=
new
FakeExtractorOutput
();
aviExtractor
.
init
(
fakeExtractorOutput
);
final
ListBox
streamList
=
new
ListBox
(
128
,
ListBox
.
TYPE_STRL
,
Collections
.
singletonList
(
DataHelper
.
getVidsStreamHeader
()));
Assert
.
assertNull
(
aviExtractor
.
parseStream
(
streamList
,
0
));
}
@Test
public
void
readTracks_givenVideoTrack
()
throws
IOException
{
final
AviExtractor
aviExtractor
=
new
AviExtractor
();
aviExtractor
.
setAviHeader
(
DataHelper
.
createAviHeaderBox
());
final
FakeExtractorOutput
fakeExtractorOutput
=
new
FakeExtractorOutput
();
aviExtractor
.
init
(
fakeExtractorOutput
);
final
ByteBuffer
byteBuffer
=
DataHelper
.
getRiffHeader
(
0xdc
,
0xc8
);
final
ByteBuffer
aviHeader
=
DataHelper
.
createAviHeader
();
byteBuffer
.
putInt
(
aviHeader
.
capacity
());
byteBuffer
.
put
(
aviHeader
);
byteBuffer
.
putInt
(
ListBox
.
LIST
);
byteBuffer
.
putInt
(
byteBuffer
.
remaining
()
-
4
);
byteBuffer
.
putInt
(
ListBox
.
TYPE_STRL
);
final
StreamHeaderBox
streamHeaderBox
=
DataHelper
.
getVidsStreamHeader
();
byteBuffer
.
putInt
(
StreamHeaderBox
.
STRH
);
byteBuffer
.
putInt
(
streamHeaderBox
.
getSize
());
byteBuffer
.
put
(
streamHeaderBox
.
getByteBuffer
());
final
StreamFormatBox
streamFormatBox
=
DataHelper
.
getVideoStreamFormat
();
byteBuffer
.
putInt
(
StreamFormatBox
.
STRF
);
byteBuffer
.
putInt
(
streamFormatBox
.
getSize
());
byteBuffer
.
put
(
streamFormatBox
.
getByteBuffer
());
aviExtractor
.
state
=
AviExtractor
.
STATE_READ_TRACKS
;
final
ExtractorInput
input
=
new
FakeExtractorInput
.
Builder
().
setData
(
byteBuffer
.
array
()).
build
();
final
PositionHolder
positionHolder
=
new
PositionHolder
();
aviExtractor
.
read
(
input
,
positionHolder
);
Assert
.
assertEquals
(
AviExtractor
.
STATE_FIND_MOVI
,
aviExtractor
.
state
);
final
ChunkHandler
chunkHandler
=
aviExtractor
.
getVideoTrack
();
Assert
.
assertEquals
(
chunkHandler
.
getClock
().
durationUs
,
streamHeaderBox
.
getDurationUs
());
}
@Test
public
void
readSamples_fragmentedChunk
()
throws
IOException
{
AviExtractor
aviExtractor
=
AviExtractorTest
.
setupVideoAviExtractor
();
final
ChunkHandler
chunkHandler
=
aviExtractor
.
getVideoTrack
();
final
int
size
=
24
+
16
;
final
ByteBuffer
byteBuffer
=
AviExtractor
.
allocate
(
size
+
8
);
byteBuffer
.
putInt
(
chunkHandler
.
chunkId
);
byteBuffer
.
putInt
(
size
);
final
ExtractorInput
chunk
=
new
FakeExtractorInput
.
Builder
().
setData
(
byteBuffer
.
array
()).
setSimulatePartialReads
(
true
).
build
();
Assert
.
assertEquals
(
Extractor
.
RESULT_CONTINUE
,
aviExtractor
.
read
(
chunk
,
new
PositionHolder
()));
Assert
.
assertEquals
(
Extractor
.
RESULT_CONTINUE
,
aviExtractor
.
read
(
chunk
,
new
PositionHolder
()));
final
FakeTrackOutput
fakeTrackOutput
=
(
FakeTrackOutput
)
chunkHandler
.
trackOutput
;
Assert
.
assertEquals
(
size
,
fakeTrackOutput
.
getSampleData
(
0
).
length
);
}
}
}
\ No newline at end of file
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