Fix flaky test in LimitOffsetPagingSourceTest
Fixes test load_initialEmptyLoad
Bug: 195794422
Fixes: 195794422
Test: ./gradlew room:room-paging:cC
Change-Id: I8091d6290818402ca68efa06758ea1f3622122ea
diff --git a/room/room-paging/src/androidTest/kotlin/androidx/room/paging/LimitOffsetPagingSourceTest.kt b/room/room-paging/src/androidTest/kotlin/androidx/room/paging/LimitOffsetPagingSourceTest.kt
index abcf013..0b2d513 100644
--- a/room/room-paging/src/androidTest/kotlin/androidx/room/paging/LimitOffsetPagingSourceTest.kt
+++ b/room/room-paging/src/androidTest/kotlin/androidx/room/paging/LimitOffsetPagingSourceTest.kt
@@ -172,11 +172,15 @@
// now add items
dao.addAllItems(itemsList)
- // the db write should cause pagingSource to realize it is invalid
+ // invalidate pagingSource to imitate invalidation from running refreshVersionSync
+ pagingSource.invalidate()
+ assertTrue(pagingSource.invalid)
+
+ // this refresh should check pagingSource's invalid status, realize it is invalid, and
+ // return a LoadResult.Invalid
assertThat(pagingSource.refresh()).isInstanceOf(
LoadResult.Invalid::class.java
)
- assertTrue(pagingSource.invalid)
}
}