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
b77cc7c6
authored
Jun 17, 2017
by
Karol Wrótniak
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Introduced failing unit test for ContentDataSource
parent
8af77acb
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
0 deletions
library/core/src/androidTest/AndroidManifest.xml
library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/AndroidDataSourceTest.java
library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/TestDataProvider.java
library/core/src/androidTest/AndroidManifest.xml
View file @
b77cc7c6
...
@@ -24,6 +24,9 @@
...
@@ -24,6 +24,9 @@
android:allowBackup=
"false"
android:allowBackup=
"false"
tools:ignore=
"MissingApplicationIcon,HardcodedDebugMode"
>
tools:ignore=
"MissingApplicationIcon,HardcodedDebugMode"
>
<uses-library
android:name=
"android.test.runner"
/>
<uses-library
android:name=
"android.test.runner"
/>
<provider
android:authorities=
"exoplayer"
android:name=
"com.google.android.exoplayer2.upstream.TestDataProvider"
/>
</application>
</application>
<instrumentation
<instrumentation
...
...
library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/AndroidDataSourceTest.java
0 → 100644
View file @
b77cc7c6
package
com
.
google
.
android
.
exoplayer2
.
upstream
;
import
android.content.Context
;
import
android.net.Uri
;
import
android.test.InstrumentationTestCase
;
public
class
AndroidDataSourceTest
extends
InstrumentationTestCase
{
private
static
final
long
SAMPLE_MP4_BYTES
=
101597
;
private
static
final
String
SAMPLE_MP4_PATH
=
"/mp4/sample.mp4"
;
public
void
testAssetDataSource
()
throws
Exception
{
final
Context
context
=
getInstrumentation
().
getContext
();
AssetDataSource
dataSource
=
new
AssetDataSource
(
context
);
Uri
assetUri
=
Uri
.
parse
(
"file:///android_asset"
+
SAMPLE_MP4_PATH
);
DataSpec
dataSpec
=
new
DataSpec
(
assetUri
);
long
sourceLengthBytes
=
dataSource
.
open
(
dataSpec
);
assertEquals
(
SAMPLE_MP4_BYTES
,
sourceLengthBytes
);
}
public
void
testContentDataSource
()
throws
Exception
{
Context
context
=
getInstrumentation
().
getContext
();
ContentDataSource
dataSource
=
new
ContentDataSource
(
context
);
Uri
contentUri
=
Uri
.
parse
(
"content://exoplayer"
+
SAMPLE_MP4_PATH
);
DataSpec
dataSpec
=
new
DataSpec
(
contentUri
);
long
sourceLengthBytes
=
dataSource
.
open
(
dataSpec
);
assertEquals
(
SAMPLE_MP4_BYTES
,
sourceLengthBytes
);
}
}
library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/TestDataProvider.java
0 → 100644
View file @
b77cc7c6
package
com
.
google
.
android
.
exoplayer2
.
upstream
;
import
android.content.ContentProvider
;
import
android.content.ContentValues
;
import
android.content.Context
;
import
android.content.res.AssetFileDescriptor
;
import
android.database.Cursor
;
import
android.net.Uri
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
static
junit
.
framework
.
Assert
.
assertNotNull
;
public
class
TestDataProvider
extends
ContentProvider
{
@Override
public
boolean
onCreate
()
{
return
true
;
}
@Nullable
@Override
public
Cursor
query
(
@NonNull
final
Uri
uri
,
@Nullable
final
String
[]
projection
,
@Nullable
final
String
selection
,
@Nullable
final
String
[]
selectionArgs
,
@Nullable
final
String
sortOrder
)
{
throw
new
UnsupportedOperationException
(
"Not implemented"
);
}
@Nullable
@Override
public
AssetFileDescriptor
openAssetFile
(
@NonNull
final
Uri
uri
,
@NonNull
final
String
mode
)
throws
FileNotFoundException
{
try
{
Context
context
=
getContext
();
assertNotNull
(
context
);
return
context
.
getAssets
().
openFd
(
uri
.
getPath
().
replaceFirst
(
"/"
,
""
));
}
catch
(
IOException
e
)
{
FileNotFoundException
exception
=
new
FileNotFoundException
(
e
.
getMessage
());
exception
.
initCause
(
e
);
throw
exception
;
}
}
@Nullable
@Override
public
String
getType
(
@NonNull
final
Uri
uri
)
{
throw
new
UnsupportedOperationException
(
"Not implemented"
);
}
@Nullable
@Override
public
Uri
insert
(
@NonNull
final
Uri
uri
,
@Nullable
final
ContentValues
values
)
{
throw
new
UnsupportedOperationException
(
"Not implemented"
);
}
@Override
public
int
delete
(
@NonNull
final
Uri
uri
,
@Nullable
final
String
selection
,
@Nullable
final
String
[]
selectionArgs
)
{
throw
new
UnsupportedOperationException
(
"Not implemented"
);
}
@Override
public
int
update
(
@NonNull
final
Uri
uri
,
@Nullable
final
ContentValues
values
,
@Nullable
final
String
selection
,
@Nullable
final
String
[]
selectionArgs
)
{
throw
new
UnsupportedOperationException
(
"Not implemented"
);
}
}
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