[GH] Replace usage of DirectDispatcher with EmptyCoroutineContext in testutils-paging
The reasoning is the same as https://github.com/androidx/androidx/pull/505, but for `testutils-paging`.
Test: ./gradlew test connectedCheck
Bug: 270612487
This is an imported pull request from https://github.com/androidx/androidx/pull/507.
Resolves #507
Github-Pr-Head-Sha: d1497e7696398d14b47b587bffb16536393f4878
GitOrigin-RevId: e1f3a08a0e559694b71ecab1557517beee193987
Change-Id: Idcd1a1981941baf4ddd93346f87b9e30dbcb746e
diff --git a/paging/paging-common/src/test/kotlin/androidx/paging/PagingDataDifferTest.kt b/paging/paging-common/src/test/kotlin/androidx/paging/PagingDataDifferTest.kt
index 4740924..24f272f 100644
--- a/paging/paging-common/src/test/kotlin/androidx/paging/PagingDataDifferTest.kt
+++ b/paging/paging-common/src/test/kotlin/androidx/paging/PagingDataDifferTest.kt
@@ -2054,7 +2054,7 @@
pagingSourceFactory = {
TestPagingSource(
loadDelay = 0,
- loadDispatcher = loadDispatcher,
+ loadContext = loadDispatcher,
).also { pagingSources.add(it) }
}
),
diff --git a/testutils/testutils-paging/build.gradle b/testutils/testutils-paging/build.gradle
index f2eb353..91046d5 100644
--- a/testutils/testutils-paging/build.gradle
+++ b/testutils/testutils-paging/build.gradle
@@ -25,7 +25,6 @@
dependencies {
api(libs.kotlinStdlib)
implementation(project(":paging:paging-common"))
- implementation(project(":internal-testutils-ktx"))
implementation(libs.kotlinTest)
}
diff --git a/testutils/testutils-paging/src/main/java/androidx/paging/TestPagingSource.kt b/testutils/testutils-paging/src/main/java/androidx/paging/TestPagingSource.kt
index a035f82..809fef2 100644
--- a/testutils/testutils-paging/src/main/java/androidx/paging/TestPagingSource.kt
+++ b/testutils/testutils-paging/src/main/java/androidx/paging/TestPagingSource.kt
@@ -16,8 +16,8 @@
package androidx.paging
-import androidx.testutils.DirectDispatcher
-import kotlinx.coroutines.CoroutineDispatcher
+import kotlin.coroutines.CoroutineContext
+import kotlin.coroutines.EmptyCoroutineContext
import kotlinx.coroutines.delay
import kotlinx.coroutines.withContext
@@ -33,7 +33,7 @@
override val jumpingSupported: Boolean = true,
val items: List<Int> = ITEMS,
private val loadDelay: Long = 1000,
- private val loadDispatcher: CoroutineDispatcher = DirectDispatcher,
+ private val loadContext: CoroutineContext = EmptyCoroutineContext,
private val placeholdersEnabled: Boolean = true,
) : PagingSource<Int, Int>() {
var errorNextLoad = false
@@ -60,7 +60,7 @@
// execution of events.
delay(loadDelay)
- return withContext(loadDispatcher) { getLoadResult(params) }
+ return withContext(loadContext) { getLoadResult(params) }
}
private fun getLoadResult(params: LoadParams<Int>): LoadResult<Int, Int> {