1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 08:30:44 +00:00

Merge pull request #7670 from XiangRongLin/search_history_test

Ensure order of search history entries in tests
This commit is contained in:
litetex 2022-01-21 22:34:48 +01:00 committed by GitHub
commit 81843ddb6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 25 deletions

View File

@ -52,6 +52,7 @@ jobs:
test-android: test-android:
# macos has hardware acceleration. See android-emulator-runner action # macos has hardware acceleration. See android-emulator-runner action
runs-on: macos-latest runs-on: macos-latest
timeout-minutes: 20
strategy: strategy:
matrix: matrix:
# api-level 19 is min sdk, but throws errors related to desugaring # api-level 19 is min sdk, but throws errors related to desugaring

View File

@ -7,13 +7,13 @@ import org.junit.Assert.assertEquals
import org.junit.Before import org.junit.Before
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
import org.junit.rules.Timeout
import org.schabi.newpipe.database.AppDatabase import org.schabi.newpipe.database.AppDatabase
import org.schabi.newpipe.database.history.model.SearchHistoryEntry import org.schabi.newpipe.database.history.model.SearchHistoryEntry
import org.schabi.newpipe.testUtil.TestDatabase import org.schabi.newpipe.testUtil.TestDatabase
import org.schabi.newpipe.testUtil.TrampolineSchedulerRule import org.schabi.newpipe.testUtil.TrampolineSchedulerRule
import java.time.LocalDateTime
import java.time.OffsetDateTime import java.time.OffsetDateTime
import java.util.concurrent.TimeUnit import java.time.ZoneOffset
class HistoryRecordManagerTest { class HistoryRecordManagerTest {
@ -23,9 +23,6 @@ class HistoryRecordManagerTest {
@get:Rule @get:Rule
val trampolineScheduler = TrampolineSchedulerRule() val trampolineScheduler = TrampolineSchedulerRule()
@get:Rule
val timeout = Timeout(1, TimeUnit.SECONDS)
@Before @Before
fun setup() { fun setup() {
database = TestDatabase.createReplacingNewPipeDatabase() database = TestDatabase.createReplacingNewPipeDatabase()
@ -54,10 +51,10 @@ class HistoryRecordManagerTest {
@Test @Test
fun deleteSearchHistory() { fun deleteSearchHistory() {
val entries = listOf( val entries = listOf(
SearchHistoryEntry(OffsetDateTime.now(), 0, "A"), SearchHistoryEntry(time.minusSeconds(1), 0, "A"),
SearchHistoryEntry(OffsetDateTime.now(), 2, "A"), SearchHistoryEntry(time.minusSeconds(2), 2, "A"),
SearchHistoryEntry(OffsetDateTime.now(), 1, "B"), SearchHistoryEntry(time.minusSeconds(3), 1, "B"),
SearchHistoryEntry(OffsetDateTime.now(), 0, "B"), SearchHistoryEntry(time.minusSeconds(4), 0, "B"),
) )
// make sure all 4 were inserted // make sure all 4 were inserted
@ -86,9 +83,9 @@ class HistoryRecordManagerTest {
@Test @Test
fun deleteCompleteSearchHistory() { fun deleteCompleteSearchHistory() {
val entries = listOf( val entries = listOf(
SearchHistoryEntry(OffsetDateTime.now(), 1, "A"), SearchHistoryEntry(time.minusSeconds(1), 1, "A"),
SearchHistoryEntry(OffsetDateTime.now(), 2, "B"), SearchHistoryEntry(time.minusSeconds(2), 2, "B"),
SearchHistoryEntry(OffsetDateTime.now(), 0, "C"), SearchHistoryEntry(time.minusSeconds(3), 0, "C"),
) )
// make sure all 3 were inserted // make sure all 3 were inserted
@ -142,14 +139,16 @@ class HistoryRecordManagerTest {
} }
companion object { companion object {
val RELATED_SEARCHES_ENTRIES = listOf( private val time = OffsetDateTime.of(LocalDateTime.of(2000, 1, 1, 1, 1), ZoneOffset.UTC)
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(7), 2, "AC"),
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(6), 0, "ABC"), private val RELATED_SEARCHES_ENTRIES = listOf(
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(5), 1, "BA"), SearchHistoryEntry(time.minusSeconds(7), 2, "AC"),
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(4), 3, "A"), SearchHistoryEntry(time.minusSeconds(6), 0, "ABC"),
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(2), 0, "B"), SearchHistoryEntry(time.minusSeconds(5), 1, "BA"),
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(3), 2, "AA"), SearchHistoryEntry(time.minusSeconds(4), 3, "A"),
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(1), 1, "A"), SearchHistoryEntry(time.minusSeconds(2), 0, "B"),
SearchHistoryEntry(time.minusSeconds(3), 2, "AA"),
SearchHistoryEntry(time.minusSeconds(1), 1, "A"),
) )
} }
} }

View File

@ -4,13 +4,11 @@ import org.junit.After
import org.junit.Before import org.junit.Before
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
import org.junit.rules.Timeout
import org.schabi.newpipe.database.AppDatabase import org.schabi.newpipe.database.AppDatabase
import org.schabi.newpipe.database.stream.model.StreamEntity import org.schabi.newpipe.database.stream.model.StreamEntity
import org.schabi.newpipe.extractor.stream.StreamType import org.schabi.newpipe.extractor.stream.StreamType
import org.schabi.newpipe.testUtil.TestDatabase import org.schabi.newpipe.testUtil.TestDatabase
import org.schabi.newpipe.testUtil.TrampolineSchedulerRule import org.schabi.newpipe.testUtil.TrampolineSchedulerRule
import java.util.concurrent.TimeUnit
class LocalPlaylistManagerTest { class LocalPlaylistManagerTest {
@ -20,9 +18,6 @@ class LocalPlaylistManagerTest {
@get:Rule @get:Rule
val trampolineScheduler = TrampolineSchedulerRule() val trampolineScheduler = TrampolineSchedulerRule()
@get:Rule
val timeout = Timeout(1, TimeUnit.SECONDS)
@Before @Before
fun setup() { fun setup() {
database = TestDatabase.createReplacingNewPipeDatabase() database = TestDatabase.createReplacingNewPipeDatabase()