mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Make setters of TestResource.Builder accept a value.
PiperOrigin-RevId: 347388172
This commit is contained in:
parent
401634a9fb
commit
e18892cd03
3 changed files with 16 additions and 17 deletions
|
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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.getExpectedResolvedLength());
|
||||||
assertThat(data).isEqualTo(resource.getExpectedBytes());
|
assertThat(data).isEqualTo(resource.getExpectedBytes());
|
||||||
} finally {
|
} finally {
|
||||||
dataSource.close();
|
dataSource.close();
|
||||||
|
|
@ -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 resolvesToKnownLength;
|
private final boolean resolvesToUnknownLength;
|
||||||
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 resolvesToKnownLength,
|
boolean resolvesToUnknownLength,
|
||||||
boolean endOfInputExpected) {
|
boolean endOfInputExpected) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
this.expectedBytes = expectedBytes;
|
this.expectedBytes = expectedBytes;
|
||||||
this.resolvesToKnownLength = resolvesToKnownLength;
|
this.resolvesToUnknownLength = resolvesToUnknownLength;
|
||||||
this.endOfInputExpected = endOfInputExpected;
|
this.endOfInputExpected = endOfInputExpected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -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 getExpectedResolvedLength() {
|
||||||
return resolvesToKnownLength ? expectedBytes.length : C.LENGTH_UNSET;
|
return resolvesToUnknownLength ? C.LENGTH_UNSET : expectedBytes.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -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 resolvesToKnownLength;
|
private boolean resolvesToUnknownLength;
|
||||||
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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.resolvesToKnownLength = false;
|
this.resolvesToUnknownLength = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -235,7 +234,7 @@ public abstract class DataSourceContractTest {
|
||||||
name,
|
name,
|
||||||
checkNotNull(uri),
|
checkNotNull(uri),
|
||||||
checkNotNull(expectedBytes),
|
checkNotNull(expectedBytes),
|
||||||
resolvesToKnownLength,
|
resolvesToUnknownLength,
|
||||||
endOfInputExpected);
|
endOfInputExpected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue