[go: up one dir, main page]

Skip to content

Commit

Permalink
Replace usage of TestDispatcher with StandardTestDispatcher in paging…
Browse files Browse the repository at this point in the history
…-compose
  • Loading branch information
veyndan committed Mar 17, 2023
1 parent 6527d56 commit 12abfc2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 0 additions & 1 deletion paging/paging-compose/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ dependencies {
androidTestImplementation(libs.testRunner)
androidTestImplementation(libs.junit)
androidTestImplementation(libs.truth)
androidTestImplementation(project(":internal-testutils-ktx"))

samples(projectOrArtifact(":paging:paging-compose:paging-compose-samples"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.testutils.TestDispatcher
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsNotDisplayed
import androidx.compose.ui.test.assertTopPositionInRootIsEqualTo
Expand All @@ -48,6 +47,7 @@ import androidx.test.filters.LargeTest
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.isActive
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.StandardTestDispatcher
import org.junit.Assert.assertFalse
import org.junit.Ignore
import org.junit.Rule
Expand Down Expand Up @@ -821,10 +821,9 @@ class LazyPagingItemsTest {
TestPagingSource(items = items, loadDelay = 0)
}

val context = TestDispatcher()
val context = StandardTestDispatcher()
lateinit var lazyPagingItems: LazyPagingItems<Int>
rule.setContent {
assertThat(context.queue).isEmpty()
lazyPagingItems = pager.flow.collectAsLazyPagingItems(context)
}

Expand All @@ -835,11 +834,11 @@ class LazyPagingItemsTest {
}

// start LaunchedEffects
context.executeAll()
context.scheduler.advanceUntilIdle()

rule.runOnIdle {
// continue with pagingDataDiffer collections
context.executeAll()
context.scheduler.advanceUntilIdle()
}
rule.waitUntil {
lazyPagingItems.itemCount == items.size
Expand Down

0 comments on commit 12abfc2

Please sign in to comment.