Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* Add `HlsInterstitialsAdsLoader.Listener.onAdStarted` to report the start
of an ad period
([#2859](https://github.com/androidx/media/issues/2859)).
* Accept space as a date/time separator in ISO 8601 date-time strings.
* DASH extension:
* Smooth Streaming extension:
* RTSP extension:
Expand Down
1 change: 1 addition & 0 deletions libraries/common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ dependencies {
testImplementation 'androidx.test:core:' + androidxTestCoreVersion
testImplementation 'androidx.test.ext:junit:' + androidxTestJUnitVersion
testImplementation 'junit:junit:' + junitVersion
testImplementation 'com.google.testparameterinjector:test-parameter-injector:' + testParameterInjectorVersion
testImplementation 'com.google.truth:truth:' + truthVersion
testImplementation 'org.robolectric:robolectric:' + robolectricVersion
testImplementation project(modulePrefix + 'lib-exoplayer')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public final class Util {
private static final String TAG = "Util";
private static final Pattern XS_DATE_TIME_PATTERN =
Pattern.compile(
"(\\d\\d\\d\\d)\\-(\\d\\d)\\-(\\d\\d)[Tt]"
"(\\d\\d\\d\\d)\\-(\\d\\d)\\-(\\d\\d)[Tt ]"
+ "(\\d\\d):(\\d\\d):(\\d\\d)([\\.,](\\d+))?"
+ "([Zz]|((\\+|\\-)(\\d?\\d):?(\\d\\d)))?");
private static final Pattern XS_DURATION_PATTERN =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
import android.util.SparseLongArray;
import androidx.media3.common.C;
import androidx.media3.test.utils.TestUtil;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.common.io.ByteStreams;
import com.google.common.primitives.Bytes;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import com.google.testing.junit.testparameterinjector.TestParameter;
import java.io.ByteArrayInputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
Expand All @@ -72,11 +72,12 @@
import java.util.zip.GZIPInputStream;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestParameterInjector;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowLooper;

/** Unit tests for {@link Util}. */
@RunWith(AndroidJUnit4.class)
@RunWith(RobolectricTestParameterInjector.class)
public class UtilTest {

private static final int TIMEOUT_MS = 10000;
Expand Down Expand Up @@ -975,14 +976,20 @@ public void parseXsDuration_returnsParsedDurationInMillis() {
}

@Test
public void parseXsDateTime_returnsParsedDateTimeInMillis() throws Exception {
assertThat(parseXsDateTime("2014-06-19T23:07:42")).isEqualTo(1403219262000L);
assertThat(parseXsDateTime("2014-08-06T11:00:00Z")).isEqualTo(1407322800000L);
assertThat(parseXsDateTime("2014-08-06T11:00:00,000Z")).isEqualTo(1407322800000L);
assertThat(parseXsDateTime("2014-09-19T13:18:55-08:00")).isEqualTo(1411161535000L);
assertThat(parseXsDateTime("2014-09-19T13:18:55-0800")).isEqualTo(1411161535000L);
assertThat(parseXsDateTime("2014-09-19T13:18:55.000-0800")).isEqualTo(1411161535000L);
assertThat(parseXsDateTime("2014-09-19T13:18:55.000-800")).isEqualTo(1411161535000L);
public void parseXsDateTime_returnsParsedDateTimeInMillis(
@TestParameter({"T", "t", " "}) String separator) throws Exception {
assertThat(parseXsDateTime("2014-06-19" + separator + "23:07:42")).isEqualTo(1403219262000L);
assertThat(parseXsDateTime("2014-08-06" + separator + "11:00:00Z")).isEqualTo(1407322800000L);
assertThat(parseXsDateTime("2014-08-06" + separator + "11:00:00,000Z"))
.isEqualTo(1407322800000L);
assertThat(parseXsDateTime("2014-09-19" + separator + "13:18:55-08:00"))
.isEqualTo(1411161535000L);
assertThat(parseXsDateTime("2014-09-19" + separator + "13:18:55-0800"))
.isEqualTo(1411161535000L);
assertThat(parseXsDateTime("2014-09-19" + separator + "13:18:55.000-0800"))
.isEqualTo(1411161535000L);
assertThat(parseXsDateTime("2014-09-19" + separator + "13:18:55.000-800"))
.isEqualTo(1411161535000L);
}

@Test
Expand Down