-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main-ose' into 1031-mkcalendar-send-vtimezone-in-calend…
…ar-timezone
- Loading branch information
Showing
27 changed files
with
501 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 0 additions & 54 deletions
54
app/src/androidTest/kotlin/at/bitfire/davdroid/sync/worker/OneTimeSyncWorkerTest.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
app/src/androidTest/kotlin/at/bitfire/davdroid/sync/worker/SyncWorkerManagerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Copyright © All Contributors. See LICENSE and AUTHORS in the root directory for details. | ||
*/ | ||
|
||
package at.bitfire.davdroid.sync.worker | ||
|
||
import android.accounts.Account | ||
import android.content.Context | ||
import android.provider.CalendarContract | ||
import android.util.Log | ||
import androidx.hilt.work.HiltWorkerFactory | ||
import androidx.work.Configuration | ||
import androidx.work.testing.WorkManagerTestInitHelper | ||
import at.bitfire.davdroid.TestUtils | ||
import at.bitfire.davdroid.TestUtils.workScheduledOrRunning | ||
import at.bitfire.davdroid.sync.account.TestAccountAuthenticator | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dagger.hilt.android.testing.HiltAndroidRule | ||
import dagger.hilt.android.testing.HiltAndroidTest | ||
import org.junit.After | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Assert.assertFalse | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import javax.inject.Inject | ||
|
||
@HiltAndroidTest | ||
class SyncWorkerManagerTest { | ||
|
||
@get:Rule | ||
val hiltRule = HiltAndroidRule(this) | ||
|
||
@Inject | ||
@ApplicationContext | ||
lateinit var context: Context | ||
|
||
@Inject | ||
lateinit var syncWorkerManager: SyncWorkerManager | ||
|
||
@Inject | ||
lateinit var workerFactory: HiltWorkerFactory | ||
|
||
lateinit var account: Account | ||
|
||
@Before | ||
fun setUp() { | ||
hiltRule.inject() | ||
|
||
// Initialize WorkManager for instrumentation tests. | ||
val config = Configuration.Builder() | ||
.setMinimumLoggingLevel(Log.DEBUG) | ||
.setWorkerFactory(workerFactory) | ||
.build() | ||
WorkManagerTestInitHelper.initializeTestWorkManager(context, config) | ||
|
||
account = TestAccountAuthenticator.create() | ||
} | ||
|
||
@After | ||
fun tearDown() { | ||
TestAccountAuthenticator.remove(account) | ||
} | ||
|
||
|
||
// one-time sync workers | ||
|
||
@Test | ||
fun testEnqueueOneTime() { | ||
val workerName = OneTimeSyncWorker.workerName(account, CalendarContract.AUTHORITY) | ||
assertFalse(TestUtils.workScheduledOrRunningOrSuccessful(context, workerName)) | ||
|
||
val returnedName = syncWorkerManager.enqueueOneTime(account, CalendarContract.AUTHORITY) | ||
assertEquals(workerName, returnedName) | ||
assertTrue(TestUtils.workScheduledOrRunningOrSuccessful(context, workerName)) | ||
} | ||
|
||
|
||
// periodic sync workers | ||
|
||
@Test | ||
fun enablePeriodic() { | ||
syncWorkerManager.enablePeriodic(account, CalendarContract.AUTHORITY, 60, false).result.get() | ||
|
||
val workerName = PeriodicSyncWorker.workerName(account, CalendarContract.AUTHORITY) | ||
assertTrue(workScheduledOrRunning(context, workerName)) | ||
} | ||
|
||
@Test | ||
fun disablePeriodic() { | ||
syncWorkerManager.enablePeriodic(account, CalendarContract.AUTHORITY, 60, false).result.get() | ||
syncWorkerManager.disablePeriodic(account, CalendarContract.AUTHORITY).result.get() | ||
|
||
val workerName = PeriodicSyncWorker.workerName(account, CalendarContract.AUTHORITY) | ||
assertFalse(workScheduledOrRunning(context, workerName)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.