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
e18892cd
authored
Dec 14, 2020
by
christosts
Committed by
Christos Tsilopoulos
Dec 17, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Make setters of TestResource.Builder accept a value.
PiperOrigin-RevId: 347388172
parent
401634a9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
17 deletions
library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/ContentDataSourceContractTest.java
library/core/src/test/java/com/google/android/exoplayer2/upstream/UdpDataSourceContractTest.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/DataSourceContractTest.java
library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/ContentDataSourceContractTest.java
View file @
e18892cd
...
@@ -48,7 +48,7 @@ public final class ContentDataSourceContractTest extends DataSourceContractTest
...
@@ -48,7 +48,7 @@ public final class ContentDataSourceContractTest extends DataSourceContractTest
.
setName
(
"simple (pipe=true)"
)
.
setName
(
"simple (pipe=true)"
)
.
setUri
(
TestContentProvider
.
buildUri
(
DATA_PATH
,
/* pipeMode= */
true
))
.
setUri
(
TestContentProvider
.
buildUri
(
DATA_PATH
,
/* pipeMode= */
true
))
.
setExpectedBytes
(
completeData
)
.
setExpectedBytes
(
completeData
)
.
resolvesToUnknownLength
(
)
.
setResolvesToUnknownLength
(
true
)
.
build
());
.
build
());
}
}
...
...
library/core/src/test/java/com/google/android/exoplayer2/upstream/UdpDataSourceContractTest.java
View file @
e18892cd
...
@@ -62,7 +62,7 @@ public class UdpDataSourceContractTest extends DataSourceContractTest {
...
@@ -62,7 +62,7 @@ public class UdpDataSourceContractTest extends DataSourceContractTest {
.
setName
(
"local-udp-unicast-socket"
)
.
setName
(
"local-udp-unicast-socket"
)
.
setUri
(
Uri
.
parse
(
"udp://localhost:"
+
findFreeUdpPort
()))
.
setUri
(
Uri
.
parse
(
"udp://localhost:"
+
findFreeUdpPort
()))
.
setExpectedBytes
(
data
)
.
setExpectedBytes
(
data
)
.
resolvesToUnknownLength
(
)
.
setResolvesToUnknownLength
(
true
)
.
setEndOfInputExpected
(
false
)
.
setEndOfInputExpected
(
false
)
.
build
());
.
build
());
}
}
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/DataSourceContractTest.java
View file @
e18892cd
...
@@ -91,7 +91,7 @@ public abstract class DataSourceContractTest {
...
@@ -91,7 +91,7 @@ public abstract class DataSourceContractTest {
?
Util
.
readToEnd
(
dataSource
)
?
Util
.
readToEnd
(
dataSource
)
:
Util
.
readExactly
(
dataSource
,
resource
.
getExpectedBytes
().
length
);
:
Util
.
readExactly
(
dataSource
,
resource
.
getExpectedBytes
().
length
);
assertThat
(
length
).
isEqualTo
(
resource
.
getExpectedLength
());
assertThat
(
length
).
isEqualTo
(
resource
.
getExpected
Resolved
Length
());
assertThat
(
data
).
isEqualTo
(
resource
.
getExpectedBytes
());
assertThat
(
data
).
isEqualTo
(
resource
.
getExpectedBytes
());
}
finally
{
}
finally
{
dataSource
.
close
();
dataSource
.
close
();
...
@@ -127,19 +127,19 @@ public abstract class DataSourceContractTest {
...
@@ -127,19 +127,19 @@ public abstract class DataSourceContractTest {
@Nullable
private
final
String
name
;
@Nullable
private
final
String
name
;
private
final
Uri
uri
;
private
final
Uri
uri
;
private
final
byte
[]
expectedBytes
;
private
final
byte
[]
expectedBytes
;
private
final
boolean
resolvesTo
K
nownLength
;
private
final
boolean
resolvesTo
Unk
nownLength
;
private
final
boolean
endOfInputExpected
;
private
final
boolean
endOfInputExpected
;
private
TestResource
(
private
TestResource
(
@Nullable
String
name
,
@Nullable
String
name
,
Uri
uri
,
Uri
uri
,
byte
[]
expectedBytes
,
byte
[]
expectedBytes
,
boolean
resolvesTo
K
nownLength
,
boolean
resolvesTo
Unk
nownLength
,
boolean
endOfInputExpected
)
{
boolean
endOfInputExpected
)
{
this
.
name
=
name
;
this
.
name
=
name
;
this
.
uri
=
uri
;
this
.
uri
=
uri
;
this
.
expectedBytes
=
expectedBytes
;
this
.
expectedBytes
=
expectedBytes
;
this
.
resolvesTo
KnownLength
=
resolvesToK
nownLength
;
this
.
resolvesTo
UnknownLength
=
resolvesToUnk
nownLength
;
this
.
endOfInputExpected
=
endOfInputExpected
;
this
.
endOfInputExpected
=
endOfInputExpected
;
}
}
...
@@ -160,13 +160,13 @@ public abstract class DataSourceContractTest {
...
@@ -160,13 +160,13 @@ public abstract class DataSourceContractTest {
}
}
/**
/**
* Returns the expected length of this resource.
* Returns the expected
resolved
length of this resource.
*
*
* <p>This is either {@link #getExpectedBytes() getExpectedBytes().length} or {@link
* <p>This is either {@link #getExpectedBytes() getExpectedBytes().length} or {@link
* C#LENGTH_UNSET}.
* C#LENGTH_UNSET}.
*/
*/
public
long
getExpectedLength
()
{
public
long
getExpected
Resolved
Length
()
{
return
resolvesTo
KnownLength
?
expectedBytes
.
length
:
C
.
LENGTH_UNSET
;
return
resolvesTo
UnknownLength
?
C
.
LENGTH_UNSET
:
expectedBytes
.
length
;
}
}
/**
/**
...
@@ -182,12 +182,11 @@ public abstract class DataSourceContractTest {
...
@@ -182,12 +182,11 @@ public abstract class DataSourceContractTest {
private
@MonotonicNonNull
String
name
;
private
@MonotonicNonNull
String
name
;
private
@MonotonicNonNull
Uri
uri
;
private
@MonotonicNonNull
Uri
uri
;
private
byte
@MonotonicNonNull
[]
expectedBytes
;
private
byte
@MonotonicNonNull
[]
expectedBytes
;
private
boolean
resolvesTo
K
nownLength
;
private
boolean
resolvesTo
Unk
nownLength
;
private
boolean
endOfInputExpected
;
private
boolean
endOfInputExpected
;
/** Construct a new instance. */
/** Construct a new instance. */
public
Builder
()
{
public
Builder
()
{
this
.
resolvesToKnownLength
=
true
;
this
.
endOfInputExpected
=
true
;
this
.
endOfInputExpected
=
true
;
}
}
...
@@ -212,12 +211,12 @@ public abstract class DataSourceContractTest {
...
@@ -212,12 +211,12 @@ public abstract class DataSourceContractTest {
}
}
/**
/**
*
Calling this method indicates it's expected that {@link DataSource#open(DataSpec)} will
*
Sets whether {@link DataSource#open(DataSpec)} is expected to return {@link C#LENGTH_UNSET}
*
return {@link C#LENGTH_UNSET} when passed the URI of this resource and a {@link DataSpec}
*
when passed the URI of this resource and a {@link DataSpec} with {@code length ==
*
with {@code length ==
C.LENGTH_UNSET}.
* C.LENGTH_UNSET}.
*/
*/
public
Builder
resolvesToUnknownLength
(
)
{
public
Builder
setResolvesToUnknownLength
(
boolean
value
)
{
this
.
resolvesTo
KnownLength
=
fals
e
;
this
.
resolvesTo
UnknownLength
=
valu
e
;
return
this
;
return
this
;
}
}
...
@@ -235,7 +234,7 @@ public abstract class DataSourceContractTest {
...
@@ -235,7 +234,7 @@ public abstract class DataSourceContractTest {
name
,
name
,
checkNotNull
(
uri
),
checkNotNull
(
uri
),
checkNotNull
(
expectedBytes
),
checkNotNull
(
expectedBytes
),
resolvesTo
K
nownLength
,
resolvesTo
Unk
nownLength
,
endOfInputExpected
);
endOfInputExpected
);
}
}
}
}
...
...
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