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
c157db69
authored
Jul 20, 2021
by
samrobinson
Committed by
Ian Baker
Jul 21, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Split MediaMetadataTest cases into PictureFrameTest and ApicFrameTest.
PiperOrigin-RevId: 385758742
parent
fde3075a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
207 additions
and
84 deletions
library/common/src/test/java/com/google/android/exoplayer2/MediaMetadataTest.java
library/common/src/test/java/com/google/android/exoplayer2/metadata/flac/PictureFrameTest.java
library/common/src/test/java/com/google/android/exoplayer2/metadata/id3/ApicFrameTest.java
library/common/src/test/java/com/google/android/exoplayer2/MediaMetadataTest.java
View file @
c157db69
...
@@ -20,10 +20,6 @@ import static com.google.common.truth.Truth.assertThat;
...
@@ -20,10 +20,6 @@ import static com.google.common.truth.Truth.assertThat;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.MediaMetadata.PictureType
;
import
com.google.android.exoplayer2.metadata.Metadata
;
import
com.google.android.exoplayer2.metadata.id3.ApicFrame
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
...
@@ -132,82 +128,4 @@ public class MediaMetadataTest {
...
@@ -132,82 +128,4 @@ public class MediaMetadataTest {
assertThat
(
fromBundle
).
isEqualTo
(
mediaMetadata
);
assertThat
(
fromBundle
).
isEqualTo
(
mediaMetadata
);
assertThat
(
fromBundle
.
extras
.
getString
(
"exampleKey"
)).
isEqualTo
(
"exampleValue"
);
assertThat
(
fromBundle
.
extras
.
getString
(
"exampleKey"
)).
isEqualTo
(
"exampleValue"
);
}
}
@Test
public
void
builderPopulatedFromApicFrameEntry_setsArtwork
()
{
byte
[]
pictureData
=
new
byte
[]
{-
12
,
52
,
33
,
85
,
34
,
22
,
1
,
-
55
};
@PictureType
int
pictureType
=
MediaMetadata
.
PICTURE_TYPE_LEAFLET_PAGE
;
Metadata
.
Entry
entry
=
new
ApicFrame
(
/* mimeType= */
MimeTypes
.
BASE_TYPE_IMAGE
,
/* description= */
"an image"
,
pictureType
,
pictureData
);
MediaMetadata
.
Builder
builder
=
MediaMetadata
.
EMPTY
.
buildUpon
();
entry
.
populateMediaMetadata
(
builder
);
MediaMetadata
mediaMetadata
=
builder
.
build
();
assertThat
(
mediaMetadata
.
artworkData
).
isEqualTo
(
pictureData
);
assertThat
(
mediaMetadata
.
artworkDataType
).
isEqualTo
(
pictureType
);
}
@Test
public
void
builderPopulatedFromApicFrameEntry_considersTypePriority
()
{
byte
[]
data1
=
new
byte
[]
{
1
,
1
,
1
,
1
};
Metadata
.
Entry
entry1
=
new
ApicFrame
(
/* mimeType= */
MimeTypes
.
BASE_TYPE_IMAGE
,
/* description= */
"an image"
,
MediaMetadata
.
PICTURE_TYPE_BAND_ARTIST_LOGO
,
data1
);
byte
[]
data2
=
new
byte
[]
{
2
,
2
,
2
,
2
};
Metadata
.
Entry
entry2
=
new
ApicFrame
(
/* mimeType= */
MimeTypes
.
BASE_TYPE_IMAGE
,
/* description= */
"an image"
,
MediaMetadata
.
PICTURE_TYPE_ARTIST_PERFORMER
,
data2
);
byte
[]
data3
=
new
byte
[]
{
3
,
3
,
3
,
3
};
Metadata
.
Entry
entry3
=
new
ApicFrame
(
/* mimeType= */
MimeTypes
.
BASE_TYPE_IMAGE
,
/* description= */
"an image"
,
MediaMetadata
.
PICTURE_TYPE_FRONT_COVER
,
data3
);
byte
[]
data4
=
new
byte
[]
{
4
,
4
,
4
,
4
};
Metadata
.
Entry
entry4
=
new
ApicFrame
(
/* mimeType= */
MimeTypes
.
BASE_TYPE_IMAGE
,
/* description= */
"an image"
,
MediaMetadata
.
PICTURE_TYPE_ILLUSTRATION
,
data4
);
byte
[]
data5
=
new
byte
[]
{
5
,
5
,
5
,
5
};
Metadata
.
Entry
entry5
=
new
ApicFrame
(
/* mimeType= */
MimeTypes
.
BASE_TYPE_IMAGE
,
/* description= */
"an image"
,
MediaMetadata
.
PICTURE_TYPE_FRONT_COVER
,
data5
);
MediaMetadata
.
Builder
builder
=
MediaMetadata
.
EMPTY
.
buildUpon
();
entry1
.
populateMediaMetadata
(
builder
);
assertThat
(
builder
.
build
().
artworkData
).
isEqualTo
(
data1
);
// Data updates when any type is given, if the current type is not front cover.
entry2
.
populateMediaMetadata
(
builder
);
assertThat
(
builder
.
build
().
artworkData
).
isEqualTo
(
data2
);
// Data updates because this entry picture type is front cover.
entry3
.
populateMediaMetadata
(
builder
);
assertThat
(
builder
.
build
().
artworkData
).
isEqualTo
(
data3
);
// Data does not update because the current type is front cover, and this entry type is not.
entry4
.
populateMediaMetadata
(
builder
);
assertThat
(
builder
.
build
().
artworkData
).
isEqualTo
(
data3
);
// Data updates because this entry picture type is front cover.
entry5
.
populateMediaMetadata
(
builder
);
assertThat
(
builder
.
build
().
artworkData
).
isEqualTo
(
data5
);
}
}
}
library/common/src/test/java/com/google/android/exoplayer2/metadata/flac/PictureFrameTest.java
View file @
c157db69
...
@@ -44,11 +44,11 @@ public final class PictureFrameTest {
...
@@ -44,11 +44,11 @@ public final class PictureFrameTest {
}
}
@Test
@Test
public
void
populateMediaMetadata_sets
MediaMetadataValue
()
{
public
void
populateMediaMetadata_sets
BuilderValues
()
{
byte
[]
pictureData
=
new
byte
[]
{-
12
,
52
,
33
,
85
,
34
,
22
,
1
,
-
55
};
byte
[]
pictureData
=
new
byte
[]
{-
12
,
52
,
33
,
85
,
34
,
22
,
1
,
-
55
};
Metadata
.
Entry
entry
=
Metadata
.
Entry
entry
=
new
PictureFrame
(
new
PictureFrame
(
/* pictureType= */
0x03
,
/* pictureType= */
MediaMetadata
.
PICTURE_TYPE_FRONT_COVER
,
/* mimeType= */
MimeTypes
.
IMAGE_JPEG
,
/* mimeType= */
MimeTypes
.
IMAGE_JPEG
,
/* description= */
"an image"
,
/* description= */
"an image"
,
/* width= */
4
,
/* width= */
4
,
...
@@ -62,5 +62,87 @@ public final class PictureFrameTest {
...
@@ -62,5 +62,87 @@ public final class PictureFrameTest {
MediaMetadata
mediaMetadata
=
builder
.
build
();
MediaMetadata
mediaMetadata
=
builder
.
build
();
assertThat
(
mediaMetadata
.
artworkData
).
isEqualTo
(
pictureData
);
assertThat
(
mediaMetadata
.
artworkData
).
isEqualTo
(
pictureData
);
assertThat
(
mediaMetadata
.
artworkDataType
).
isEqualTo
(
MediaMetadata
.
PICTURE_TYPE_FRONT_COVER
);
}
@Test
public
void
populateMediaMetadata_considersTypePriority
()
{
byte
[]
data1
=
new
byte
[]
{
1
,
1
,
1
,
1
};
byte
[]
data2
=
new
byte
[]
{
2
,
2
,
2
,
2
};
byte
[]
data3
=
new
byte
[]
{
3
,
3
,
3
,
3
};
byte
[]
data4
=
new
byte
[]
{
4
,
4
,
4
,
4
};
byte
[]
data5
=
new
byte
[]
{
5
,
5
,
5
,
5
};
Metadata
.
Entry
entry1
=
new
PictureFrame
(
/* pictureType= */
MediaMetadata
.
PICTURE_TYPE_BAND_ORCHESTRA
,
/* mimeType= */
MimeTypes
.
IMAGE_JPEG
,
/* description= */
"an image"
,
/* width= */
2
,
/* height= */
2
,
/* depth= */
1
,
/* colors= */
1
,
data1
);
Metadata
.
Entry
entry2
=
new
PictureFrame
(
/* pictureType= */
MediaMetadata
.
PICTURE_TYPE_DURING_RECORDING
,
/* mimeType= */
MimeTypes
.
IMAGE_JPEG
,
/* description= */
"an image"
,
/* width= */
2
,
/* height= */
2
,
/* depth= */
1
,
/* colors= */
1
,
data2
);
Metadata
.
Entry
entry3
=
new
PictureFrame
(
/* pictureType= */
MediaMetadata
.
PICTURE_TYPE_FRONT_COVER
,
/* mimeType= */
MimeTypes
.
IMAGE_JPEG
,
/* description= */
"an image"
,
/* width= */
2
,
/* height= */
2
,
/* depth= */
1
,
/* colors= */
1
,
data3
);
Metadata
.
Entry
entry4
=
new
PictureFrame
(
/* pictureType= */
MediaMetadata
.
PICTURE_TYPE_ARTIST_PERFORMER
,
/* mimeType= */
MimeTypes
.
IMAGE_JPEG
,
/* description= */
"an image"
,
/* width= */
2
,
/* height= */
2
,
/* depth= */
1
,
/* colors= */
1
,
data4
);
Metadata
.
Entry
entry5
=
new
PictureFrame
(
/* pictureType= */
MediaMetadata
.
PICTURE_TYPE_FRONT_COVER
,
/* mimeType= */
MimeTypes
.
IMAGE_JPEG
,
/* description= */
"an image"
,
/* width= */
2
,
/* height= */
2
,
/* depth= */
1
,
/* colors= */
1
,
data5
);
MediaMetadata
.
Builder
builder
=
MediaMetadata
.
EMPTY
.
buildUpon
();
entry1
.
populateMediaMetadata
(
builder
);
assertThat
(
builder
.
build
().
artworkData
).
isEqualTo
(
data1
);
// Data updates when any type is given, if the current type is not front cover.
entry2
.
populateMediaMetadata
(
builder
);
assertThat
(
builder
.
build
().
artworkData
).
isEqualTo
(
data2
);
// Data updates because this entry picture type is front cover.
entry3
.
populateMediaMetadata
(
builder
);
assertThat
(
builder
.
build
().
artworkData
).
isEqualTo
(
data3
);
// Data does not update because the current type is front cover, and this entry type is not.
entry4
.
populateMediaMetadata
(
builder
);
assertThat
(
builder
.
build
().
artworkData
).
isEqualTo
(
data3
);
// Data updates because this entry picture type is front cover.
entry5
.
populateMediaMetadata
(
builder
);
assertThat
(
builder
.
build
().
artworkData
).
isEqualTo
(
data5
);
}
}
}
}
library/common/src/test/java/com/google/android/exoplayer2/metadata/id3/ApicFrameTest.java
0 → 100644
View file @
c157db69
/*
* Copyright 2021 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
.
metadata
.
id3
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
android.os.Parcel
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.MediaMetadata
;
import
com.google.android.exoplayer2.metadata.Metadata
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
/** Unit test for {@link ApicFrame}. */
@RunWith
(
AndroidJUnit4
.
class
)
public
class
ApicFrameTest
{
@Test
public
void
parcelable
()
{
ApicFrame
apicFrameToParcel
=
new
ApicFrame
(
""
,
""
,
0
,
new
byte
[
0
]);
Parcel
parcel
=
Parcel
.
obtain
();
apicFrameToParcel
.
writeToParcel
(
parcel
,
0
);
parcel
.
setDataPosition
(
0
);
ApicFrame
apicFrameFromParcel
=
ApicFrame
.
CREATOR
.
createFromParcel
(
parcel
);
assertThat
(
apicFrameFromParcel
).
isEqualTo
(
apicFrameToParcel
);
parcel
.
recycle
();
}
@Test
public
void
populateMediaMetadata_setsBuilderValues
()
{
byte
[]
pictureData
=
new
byte
[]
{-
12
,
52
,
33
,
85
,
34
,
22
,
1
,
-
55
};
@MediaMetadata
.
PictureType
int
pictureType
=
MediaMetadata
.
PICTURE_TYPE_LEAFLET_PAGE
;
Metadata
.
Entry
entry
=
new
ApicFrame
(
/* mimeType= */
MimeTypes
.
BASE_TYPE_IMAGE
,
/* description= */
"an image"
,
pictureType
,
pictureData
);
MediaMetadata
.
Builder
builder
=
MediaMetadata
.
EMPTY
.
buildUpon
();
entry
.
populateMediaMetadata
(
builder
);
MediaMetadata
mediaMetadata
=
builder
.
build
();
assertThat
(
mediaMetadata
.
artworkData
).
isEqualTo
(
pictureData
);
assertThat
(
mediaMetadata
.
artworkDataType
).
isEqualTo
(
pictureType
);
}
@Test
public
void
populateMediaMetadata_considersTypePriority
()
{
byte
[]
data1
=
new
byte
[]
{
1
,
1
,
1
,
1
};
byte
[]
data2
=
new
byte
[]
{
2
,
2
,
2
,
2
};
byte
[]
data3
=
new
byte
[]
{
3
,
3
,
3
,
3
};
byte
[]
data4
=
new
byte
[]
{
4
,
4
,
4
,
4
};
byte
[]
data5
=
new
byte
[]
{
5
,
5
,
5
,
5
};
Metadata
.
Entry
entry1
=
new
ApicFrame
(
/* mimeType= */
MimeTypes
.
BASE_TYPE_IMAGE
,
/* description= */
"an image"
,
MediaMetadata
.
PICTURE_TYPE_BAND_ARTIST_LOGO
,
data1
);
Metadata
.
Entry
entry2
=
new
ApicFrame
(
/* mimeType= */
MimeTypes
.
BASE_TYPE_IMAGE
,
/* description= */
"an image"
,
MediaMetadata
.
PICTURE_TYPE_ARTIST_PERFORMER
,
data2
);
Metadata
.
Entry
entry3
=
new
ApicFrame
(
/* mimeType= */
MimeTypes
.
BASE_TYPE_IMAGE
,
/* description= */
"an image"
,
MediaMetadata
.
PICTURE_TYPE_FRONT_COVER
,
data3
);
Metadata
.
Entry
entry4
=
new
ApicFrame
(
/* mimeType= */
MimeTypes
.
BASE_TYPE_IMAGE
,
/* description= */
"an image"
,
MediaMetadata
.
PICTURE_TYPE_ILLUSTRATION
,
data4
);
Metadata
.
Entry
entry5
=
new
ApicFrame
(
/* mimeType= */
MimeTypes
.
BASE_TYPE_IMAGE
,
/* description= */
"an image"
,
MediaMetadata
.
PICTURE_TYPE_FRONT_COVER
,
data5
);
MediaMetadata
.
Builder
builder
=
MediaMetadata
.
EMPTY
.
buildUpon
();
entry1
.
populateMediaMetadata
(
builder
);
assertThat
(
builder
.
build
().
artworkData
).
isEqualTo
(
data1
);
// Data updates when any type is given, if the current type is not front cover.
entry2
.
populateMediaMetadata
(
builder
);
assertThat
(
builder
.
build
().
artworkData
).
isEqualTo
(
data2
);
// Data updates because this entry picture type is front cover.
entry3
.
populateMediaMetadata
(
builder
);
assertThat
(
builder
.
build
().
artworkData
).
isEqualTo
(
data3
);
// Data does not update because the current type is front cover, and this entry type is not.
entry4
.
populateMediaMetadata
(
builder
);
assertThat
(
builder
.
build
().
artworkData
).
isEqualTo
(
data3
);
// Data updates because this entry picture type is front cover.
entry5
.
populateMediaMetadata
(
builder
);
assertThat
(
builder
.
build
().
artworkData
).
isEqualTo
(
data5
);
}
}
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