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
920d2e03
authored
Feb 23, 2021
by
olly
Committed by
marcbaechinger
Feb 23, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Remove unused mocking in CacheWriterTest
#minor-release PiperOrigin-RevId: 358998449
parent
b4b22d98
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
48 deletions
library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheWriterTest.java
library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheWriterTest.java
View file @
920d2e03
...
@@ -17,7 +17,6 @@ package com.google.android.exoplayer2.upstream.cache;
...
@@ -17,7 +17,6 @@ package com.google.android.exoplayer2.upstream.cache;
import
static
com
.
google
.
android
.
exoplayer2
.
testutil
.
CacheAsserts
.
assertCachedData
;
import
static
com
.
google
.
android
.
exoplayer2
.
testutil
.
CacheAsserts
.
assertCachedData
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
java
.
lang
.
Math
.
min
;
import
static
org
.
junit
.
Assert
.
assertThrows
;
import
static
org
.
junit
.
Assert
.
assertThrows
;
import
android.net.Uri
;
import
android.net.Uri
;
...
@@ -36,65 +35,18 @@ import org.junit.After;
...
@@ -36,65 +35,18 @@ import org.junit.After;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.mockito.Answers
;
import
org.mockito.Mock
;
import
org.mockito.MockitoAnnotations
;
import
org.mockito.MockitoAnnotations
;
/** Unit tests for {@link CacheWriter}. */
/** Unit tests for {@link CacheWriter}. */
@RunWith
(
AndroidJUnit4
.
class
)
@RunWith
(
AndroidJUnit4
.
class
)
public
final
class
CacheWriterTest
{
public
final
class
CacheWriterTest
{
/**
* Abstract fake Cache implementation used by the test. This class must be public so Mockito can
* create a proxy for it.
*/
public
abstract
static
class
AbstractFakeCache
implements
Cache
{
// This array is set to alternating length of cached and not cached regions in tests:
// spansAndGaps = {<length of 1st cached region>, <length of 1st not cached region>,
// <length of 2nd cached region>, <length of 2nd not cached region>, ... }
// Ideally it should end with a cached region but it shouldn't matter for any code.
private
int
[]
spansAndGaps
;
private
long
contentLength
;
private
void
init
()
{
spansAndGaps
=
new
int
[]
{};
contentLength
=
C
.
LENGTH_UNSET
;
}
@Override
public
long
getCachedLength
(
String
key
,
long
position
,
long
length
)
{
if
(
length
==
C
.
LENGTH_UNSET
)
{
length
=
Long
.
MAX_VALUE
;
}
for
(
int
i
=
0
;
i
<
spansAndGaps
.
length
;
i
++)
{
int
spanOrGap
=
spansAndGaps
[
i
];
if
(
position
<
spanOrGap
)
{
long
left
=
min
(
spanOrGap
-
position
,
length
);
return
(
i
&
1
)
==
1
?
-
left
:
left
;
}
position
-=
spanOrGap
;
}
return
-
length
;
}
@Override
public
ContentMetadata
getContentMetadata
(
String
key
)
{
DefaultContentMetadata
metadata
=
new
DefaultContentMetadata
();
ContentMetadataMutations
mutations
=
new
ContentMetadataMutations
();
ContentMetadataMutations
.
setContentLength
(
mutations
,
contentLength
);
return
metadata
.
copyWithMutationsApplied
(
mutations
);
}
}
@Mock
(
answer
=
Answers
.
CALLS_REAL_METHODS
)
private
AbstractFakeCache
mockCache
;
private
File
tempFolder
;
private
File
tempFolder
;
private
SimpleCache
cache
;
private
SimpleCache
cache
;
@Before
@Before
public
void
setUp
()
throws
Exception
{
public
void
setUp
()
throws
Exception
{
MockitoAnnotations
.
initMocks
(
this
);
MockitoAnnotations
.
initMocks
(
this
);
mockCache
.
init
();
tempFolder
=
tempFolder
=
Util
.
createTempDirectory
(
ApplicationProvider
.
getApplicationContext
(),
"ExoPlayerTest"
);
Util
.
createTempDirectory
(
ApplicationProvider
.
getApplicationContext
(),
"ExoPlayerTest"
);
cache
=
cache
=
...
...
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