Fixed core integration tests

This commit is contained in:
ByteHamster 2019-08-11 15:00:37 +02:00
parent ce64c412ac
commit aca6e3e9e4
2 changed files with 31 additions and 4 deletions

View File

@ -6,6 +6,7 @@ android {
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled false
versionCode 1
versionName "1.0"
testApplicationId "de.danoeh.antennapod.core.tests"
@ -22,6 +23,14 @@ android {
minifyEnabled false
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
debug {
// debug build has method count over 64k single-dex threshold.
// For building debug build to use on Android < 21 (pre-Android 5) devices,
// you need to manually change class
// de.danoeh.antennapod.PodcastApp to extend MultiDexApplication .
// See Issue #2813
multiDexEnabled true
}
}
packagingOptions {

View File

@ -1,13 +1,15 @@
package de.danoeh.antennapod.core.util;
import android.test.AndroidTestCase;
import android.support.test.filters.SmallTest;
import org.junit.Test;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
import static org.junit.Assert.assertEquals;
/**
* Unit test for {@link DateUtils}.
*
@ -16,8 +18,9 @@ import java.util.TimeZone;
* {@link java.text.SimpleDateFormat} used by {@link DateUtils}.
*
*/
public class DateUtilsTest extends AndroidTestCase {
@SmallTest
public class DateUtilsTest {
@Test
public void testParseDateWithMicroseconds() throws Exception {
GregorianCalendar exp = new GregorianCalendar(2015, 2, 28, 13, 31, 4);
exp.setTimeZone(TimeZone.getTimeZone("UTC"));
@ -26,6 +29,7 @@ public class DateUtilsTest extends AndroidTestCase {
assertEquals(expected, actual);
}
@Test
public void testParseDateWithCentiseconds() throws Exception {
GregorianCalendar exp = new GregorianCalendar(2015, 2, 28, 13, 31, 4);
exp.setTimeZone(TimeZone.getTimeZone("UTC"));
@ -34,6 +38,7 @@ public class DateUtilsTest extends AndroidTestCase {
assertEquals(expected, actual);
}
@Test
public void testParseDateWithDeciseconds() throws Exception {
GregorianCalendar exp = new GregorianCalendar(2015, 2, 28, 13, 31, 4);
exp.setTimeZone(TimeZone.getTimeZone("UTC"));
@ -43,6 +48,7 @@ public class DateUtilsTest extends AndroidTestCase {
assertEquals(900, actual.getTime()%1000);
}
@Test
public void testParseDateWithMicrosecondsAndTimezone() throws Exception {
GregorianCalendar exp = new GregorianCalendar(2015, 2, 28, 6, 31, 4);
exp.setTimeZone(TimeZone.getTimeZone("UTC"));
@ -51,6 +57,7 @@ public class DateUtilsTest extends AndroidTestCase {
assertEquals(expected, actual);
}
@Test
public void testParseDateWithCentisecondsAndTimezone() throws Exception {
GregorianCalendar exp = new GregorianCalendar(2015, 2, 28, 6, 31, 4);
exp.setTimeZone(TimeZone.getTimeZone("UTC"));
@ -59,6 +66,7 @@ public class DateUtilsTest extends AndroidTestCase {
assertEquals(expected, actual);
}
@Test
public void testParseDateWithDecisecondsAndTimezone() throws Exception {
GregorianCalendar exp = new GregorianCalendar(2015, 2, 28, 6, 31, 4);
exp.setTimeZone(TimeZone.getTimeZone("UTC"));
@ -68,6 +76,7 @@ public class DateUtilsTest extends AndroidTestCase {
assertEquals(900, actual.getTime()%1000);
}
@Test
public void testParseDateWithTimezoneName() throws Exception {
GregorianCalendar exp = new GregorianCalendar(2015, 2, 28, 6, 31, 4);
exp.setTimeZone(TimeZone.getTimeZone("UTC"));
@ -76,6 +85,7 @@ public class DateUtilsTest extends AndroidTestCase {
assertEquals(expected, actual);
}
@Test
public void testParseDateWithTimezoneName2() throws Exception {
GregorianCalendar exp = new GregorianCalendar(2015, 2, 28, 6, 31, 0);
exp.setTimeZone(TimeZone.getTimeZone("UTC"));
@ -84,6 +94,7 @@ public class DateUtilsTest extends AndroidTestCase {
assertEquals(expected, actual);
}
@Test
public void testParseDateWithTimeZoneOffset() throws Exception {
GregorianCalendar exp = new GregorianCalendar(2015, 2, 28, 12, 16, 12);
exp.setTimeZone(TimeZone.getTimeZone("UTC"));
@ -92,6 +103,7 @@ public class DateUtilsTest extends AndroidTestCase {
assertEquals(expected, actual);
}
@Test
public void testAsctime() throws Exception {
GregorianCalendar exp = new GregorianCalendar(2011, 4, 25, 12, 33, 0);
exp.setTimeZone(TimeZone.getTimeZone("UTC"));
@ -100,6 +112,7 @@ public class DateUtilsTest extends AndroidTestCase {
assertEquals(expected, actual);
}
@Test
public void testMultipleConsecutiveSpaces() throws Exception {
GregorianCalendar exp = new GregorianCalendar(2010, 2, 23, 6, 6, 26);
exp.setTimeZone(TimeZone.getTimeZone("UTC"));
@ -114,6 +127,7 @@ public class DateUtilsTest extends AndroidTestCase {
* Reason: Standard JDK cannot parse timezone <code>-08:00</code> (ISO 8601 format). It only accepts
* <code>-0800</code> (RFC 822 format)
*/
@Test
public void testParseDateWithNoTimezonePadding() throws Exception {
GregorianCalendar exp = new GregorianCalendar(2017, 1, 22, 22, 28, 0);
exp.setTimeZone(TimeZone.getTimeZone("UTC"));
@ -128,6 +142,7 @@ public class DateUtilsTest extends AndroidTestCase {
*
* @see #testParseDateWithNoTimezonePadding()
*/
@Test
public void testParseDateWithForCest() throws Exception {
GregorianCalendar exp1 = new GregorianCalendar(2017, 0, 28, 22, 0, 0);
exp1.setTimeZone(TimeZone.getTimeZone("UTC"));
@ -142,6 +157,7 @@ public class DateUtilsTest extends AndroidTestCase {
assertEquals(expected2, actual2);
}
@Test
public void testParseDateWithIncorrectWeekday() {
GregorianCalendar exp1 = new GregorianCalendar(2014, 9, 8, 9, 0, 0);
exp1.setTimeZone(TimeZone.getTimeZone("GMT"));
@ -150,6 +166,7 @@ public class DateUtilsTest extends AndroidTestCase {
assertEquals(expected, actual);
}
@Test
public void testParseDateWithBadAbbreviation() {
GregorianCalendar exp1 = new GregorianCalendar(2014, 8, 8, 0, 0, 0);
exp1.setTimeZone(TimeZone.getTimeZone("GMT"));
@ -158,6 +175,7 @@ public class DateUtilsTest extends AndroidTestCase {
assertEquals(expected, actual);
}
@Test
public void testParseDateWithTwoTimezones() {
final GregorianCalendar exp1 = new GregorianCalendar(2015, Calendar.MARCH, 1, 1, 0, 0);
exp1.setTimeZone(TimeZone.getTimeZone("GMT-4"));