Skip to content

Commit 89c3eac

Browse files
authored
LocalEvent: don't subclass AndroidEvent (#1551)
* [WIP] Refactor LocalEvent to delegate to AndroidEvent * Move tests * Use test rules from synctools * Add null check for content provider client in JtxSyncManagerTest * Update dependencies, move OkhttpClientTest
1 parent 4246ed6 commit 89c3eac

File tree

13 files changed

+89
-583
lines changed

13 files changed

+89
-583
lines changed

app/build.gradle.kts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ dependencies {
176176
exclude(group="junit")
177177
exclude(group="org.ogce", module="xpp3") // Android has its own XmlPullParser implementation
178178
}
179-
implementation(libs.bitfire.synctools)
179+
implementation(libs.bitfire.synctools) {
180+
exclude(group="androidx.test") // synctools declares test rules, but we don't want them in non-test code
181+
exclude(group = "junit")
182+
}
180183

181184
// third-party libs
182185
@Suppress("RedundantSuppression")

app/src/androidTest/kotlin/at/bitfire/davdroid/CatchExceptionsRule.kt

Lines changed: 0 additions & 37 deletions
This file was deleted.

app/src/androidTest/kotlin/at/bitfire/davdroid/Dav4jvm.kt renamed to app/src/androidTest/kotlin/at/bitfire/davdroid/Dav4jvmTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import at.bitfire.dav4jvm.XmlUtils
99
import org.junit.Assert.assertTrue
1010
import org.junit.Test
1111

12-
class Dav4jvm {
12+
class Dav4jvmTest {
1313

1414
@Test
1515
fun test_Dav4jvm_XmlUtils_NewPullParser_RelaxedParsing() {

app/src/androidTest/kotlin/at/bitfire/davdroid/InitCalendarProviderRule.kt

Lines changed: 0 additions & 123 deletions
This file was deleted.

app/src/androidTest/kotlin/at/bitfire/davdroid/OkhttpClientTest.kt renamed to app/src/androidTest/kotlin/at/bitfire/davdroid/network/OkhttpClientTest.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
* Copyright © All Contributors. See LICENSE and AUTHORS in the root directory for details.
33
*/
44

5-
package at.bitfire.davdroid
5+
package at.bitfire.davdroid.network
66

77
import androidx.test.filters.SdkSuppress
8-
import at.bitfire.davdroid.network.HttpClient
98
import dagger.hilt.android.testing.HiltAndroidRule
109
import dagger.hilt.android.testing.HiltAndroidTest
1110
import okhttp3.Request
@@ -34,10 +33,12 @@ class OkhttpClientTest {
3433
fun testIcloudWithSettings() {
3534
httpClientBuilder.build().use { client ->
3635
client.okHttpClient
37-
.newCall(Request.Builder()
38-
.get()
39-
.url("https://icloud.com")
40-
.build())
36+
.newCall(
37+
Request.Builder()
38+
.get()
39+
.url("https://icloud.com")
40+
.build()
41+
)
4142
.execute()
4243
}
4344
}

app/src/androidTest/kotlin/at/bitfire/davdroid/resource/LocalCalendarTest.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ import android.provider.CalendarContract
1212
import android.provider.CalendarContract.ACCOUNT_TYPE_LOCAL
1313
import android.provider.CalendarContract.Events
1414
import androidx.test.platform.app.InstrumentationRegistry
15-
import at.bitfire.davdroid.InitCalendarProviderRule
1615
import at.bitfire.ical4android.AndroidCalendar
16+
import at.bitfire.ical4android.AndroidEvent
1717
import at.bitfire.ical4android.Event
1818
import at.bitfire.ical4android.util.MiscUtils.asSyncAdapter
1919
import at.bitfire.ical4android.util.MiscUtils.closeCompat
20+
import at.bitfire.synctools.test.InitCalendarProviderRule
2021
import net.fortuna.ical4j.model.property.DtStart
2122
import net.fortuna.ical4j.model.property.RRule
2223
import net.fortuna.ical4j.model.property.RecurrenceId
@@ -96,7 +97,7 @@ class LocalCalendarTest {
9697
status = Status.VEVENT_CANCELLED
9798
})
9899
}
99-
val localEvent = LocalEvent(calendar, event, "filename.ics", null, null, LocalResource.FLAG_REMOTELY_PRESENT)
100+
val localEvent = AndroidEvent(calendar, event, "filename.ics", null, null, LocalResource.FLAG_REMOTELY_PRESENT)
100101
localEvent.add()
101102
val eventId = localEvent.id!!
102103

@@ -126,7 +127,7 @@ class LocalCalendarTest {
126127
summary = "Event with 3 instances"
127128
rRules.add(RRule("FREQ=DAILY;COUNT=3"))
128129
}
129-
val localEvent = LocalEvent(calendar, event, "filename.ics", null, null, LocalResource.FLAG_REMOTELY_PRESENT)
130+
val localEvent = AndroidEvent(calendar, event, "filename.ics", null, null, LocalResource.FLAG_REMOTELY_PRESENT)
130131
localEvent.add()
131132
val eventId = localEvent.id!!
132133

0 commit comments

Comments
 (0)