Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure order of search history entries in tests #7670

Merged
merged 4 commits into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
test-android:
# macos has hardware acceleration. See android-emulator-runner action
runs-on: macos-latest
timeout-minutes: 20
strategy:
matrix:
# api-level 19 is min sdk, but throws errors related to desugaring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.Timeout
import org.schabi.newpipe.database.AppDatabase
import org.schabi.newpipe.database.history.model.SearchHistoryEntry
import org.schabi.newpipe.testUtil.TestDatabase
import org.schabi.newpipe.testUtil.TrampolineSchedulerRule
import java.time.LocalDateTime
import java.time.OffsetDateTime
import java.util.concurrent.TimeUnit
import java.time.ZoneOffset

class HistoryRecordManagerTest {

Expand All @@ -23,9 +23,6 @@ class HistoryRecordManagerTest {
@get:Rule
val trampolineScheduler = TrampolineSchedulerRule()

@get:Rule
val timeout = Timeout(1, TimeUnit.SECONDS)

@Before
fun setup() {
database = TestDatabase.createReplacingNewPipeDatabase()
Expand Down Expand Up @@ -54,10 +51,10 @@ class HistoryRecordManagerTest {
@Test
fun deleteSearchHistory() {
val entries = listOf(
SearchHistoryEntry(OffsetDateTime.now(), 0, "A"),
SearchHistoryEntry(OffsetDateTime.now(), 2, "A"),
SearchHistoryEntry(OffsetDateTime.now(), 1, "B"),
SearchHistoryEntry(OffsetDateTime.now(), 0, "B"),
SearchHistoryEntry(time.minusSeconds(1), 0, "A"),
SearchHistoryEntry(time.minusSeconds(2), 2, "A"),
SearchHistoryEntry(time.minusSeconds(3), 1, "B"),
SearchHistoryEntry(time.minusSeconds(4), 0, "B"),
)

// make sure all 4 were inserted
Expand Down Expand Up @@ -86,9 +83,9 @@ class HistoryRecordManagerTest {
@Test
fun deleteCompleteSearchHistory() {
val entries = listOf(
SearchHistoryEntry(OffsetDateTime.now(), 1, "A"),
SearchHistoryEntry(OffsetDateTime.now(), 2, "B"),
SearchHistoryEntry(OffsetDateTime.now(), 0, "C"),
SearchHistoryEntry(time.minusSeconds(1), 1, "A"),
SearchHistoryEntry(time.minusSeconds(2), 2, "B"),
SearchHistoryEntry(time.minusSeconds(3), 0, "C"),
)

// make sure all 3 were inserted
Expand Down Expand Up @@ -142,14 +139,16 @@ class HistoryRecordManagerTest {
}

companion object {
val RELATED_SEARCHES_ENTRIES = listOf(
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(7), 2, "AC"),
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(6), 0, "ABC"),
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(5), 1, "BA"),
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(4), 3, "A"),
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(2), 0, "B"),
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(3), 2, "AA"),
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(1), 1, "A"),
private val time = OffsetDateTime.of(LocalDateTime.of(2000, 1, 1, 1, 1), ZoneOffset.UTC)

private val RELATED_SEARCHES_ENTRIES = listOf(
SearchHistoryEntry(time.minusSeconds(7), 2, "AC"),
SearchHistoryEntry(time.minusSeconds(6), 0, "ABC"),
SearchHistoryEntry(time.minusSeconds(5), 1, "BA"),
SearchHistoryEntry(time.minusSeconds(4), 3, "A"),
SearchHistoryEntry(time.minusSeconds(2), 0, "B"),
SearchHistoryEntry(time.minusSeconds(3), 2, "AA"),
SearchHistoryEntry(time.minusSeconds(1), 1, "A"),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.Timeout
import org.schabi.newpipe.database.AppDatabase
import org.schabi.newpipe.database.stream.model.StreamEntity
import org.schabi.newpipe.extractor.stream.StreamType
import org.schabi.newpipe.testUtil.TestDatabase
import org.schabi.newpipe.testUtil.TrampolineSchedulerRule
import java.util.concurrent.TimeUnit

class LocalPlaylistManagerTest {

Expand All @@ -20,9 +18,6 @@ class LocalPlaylistManagerTest {
@get:Rule
val trampolineScheduler = TrampolineSchedulerRule()

@get:Rule
val timeout = Timeout(1, TimeUnit.SECONDS)

@Before
fun setup() {
database = TestDatabase.createReplacingNewPipeDatabase()
Expand Down