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
88af9448
authored
Nov 30, 2018
by
olly
Committed by
Oliver Woodman
Dec 01, 2018
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Move CachedContentIndex and SimpleCacheSpan tests to robolectric
PiperOrigin-RevId: 223518390
parent
beae7c9d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
21 deletions
library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndexTest.java → library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndexTest.java
library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpanTest.java → library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpanTest.java
library/core/src/
androidT
est/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndexTest.java
→
library/core/src/
t
est/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndexTest.java
View file @
88af9448
...
...
@@ -20,8 +20,6 @@ import static com.google.common.truth.Truth.assertWithMessage;
import
android.net.Uri
;
import
android.util.SparseArray
;
import
androidx.test.InstrumentationRegistry
;
import
androidx.test.runner.AndroidJUnit4
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.util.Util
;
import
java.io.File
;
...
...
@@ -34,9 +32,11 @@ import org.junit.After;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.robolectric.RobolectricTestRunner
;
import
org.robolectric.RuntimeEnvironment
;
/** Tests {@link CachedContentIndex}. */
@RunWith
(
AndroidJUnit4
.
class
)
@RunWith
(
RobolectricTestRunner
.
class
)
public
class
CachedContentIndexTest
{
private
final
byte
[]
testIndexV1File
=
{
...
...
@@ -79,7 +79,7 @@ public class CachedContentIndexTest {
@Before
public
void
setUp
()
throws
Exception
{
cacheDir
=
Util
.
createTempDirectory
(
InstrumentationRegistry
.
getTargetContext
()
,
"ExoPlayerTest"
);
Util
.
createTempDirectory
(
RuntimeEnvironment
.
application
,
"ExoPlayerTest"
);
index
=
new
CachedContentIndex
(
cacheDir
);
}
...
...
library/core/src/
androidT
est/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpanTest.java
→
library/core/src/
t
est/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpanTest.java
View file @
88af9448
...
...
@@ -18,8 +18,6 @@ package com.google.android.exoplayer2.upstream.cache;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertWithMessage
;
import
androidx.test.InstrumentationRegistry
;
import
androidx.test.runner.AndroidJUnit4
;
import
com.google.android.exoplayer2.util.Util
;
import
java.io.File
;
import
java.io.FileOutputStream
;
...
...
@@ -31,14 +29,13 @@ import org.junit.After;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.robolectric.RobolectricTestRunner
;
import
org.robolectric.RuntimeEnvironment
;
/** Unit tests for {@link SimpleCacheSpan}. */
@RunWith
(
AndroidJUnit4
.
class
)
@RunWith
(
RobolectricTestRunner
.
class
)
public
class
SimpleCacheSpanTest
{
private
CachedContentIndex
index
;
private
File
cacheDir
;
public
static
File
createCacheSpanFile
(
File
cacheDir
,
int
id
,
long
offset
,
int
length
,
long
lastAccessTimestamp
)
throws
IOException
{
File
cacheFile
=
SimpleCacheSpan
.
getCacheFile
(
cacheDir
,
id
,
offset
,
lastAccessTimestamp
);
...
...
@@ -46,17 +43,13 @@ public class SimpleCacheSpanTest {
return
cacheFile
;
}
public
static
CacheSpan
createCacheSpan
(
CachedContentIndex
index
,
File
cacheDir
,
String
key
,
long
offset
,
int
length
,
long
lastAccessTimestamp
)
throws
IOException
{
int
id
=
index
.
assignIdForKey
(
key
);
File
cacheFile
=
createCacheSpanFile
(
cacheDir
,
id
,
offset
,
length
,
lastAccessTimestamp
);
return
SimpleCacheSpan
.
createCacheEntry
(
cacheFile
,
index
);
}
private
CachedContentIndex
index
;
private
File
cacheDir
;
@Before
public
void
setUp
()
throws
Exception
{
cacheDir
=
Util
.
createTempDirectory
(
InstrumentationRegistry
.
getTargetContext
()
,
"ExoPlayerTest"
);
Util
.
createTempDirectory
(
RuntimeEnvironment
.
application
,
"ExoPlayerTest"
);
index
=
new
CachedContentIndex
(
cacheDir
);
}
...
...
@@ -86,12 +79,12 @@ public class SimpleCacheSpanTest {
@Test
public
void
testUpgradeFileName
()
throws
Exception
{
String
key
=
"a
sd\u00aa
"
;
String
key
=
"a
bc%def
"
;
int
id
=
index
.
assignIdForKey
(
key
);
File
v3file
=
createTestFile
(
id
+
".0.1.v3.exo"
);
File
v2file
=
createTestFile
(
"a
sd%aa.1.2.v2.exo"
);
File
wrongEscapedV2file
=
createTestFile
(
"a
sd%za.3.4.v2.exo"
);
File
v1File
=
createTestFile
(
"a
sd\u00aa.5.6.v1.exo"
);
File
v2file
=
createTestFile
(
"a
bc%25def.1.2.v2.exo"
);
// %25 is '%' after escaping
File
wrongEscapedV2file
=
createTestFile
(
"a
bc%2Gdef.3.4.v2.exo"
);
// 2G is invalid hex
File
v1File
=
createTestFile
(
"a
bc%def.5.6.v1.exo"
);
// V1 did not escape
for
(
File
file
:
cacheDir
.
listFiles
())
{
SimpleCacheSpan
cacheEntry
=
SimpleCacheSpan
.
createCacheEntry
(
file
,
index
);
...
...
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