mirror of https://github.com/tasks/tasks
Local unit tests
parent
d1ad84f281
commit
6069c53a04
@ -1,56 +0,0 @@
|
|||||||
package org.tasks
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import androidx.test.InstrumentationRegistry
|
|
||||||
import at.bitfire.ical4android.Task.Companion.tasksFromReader
|
|
||||||
import com.todoroo.astrid.data.Task
|
|
||||||
import org.tasks.caldav.CaldavConverter
|
|
||||||
import org.tasks.preferences.Preferences
|
|
||||||
import java.io.IOException
|
|
||||||
import java.io.InputStream
|
|
||||||
import java.io.InputStreamReader
|
|
||||||
import java.io.StringReader
|
|
||||||
|
|
||||||
object TestUtilities {
|
|
||||||
fun newPreferences(context: Context?): Preferences {
|
|
||||||
return Preferences(context, "test_preferences")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun vtodo(path: String): Task {
|
|
||||||
val task = Task()
|
|
||||||
CaldavConverter.apply(task, fromResource(path))
|
|
||||||
return task
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun fromResource(path: String): at.bitfire.ical4android.Task {
|
|
||||||
val context = InstrumentationRegistry.getInstrumentation().context
|
|
||||||
var `is`: InputStream? = null
|
|
||||||
var reader: InputStreamReader? = null
|
|
||||||
return try {
|
|
||||||
`is` = context.assets.open(path)
|
|
||||||
reader = InputStreamReader(`is`, Charsets.UTF_8)
|
|
||||||
fromString(reader.readText())
|
|
||||||
} catch (e: IOException) {
|
|
||||||
throw IllegalArgumentException(e)
|
|
||||||
} finally {
|
|
||||||
if (reader != null) {
|
|
||||||
try {
|
|
||||||
reader.close()
|
|
||||||
} catch (ignored: IOException) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (`is` != null) {
|
|
||||||
try {
|
|
||||||
`is`.close()
|
|
||||||
} catch (ignored: IOException) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun fromString(task: String) = try {
|
|
||||||
tasksFromReader(StringReader(task))[0]
|
|
||||||
} catch (e: Exception) {
|
|
||||||
throw IllegalArgumentException(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
package org.tasks
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import at.bitfire.ical4android.Task.Companion.tasksFromReader
|
||||||
|
import com.todoroo.astrid.data.Task
|
||||||
|
import org.tasks.caldav.CaldavConverter
|
||||||
|
import org.tasks.preferences.Preferences
|
||||||
|
import java.io.StringReader
|
||||||
|
import java.nio.file.Files
|
||||||
|
import java.nio.file.Paths
|
||||||
|
|
||||||
|
object TestUtilities {
|
||||||
|
fun newPreferences(context: Context?): Preferences {
|
||||||
|
return Preferences(context, "test_preferences")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun vtodo(path: String): Task {
|
||||||
|
val task = Task()
|
||||||
|
CaldavConverter.apply(task, fromResource(path))
|
||||||
|
return task
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun fromResource(path: String): at.bitfire.ical4android.Task {
|
||||||
|
val url = javaClass.classLoader!!.getResource(path)
|
||||||
|
val paths = Paths.get(url!!.toURI())
|
||||||
|
return fromString(String(Files.readAllBytes(paths), Charsets.UTF_8))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun fromString(task: String) = tasksFromReader(StringReader(task))[0]
|
||||||
|
}
|
||||||
@ -1,18 +1,15 @@
|
|||||||
package com.todoroo.astrid.data
|
package com.todoroo.astrid.data
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Assert.*
|
import org.junit.Assert.*
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.tasks.Freeze
|
import org.tasks.Freeze
|
||||||
import org.tasks.Freeze.Companion.freezeAt
|
import org.tasks.Freeze.Companion.freezeAt
|
||||||
import org.tasks.date.DateTimeUtils
|
import org.tasks.date.DateTimeUtils
|
||||||
import org.tasks.time.DateTime
|
import org.tasks.time.DateTime
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
|
||||||
class TaskTest {
|
class TaskTest {
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
@ -1,16 +1,13 @@
|
|||||||
package com.todoroo.astrid.gtasks.api
|
package com.todoroo.astrid.gtasks.api
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
||||||
import com.google.api.client.util.DateTime
|
import com.google.api.client.util.DateTime
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertNull
|
import org.junit.Assert.assertNull
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
|
||||||
class GtasksApiUtilitiesTest {
|
class GtasksApiUtilitiesTest {
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
@ -1,17 +1,14 @@
|
|||||||
package org.tasks.caldav
|
package org.tasks.caldav
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
||||||
import com.todoroo.astrid.data.Task
|
import com.todoroo.astrid.data.Task
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.tasks.TestUtilities.vtodo
|
import org.tasks.TestUtilities.vtodo
|
||||||
import org.tasks.time.DateTime
|
import org.tasks.time.DateTime
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
|
||||||
class AppleRemindersTests {
|
class AppleRemindersTests {
|
||||||
private val defaultTimeZone = TimeZone.getDefault()
|
private val defaultTimeZone = TimeZone.getDefault()
|
||||||
|
|
||||||
@ -1,15 +1,12 @@
|
|||||||
package org.tasks.caldav
|
package org.tasks.caldav
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
||||||
import net.fortuna.ical4j.model.property.Geo
|
import net.fortuna.ical4j.model.property.Geo
|
||||||
import org.junit.Assert.*
|
import org.junit.Assert.*
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.tasks.caldav.GeoUtils.equalish
|
import org.tasks.caldav.GeoUtils.equalish
|
||||||
import org.tasks.caldav.GeoUtils.latitudeLike
|
import org.tasks.caldav.GeoUtils.latitudeLike
|
||||||
import org.tasks.caldav.GeoUtils.longitudeLike
|
import org.tasks.caldav.GeoUtils.longitudeLike
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
|
||||||
class GeoUtilsTest {
|
class GeoUtilsTest {
|
||||||
@Test
|
@Test
|
||||||
fun getLatitudeLike() =
|
fun getLatitudeLike() =
|
||||||
@ -1,17 +1,14 @@
|
|||||||
package org.tasks.caldav
|
package org.tasks.caldav
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
||||||
import com.todoroo.astrid.data.Task
|
import com.todoroo.astrid.data.Task
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.tasks.TestUtilities.vtodo
|
import org.tasks.TestUtilities.vtodo
|
||||||
import org.tasks.time.DateTime
|
import org.tasks.time.DateTime
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
|
||||||
class NextCloudTests {
|
class NextCloudTests {
|
||||||
private val defaultTimeZone = TimeZone.getDefault()
|
private val defaultTimeZone = TimeZone.getDefault()
|
||||||
|
|
||||||
@ -1,15 +1,12 @@
|
|||||||
package org.tasks.caldav
|
package org.tasks.caldav
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.tasks.TestUtilities.vtodo
|
import org.tasks.TestUtilities.vtodo
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
|
||||||
class SynologyTests {
|
class SynologyTests {
|
||||||
private val defaultTimeZone = TimeZone.getDefault()
|
private val defaultTimeZone = TimeZone.getDefault()
|
||||||
|
|
||||||
@ -1,17 +1,14 @@
|
|||||||
package org.tasks.caldav
|
package org.tasks.caldav
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
||||||
import com.todoroo.astrid.data.Task
|
import com.todoroo.astrid.data.Task
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.tasks.TestUtilities.vtodo
|
import org.tasks.TestUtilities.vtodo
|
||||||
import org.tasks.time.DateTime
|
import org.tasks.time.DateTime
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
|
||||||
class ThunderbirdTests {
|
class ThunderbirdTests {
|
||||||
private val defaultTimeZone = TimeZone.getDefault()
|
private val defaultTimeZone = TimeZone.getDefault()
|
||||||
|
|
||||||
@ -1,14 +1,11 @@
|
|||||||
package org.tasks.date
|
package org.tasks.date
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.tasks.Freeze.Companion.freezeAt
|
import org.tasks.Freeze.Companion.freezeAt
|
||||||
import org.tasks.time.DateTime
|
import org.tasks.time.DateTime
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
|
||||||
class DateTimeUtilsTest {
|
class DateTimeUtilsTest {
|
||||||
private val now = DateTime(2014, 1, 1, 15, 17, 53, 0)
|
private val now = DateTime(2014, 1, 1, 15, 17, 53, 0)
|
||||||
|
|
||||||
@ -1,13 +1,10 @@
|
|||||||
package org.tasks.db
|
package org.tasks.db
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
||||||
import com.todoroo.andlib.sql.Functions
|
import com.todoroo.andlib.sql.Functions
|
||||||
import com.todoroo.astrid.data.Task
|
import com.todoroo.astrid.data.Task
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
|
||||||
class QueryUtilsTest {
|
class QueryUtilsTest {
|
||||||
@Test
|
@Test
|
||||||
fun replaceHiddenLT() {
|
fun replaceHiddenLT() {
|
||||||
@ -1,15 +1,12 @@
|
|||||||
package org.tasks.jobs
|
package org.tasks.jobs
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
||||||
import org.junit.Assert.*
|
import org.junit.Assert.*
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.mockito.Mockito
|
import org.mockito.Mockito
|
||||||
import org.tasks.date.DateTimeUtils
|
import org.tasks.date.DateTimeUtils
|
||||||
import org.tasks.time.DateTime
|
import org.tasks.time.DateTime
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
|
||||||
class BackupWorkTest {
|
class BackupWorkTest {
|
||||||
@Test
|
@Test
|
||||||
fun filterExcludesXmlFiles() {
|
fun filterExcludesXmlFiles() {
|
||||||
@ -1,14 +1,11 @@
|
|||||||
package org.tasks.time
|
package org.tasks.time
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
||||||
import org.junit.Assert.*
|
import org.junit.Assert.*
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.tasks.Freeze
|
import org.tasks.Freeze
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
|
||||||
class DateTimeTest {
|
class DateTimeTest {
|
||||||
@Test
|
@Test
|
||||||
fun testGetMillisOfDay() {
|
fun testGetMillisOfDay() {
|
||||||
Loading…
Reference in New Issue