aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLive Channels Team <no-reply@google.com>2018-01-16 13:03:26 -0800
committerNick Chalko <nchalko@google.com>2018-01-16 15:02:20 -0800
commitff75e39b569fb119c58a2b4f013d8a62cc725c75 (patch)
tree82c7b3e908473988f13c06e4fea09a66ab1c30ec /tests
parent4a5144ac8c51c4d89d1359e13e37fcd7f928ed9a (diff)
downloadTV-ff75e39b569fb119c58a2b4f013d8a62cc725c75.tar.gz
Project import generated by Copybara.
PiperOrigin-RevId: 182099521 Change-Id: I213983755c98da36ab2cff3f7cfa494e1a1f082c
Diffstat (limited to 'tests')
-rw-r--r--tests/common/Android.mk3
-rw-r--r--tests/common/src/com/android/tv/testing/ChannelNumberSubject.java6
-rw-r--r--tests/tunerunit/Android.mk1
-rw-r--r--tests/tunerunit/AndroidManifest.xml18
-rw-r--r--tests/unit/src/com/android/tv/data/ChannelTest.java1
-rw-r--r--tests/unit/src/com/android/tv/util/MultiLongSparseArrayTest.java107
-rw-r--r--tests/unit/src/com/android/tv/util/UtilsTest_GetDurationString.java449
-rw-r--r--tests/unit/src/com/android/tv/util/UtilsTest_GetMultiAudioString.java110
-rw-r--r--tests/unit/src/com/android/tv/util/UtilsTest_IsInGivenDay.java68
9 files changed, 11 insertions, 752 deletions
diff --git a/tests/common/Android.mk b/tests/common/Android.mk
index bb8d2fbb..4ead78bf 100644
--- a/tests/common/Android.mk
+++ b/tests/common/Android.mk
@@ -28,6 +28,3 @@ LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_AIDL_INCLUDES += $(LOCAL_PATH)/src
include $(BUILD_STATIC_JAVA_LIBRARY)
-
-
-
diff --git a/tests/common/src/com/android/tv/testing/ChannelNumberSubject.java b/tests/common/src/com/android/tv/testing/ChannelNumberSubject.java
index 23b86e89..ba4662ee 100644
--- a/tests/common/src/com/android/tv/testing/ChannelNumberSubject.java
+++ b/tests/common/src/com/android/tv/testing/ChannelNumberSubject.java
@@ -16,8 +16,6 @@
package com.android.tv.testing;
-import static junit.framework.Assert.fail;
-
import android.support.annotation.Nullable;
import com.android.tv.data.ChannelNumber;
import com.google.common.truth.ComparableSubject;
@@ -25,7 +23,6 @@ import com.google.common.truth.FailureMetadata;
import com.google.common.truth.Subject;
import com.google.common.truth.Truth;
-
/** Propositions for {@link ChannelNumber} subjects. */
public final class ChannelNumberSubject
extends ComparableSubject<ChannelNumberSubject, ChannelNumber> {
@@ -60,7 +57,8 @@ public final class ChannelNumberSubject
}
public void isEmpty() {
- if (!getSubject().majorNumber.equals("") | !getSubject().minorNumber.equals("")
+ if (!getSubject().majorNumber.isEmpty()
+ || !getSubject().minorNumber.isEmpty()
|| getSubject().hasDelimiter) {
fail("isEmpty");
}
diff --git a/tests/tunerunit/Android.mk b/tests/tunerunit/Android.mk
index eeb1c080..5c861641 100644
--- a/tests/tunerunit/Android.mk
+++ b/tests/tunerunit/Android.mk
@@ -17,7 +17,6 @@ LOCAL_JAVA_LIBRARIES := \
android.test.base.stubs \
android.test.mock.stubs \
-
LOCAL_INSTRUMENTATION_FOR := LiveTv
LOCAL_SDK_VERSION := current
diff --git a/tests/tunerunit/AndroidManifest.xml b/tests/tunerunit/AndroidManifest.xml
index d8137f93..0340121f 100644
--- a/tests/tunerunit/AndroidManifest.xml
+++ b/tests/tunerunit/AndroidManifest.xml
@@ -18,15 +18,15 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.tv.tests" >
- <uses-sdk android:targetSdkVersion="23" android:minSdkVersion="23" />
+ <uses-sdk android:targetSdkVersion="23" android:minSdkVersion="23" />
- <instrumentation
- android:name="android.support.test.runner.AndroidJUnitRunner"
- android:label="Live Channel Unit Tests"
- android:targetPackage="com.android.tv.tuner" />
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:label="Live Channel Unit Tests"
+ android:targetPackage="com.android.tv.tuner" />
- <application android:label="TunerTest" >
- <uses-library android:name="android.test.runner" />
- </application>
+ <application android:label="TunerTest" >
+ <uses-library android:name="android.test.runner" />
+ </application>
-</manifest>
+</manifest> \ No newline at end of file
diff --git a/tests/unit/src/com/android/tv/data/ChannelTest.java b/tests/unit/src/com/android/tv/data/ChannelTest.java
index 34cb0b53..1f30a819 100644
--- a/tests/unit/src/com/android/tv/data/ChannelTest.java
+++ b/tests/unit/src/com/android/tv/data/ChannelTest.java
@@ -252,7 +252,6 @@ public class ChannelTest {
@Test
public void testComparator() {
-
TvInputManagerHelper manager = Mockito.mock(TvInputManagerHelper.class);
Mockito.when(manager.isPartnerInput(Matchers.anyString()))
.thenAnswer(
diff --git a/tests/unit/src/com/android/tv/util/MultiLongSparseArrayTest.java b/tests/unit/src/com/android/tv/util/MultiLongSparseArrayTest.java
deleted file mode 100644
index f7c0ac2a..00000000
--- a/tests/unit/src/com/android/tv/util/MultiLongSparseArrayTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.tv.util;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-
-import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
-import android.test.MoreAsserts;
-import java.util.Collections;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/** Tests for {@link MultiLongSparseArray}. */
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-public class MultiLongSparseArrayTest {
- @Test
- public void testEmpty() {
- MultiLongSparseArray<String> sparseArray = new MultiLongSparseArray<>();
- assertSame(Collections.EMPTY_SET, sparseArray.get(0));
- }
-
- @Test
- public void testOneElement() {
- MultiLongSparseArray<String> sparseArray = new MultiLongSparseArray<>();
- sparseArray.put(0, "foo");
- MoreAsserts.assertContentsInAnyOrder(sparseArray.get(0), "foo");
- }
-
- @Test
- public void testTwoElements() {
- MultiLongSparseArray<String> sparseArray = new MultiLongSparseArray<>();
- sparseArray.put(0, "foo");
- sparseArray.put(0, "bar");
- MoreAsserts.assertContentsInAnyOrder(sparseArray.get(0), "foo", "bar");
- }
-
- @Test
- public void testClearEmptyCache() {
- MultiLongSparseArray<String> sparseArray = new MultiLongSparseArray<>();
- sparseArray.clearEmptyCache();
- assertEquals(0, sparseArray.getEmptyCacheSize());
- sparseArray.put(0, "foo");
- sparseArray.remove(0, "foo");
- assertEquals(1, sparseArray.getEmptyCacheSize());
- sparseArray.clearEmptyCache();
- assertEquals(0, sparseArray.getEmptyCacheSize());
- }
-
- @Test
- public void testMaxEmptyCacheSize() {
- MultiLongSparseArray<String> sparseArray = new MultiLongSparseArray<>();
- sparseArray.clearEmptyCache();
- assertEquals(0, sparseArray.getEmptyCacheSize());
- for (int i = 0; i <= MultiLongSparseArray.DEFAULT_MAX_EMPTIES_KEPT + 2; i++) {
- sparseArray.put(i, "foo");
- }
- for (int i = 0; i <= MultiLongSparseArray.DEFAULT_MAX_EMPTIES_KEPT + 2; i++) {
- sparseArray.remove(i, "foo");
- }
- assertEquals(
- MultiLongSparseArray.DEFAULT_MAX_EMPTIES_KEPT, sparseArray.getEmptyCacheSize());
- sparseArray.clearEmptyCache();
- assertEquals(0, sparseArray.getEmptyCacheSize());
- }
-
- @Test
- public void testReuseEmptySets() {
- MultiLongSparseArray<String> sparseArray = new MultiLongSparseArray<>();
- sparseArray.clearEmptyCache();
- assertEquals(0, sparseArray.getEmptyCacheSize());
- // create a bunch of sets
- for (int i = 0; i <= MultiLongSparseArray.DEFAULT_MAX_EMPTIES_KEPT + 2; i++) {
- sparseArray.put(i, "foo");
- }
- // remove them so they are all put in the cache.
- for (int i = 0; i <= MultiLongSparseArray.DEFAULT_MAX_EMPTIES_KEPT + 2; i++) {
- sparseArray.remove(i, "foo");
- }
- assertEquals(
- MultiLongSparseArray.DEFAULT_MAX_EMPTIES_KEPT, sparseArray.getEmptyCacheSize());
-
- // now create elements, that use the cached empty sets.
- for (int i = 0; i < MultiLongSparseArray.DEFAULT_MAX_EMPTIES_KEPT; i++) {
- sparseArray.put(10 + i, "bar");
- assertEquals(
- MultiLongSparseArray.DEFAULT_MAX_EMPTIES_KEPT - i - 1,
- sparseArray.getEmptyCacheSize());
- }
- }
-}
diff --git a/tests/unit/src/com/android/tv/util/UtilsTest_GetDurationString.java b/tests/unit/src/com/android/tv/util/UtilsTest_GetDurationString.java
deleted file mode 100644
index 0be1026f..00000000
--- a/tests/unit/src/com/android/tv/util/UtilsTest_GetDurationString.java
+++ /dev/null
@@ -1,449 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.tv.util;
-
-import static android.support.test.InstrumentationRegistry.getContext;
-import static org.junit.Assert.assertEquals;
-
-import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
-import android.text.format.DateUtils;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.Locale;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests for {@link com.android.tv.util.Utils#getDurationString}.
- *
- * <p>This test uses deprecated flags {@link DateUtils#FORMAT_12HOUR} and {@link
- * DateUtils#FORMAT_24HOUR} to run this test independent to system's 12/24h format. Note that
- * changing system setting requires permission android.permission.WRITE_SETTINGS and it should be
- * defined in TV app, not this test.
- */
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-public class UtilsTest_GetDurationString {
- // TODO: Mock Context so we can specify current time and locale for test.
- private Locale mLocale;
- private static final long DATE_THIS_YEAR_2_1_MS = getFebOfThisYearInMillis(1, 0, 0);
-
- // All possible list for a parameter to test parameter independent result.
- private static final boolean[] PARAM_USE_SHORT_FORMAT = {false, true};
-
- @Before
- public void setUp() {
- // Set locale to US
- mLocale = Locale.getDefault();
- Locale.setDefault(Locale.US);
- }
-
- @After
- public void tearDown() {
- // Revive system locale.
- Locale.setDefault(mLocale);
- }
-
- /** Return time in millis assuming that whose year is this year and month is Jan. */
- private static long getJanOfThisYearInMillis(int date, int hour, int minutes) {
- return new GregorianCalendar(getThisYear(), Calendar.JANUARY, date, hour, minutes)
- .getTimeInMillis();
- }
-
- private static long getJanOfThisYearInMillis(int date, int hour) {
- return getJanOfThisYearInMillis(date, hour, 0);
- }
-
- /** Return time in millis assuming that whose year is this year and month is Feb. */
- private static long getFebOfThisYearInMillis(int date, int hour, int minutes) {
- return new GregorianCalendar(getThisYear(), Calendar.FEBRUARY, date, hour, minutes)
- .getTimeInMillis();
- }
-
- private static long getFebOfThisYearInMillis(int date, int hour) {
- return getFebOfThisYearInMillis(date, hour, 0);
- }
-
- private static int getThisYear() {
- return new GregorianCalendar().get(GregorianCalendar.YEAR);
- }
-
- @Test
- public void testSameDateAndTime() {
- assertEquals(
- "3:00 AM",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(1, 3),
- getFebOfThisYearInMillis(1, 3),
- false,
- DateUtils.FORMAT_12HOUR));
- assertEquals(
- "03:00",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(1, 3),
- getFebOfThisYearInMillis(1, 3),
- false,
- DateUtils.FORMAT_24HOUR));
- }
-
- @Test
- public void testDurationWithinToday() {
- assertEquals(
- "12:00 – 3:00 AM",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(1, 3),
- false,
- DateUtils.FORMAT_12HOUR));
- assertEquals(
- "00:00 – 03:00",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(1, 3),
- false,
- DateUtils.FORMAT_24HOUR));
- }
-
- @Test
- public void testDurationFromYesterdayToToday() {
- assertEquals(
- "Jan 31, 3:00 AM – Feb 1, 4:00 AM",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getJanOfThisYearInMillis(31, 3),
- getFebOfThisYearInMillis(1, 4),
- false,
- DateUtils.FORMAT_12HOUR));
- assertEquals(
- "Jan 31, 03:00 – Feb 1, 04:00",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getJanOfThisYearInMillis(31, 3),
- getFebOfThisYearInMillis(1, 4),
- false,
- DateUtils.FORMAT_24HOUR));
- assertEquals(
- "1/31, 11:30 PM – 12:30 AM",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getJanOfThisYearInMillis(31, 23, 30),
- getFebOfThisYearInMillis(1, 0, 30),
- true,
- DateUtils.FORMAT_12HOUR));
- assertEquals(
- "1/31, 23:30 – 00:30",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getJanOfThisYearInMillis(31, 23, 30),
- getFebOfThisYearInMillis(1, 0, 30),
- true,
- DateUtils.FORMAT_24HOUR));
- }
-
- @Test
- public void testDurationFromTodayToTomorrow() {
- assertEquals(
- "Feb 1, 3:00 AM – Feb 2, 4:00 AM",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(1, 3),
- getFebOfThisYearInMillis(2, 4),
- false,
- DateUtils.FORMAT_12HOUR));
- assertEquals(
- "Feb 1, 03:00 – Feb 2, 04:00",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(1, 3),
- getFebOfThisYearInMillis(2, 4),
- false,
- DateUtils.FORMAT_24HOUR));
- assertEquals(
- "2/1, 3:00 AM – 2/2, 4:00 AM",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(1, 3),
- getFebOfThisYearInMillis(2, 4),
- true,
- DateUtils.FORMAT_12HOUR));
- assertEquals(
- "2/1, 03:00 – 2/2, 04:00",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(1, 3),
- getFebOfThisYearInMillis(2, 4),
- true,
- DateUtils.FORMAT_24HOUR));
-
- assertEquals(
- "Feb 1, 11:30 PM – Feb 2, 12:30 AM",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(1, 23, 30),
- getFebOfThisYearInMillis(2, 0, 30),
- false,
- DateUtils.FORMAT_12HOUR));
- assertEquals(
- "Feb 1, 23:30 – Feb 2, 00:30",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(1, 23, 30),
- getFebOfThisYearInMillis(2, 0, 30),
- false,
- DateUtils.FORMAT_24HOUR));
- assertEquals(
- "11:30 PM – 12:30 AM",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(1, 23, 30),
- getFebOfThisYearInMillis(2, 0, 30),
- true,
- DateUtils.FORMAT_12HOUR));
- assertEquals(
- "23:30 – 00:30",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(1, 23, 30),
- getFebOfThisYearInMillis(2, 0, 30),
- true,
- DateUtils.FORMAT_24HOUR));
- }
-
- @Test
- public void testDurationWithinTomorrow() {
- assertEquals(
- "Feb 2, 2:00 – 4:00 AM",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(2, 2),
- getFebOfThisYearInMillis(2, 4),
- false,
- DateUtils.FORMAT_12HOUR));
- assertEquals(
- "Feb 2, 02:00 – 04:00",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(2, 2),
- getFebOfThisYearInMillis(2, 4),
- false,
- DateUtils.FORMAT_24HOUR));
- assertEquals(
- "2/2, 2:00 – 4:00 AM",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(2, 2),
- getFebOfThisYearInMillis(2, 4),
- true,
- DateUtils.FORMAT_12HOUR));
- assertEquals(
- "2/2, 02:00 – 04:00",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(2, 2),
- getFebOfThisYearInMillis(2, 4),
- true,
- DateUtils.FORMAT_24HOUR));
- }
-
- @Test
- public void testStartOfDay() {
- assertEquals(
- "12:00 – 1:00 AM",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(1, 1),
- false,
- DateUtils.FORMAT_12HOUR));
- assertEquals(
- "00:00 – 01:00",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(1, 1),
- false,
- DateUtils.FORMAT_24HOUR));
-
- assertEquals(
- "Feb 2, 12:00 – 1:00 AM",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(2, 0),
- getFebOfThisYearInMillis(2, 1),
- false,
- DateUtils.FORMAT_12HOUR));
- assertEquals(
- "Feb 2, 00:00 – 01:00",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(2, 0),
- getFebOfThisYearInMillis(2, 1),
- false,
- DateUtils.FORMAT_24HOUR));
- assertEquals(
- "2/2, 12:00 – 1:00 AM",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(2, 0),
- getFebOfThisYearInMillis(2, 1),
- true,
- DateUtils.FORMAT_12HOUR));
- assertEquals(
- "2/2, 00:00 – 01:00",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(2, 0),
- getFebOfThisYearInMillis(2, 1),
- true,
- DateUtils.FORMAT_24HOUR));
- }
-
- @Test
- public void testEndOfDay() {
- for (boolean useShortFormat : PARAM_USE_SHORT_FORMAT) {
- assertEquals(
- "11:00 PM – 12:00 AM",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(1, 23),
- getFebOfThisYearInMillis(2, 0),
- useShortFormat,
- DateUtils.FORMAT_12HOUR));
- assertEquals(
- "23:00 – 00:00",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(1, 23),
- getFebOfThisYearInMillis(2, 0),
- useShortFormat,
- DateUtils.FORMAT_24HOUR));
- }
-
- assertEquals(
- "Feb 2, 11:00 PM – 12:00 AM",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(2, 23),
- getFebOfThisYearInMillis(3, 0),
- false,
- DateUtils.FORMAT_12HOUR));
- assertEquals(
- "Feb 2, 23:00 – 00:00",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(2, 23),
- getFebOfThisYearInMillis(3, 0),
- false,
- DateUtils.FORMAT_24HOUR));
- assertEquals(
- "2/2, 11:00 PM – 12:00 AM",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(2, 23),
- getFebOfThisYearInMillis(3, 0),
- true,
- DateUtils.FORMAT_12HOUR));
- assertEquals(
- "2/2, 23:00 – 00:00",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(2, 23),
- getFebOfThisYearInMillis(3, 0),
- true,
- DateUtils.FORMAT_24HOUR));
- assertEquals(
- "2/2, 12:00 AM – 2/3, 12:00 AM",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(2, 0),
- getFebOfThisYearInMillis(3, 0),
- true,
- DateUtils.FORMAT_12HOUR));
- assertEquals(
- "2/2, 00:00 – 2/3, 00:00",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- getFebOfThisYearInMillis(2, 0),
- getFebOfThisYearInMillis(3, 0),
- true,
- DateUtils.FORMAT_24HOUR));
- }
-
- @Test
- public void testMidnight() {
- for (boolean useShortFormat : PARAM_USE_SHORT_FORMAT) {
- assertEquals(
- "12:00 AM",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- DATE_THIS_YEAR_2_1_MS,
- DATE_THIS_YEAR_2_1_MS,
- useShortFormat,
- DateUtils.FORMAT_12HOUR));
- assertEquals(
- "00:00",
- Utils.getDurationString(
- getContext(),
- DATE_THIS_YEAR_2_1_MS,
- DATE_THIS_YEAR_2_1_MS,
- DATE_THIS_YEAR_2_1_MS,
- useShortFormat,
- DateUtils.FORMAT_24HOUR));
- }
- }
-}
diff --git a/tests/unit/src/com/android/tv/util/UtilsTest_GetMultiAudioString.java b/tests/unit/src/com/android/tv/util/UtilsTest_GetMultiAudioString.java
deleted file mode 100644
index affe7d2f..00000000
--- a/tests/unit/src/com/android/tv/util/UtilsTest_GetMultiAudioString.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tv.util;
-
-import static android.support.test.InstrumentationRegistry.getTargetContext;
-import static org.junit.Assert.assertEquals;
-
-import android.content.Context;
-import android.media.tv.TvTrackInfo;
-import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/** Tests for {@link com.android.tv.util.Utils#getMultiAudioString}. */
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-public class UtilsTest_GetMultiAudioString {
- private static final String TRACK_ID = "test_track_id";
- private static final int AUDIO_SAMPLE_RATE = 48000;
-
- @Test
- public void testAudioTrackLanguage() {
- Context context = getTargetContext();
- assertEquals(
- "Korean", Utils.getMultiAudioString(context, createAudioTrackInfo("kor"), false));
- assertEquals(
- "English", Utils.getMultiAudioString(context, createAudioTrackInfo("eng"), false));
- assertEquals(
- "Unknown language",
- Utils.getMultiAudioString(context, createAudioTrackInfo(null), false));
- assertEquals(
- "Unknown language",
- Utils.getMultiAudioString(context, createAudioTrackInfo(""), false));
- assertEquals("abc", Utils.getMultiAudioString(context, createAudioTrackInfo("abc"), false));
- }
-
- @Test
- public void testAudioTrackCount() {
- Context context = getTargetContext();
- assertEquals(
- "English",
- Utils.getMultiAudioString(context, createAudioTrackInfo("eng", -1), false));
- assertEquals(
- "English",
- Utils.getMultiAudioString(context, createAudioTrackInfo("eng", 0), false));
- assertEquals(
- "English (mono)",
- Utils.getMultiAudioString(context, createAudioTrackInfo("eng", 1), false));
- assertEquals(
- "English (stereo)",
- Utils.getMultiAudioString(context, createAudioTrackInfo("eng", 2), false));
- assertEquals(
- "English (3 channels)",
- Utils.getMultiAudioString(context, createAudioTrackInfo("eng", 3), false));
- assertEquals(
- "English (4 channels)",
- Utils.getMultiAudioString(context, createAudioTrackInfo("eng", 4), false));
- assertEquals(
- "English (5 channels)",
- Utils.getMultiAudioString(context, createAudioTrackInfo("eng", 5), false));
- assertEquals(
- "English (5.1 surround)",
- Utils.getMultiAudioString(context, createAudioTrackInfo("eng", 6), false));
- assertEquals(
- "English (7 channels)",
- Utils.getMultiAudioString(context, createAudioTrackInfo("eng", 7), false));
- assertEquals(
- "English (7.1 surround)",
- Utils.getMultiAudioString(context, createAudioTrackInfo("eng", 8), false));
- }
-
- @Test
- public void testShowSampleRate() {
- assertEquals(
- "Korean (48kHz)",
- Utils.getMultiAudioString(
- getTargetContext(), createAudioTrackInfo("kor", 0), true));
- assertEquals(
- "Korean (7.1 surround, 48kHz)",
- Utils.getMultiAudioString(
- getTargetContext(), createAudioTrackInfo("kor", 8), true));
- }
-
- private static TvTrackInfo createAudioTrackInfo(String language) {
- return createAudioTrackInfo(language, 0);
- }
-
- private static TvTrackInfo createAudioTrackInfo(String language, int channelCount) {
- return new TvTrackInfo.Builder(TvTrackInfo.TYPE_AUDIO, TRACK_ID)
- .setLanguage(language)
- .setAudioChannelCount(channelCount)
- .setAudioSampleRate(AUDIO_SAMPLE_RATE)
- .build();
- }
-}
diff --git a/tests/unit/src/com/android/tv/util/UtilsTest_IsInGivenDay.java b/tests/unit/src/com/android/tv/util/UtilsTest_IsInGivenDay.java
deleted file mode 100644
index 15f15d1c..00000000
--- a/tests/unit/src/com/android/tv/util/UtilsTest_IsInGivenDay.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tv.util;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/** Tests for {@link com.android.tv.util.Utils#isInGivenDay}. */
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-public class UtilsTest_IsInGivenDay {
- @Test
- public void testIsInGivenDay() {
- assertTrue(
- Utils.isInGivenDay(
- new GregorianCalendar(2015, Calendar.JANUARY, 1).getTimeInMillis(),
- new GregorianCalendar(2015, Calendar.JANUARY, 1, 0, 30).getTimeInMillis()));
- }
-
- @Test
- public void testIsNotInGivenDay() {
- assertFalse(
- Utils.isInGivenDay(
- new GregorianCalendar(2015, Calendar.JANUARY, 1).getTimeInMillis(),
- new GregorianCalendar(2015, Calendar.JANUARY, 2).getTimeInMillis()));
- }
-
- @Test
- public void testIfTimeZoneApplied() {
- TimeZone timeZone = TimeZone.getDefault();
-
- TimeZone.setDefault(TimeZone.getTimeZone("Asia/Seoul"));
-
- // 2015.01.01 00:00 in KST = 2014.12.31 15:00 in UTC
- long date2015StartMs = new GregorianCalendar(2015, Calendar.JANUARY, 1).getTimeInMillis();
-
- // 2015.01.01 10:00 in KST = 2015.01.01 01:00 in UTC
- long date2015Start10AMMs =
- new GregorianCalendar(2015, Calendar.JANUARY, 1, 10, 0).getTimeInMillis();
-
- // Those two times aren't in the same day in UTC, but they are in KST.
- assertTrue(Utils.isInGivenDay(date2015StartMs, date2015Start10AMMs));
-
- TimeZone.setDefault(timeZone);
- }
-}