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
333de741
authored
Feb 10, 2021
by
christosts
Committed by
Ian Baker
Feb 11, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Minor fixes in CacheDataSourceTest
PiperOrigin-RevId: 356695284
parent
41c94edc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceTest.java
library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceTest.java
View file @
333de741
...
@@ -265,30 +265,31 @@ public final class CacheDataSourceTest {
...
@@ -265,30 +265,31 @@ public final class CacheDataSourceTest {
}
}
@Test
@Test
public
void
contentLengthEdgeCases
()
throws
Exception
{
public
void
boundedRead_doesNotSetContentLength
()
throws
Exception
{
DataSpec
dataSpec
=
buildDataSpec
(
TEST_DATA
.
length
-
2
,
2
);
DataSpec
dataSpec
=
buildDataSpec
(
0
,
TEST_DATA
.
length
);
// Read partial at EOS but don't cross it so length is unknown.
// Read up to the end of the data, but since the DataSpec is bounded, the read doesn't see the
// EOS, and so the content length remains unknown.
CacheDataSource
cacheDataSource
=
createCacheDataSource
(
false
,
true
);
CacheDataSource
cacheDataSource
=
createCacheDataSource
(
false
,
true
);
assertReadData
(
cacheDataSource
,
dataSpec
,
true
);
assertReadData
(
cacheDataSource
,
dataSpec
,
true
);
assertThat
(
ContentMetadata
.
getContentLength
(
cache
.
getContentMetadata
(
defaultCacheKey
)))
assertThat
(
ContentMetadata
.
getContentLength
(
cache
.
getContentMetadata
(
defaultCacheKey
)))
.
isEqualTo
(
C
.
LENGTH_UNSET
);
.
isEqualTo
(
C
.
LENGTH_UNSET
);
}
// Now do an unbounded request for whole data. This will cause a bounded request from upstream.
@Test
// End of data from upstream shouldn't be mixed up with EOS and cause length set wrong.
public
void
unboundedRead_setsContentLength
()
throws
IOException
{
cacheDataSource
=
createCacheDataSource
(
false
,
true
);
// Perform an unbounded request for the whole data. This should cause the content length to
// become known.
CacheDataSource
cacheDataSource
=
createCacheDataSource
(
false
,
true
);
assertReadDataContentLength
(
cacheDataSource
,
unboundedDataSpec
,
true
,
false
);
assertReadDataContentLength
(
cacheDataSource
,
unboundedDataSpec
,
true
,
false
);
//
Now the length set correctly do an unbounded request with offse
t.
//
Check the correct length is returned for an unbounded reques
t.
assertThat
(
assertThat
(
cacheDataSource
.
open
(
cacheDataSource
.
open
(
buildDataSpec
(
TEST_DATA
.
length
-
2
,
C
.
LENGTH_UNSET
,
defaultCacheKey
)))
buildDataSpec
(
TEST_DATA
.
length
-
2
,
C
.
LENGTH_UNSET
,
defaultCacheKey
)))
.
isEqualTo
(
2
);
.
isEqualTo
(
2
);
cacheDataSource
.
close
();
// An unbounded request with offset for not cached content.
dataSpec
=
new
DataSpec
(
Uri
.
parse
(
"https://www.test.com/other"
),
TEST_DATA
.
length
-
2
,
C
.
LENGTH_UNSET
);
assertThat
(
cacheDataSource
.
open
(
dataSpec
)).
isEqualTo
(
C
.
LENGTH_UNSET
);
}
}
@Test
@Test
...
...
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