Skip to content

Commit 550fc2e

Browse files
Clean up some test code
1 parent 78acdf3 commit 550fc2e

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed

app/src/androidTest/java/org/schabi/newpipe/database/FeedDAOTest.kt

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import org.schabi.newpipe.extractor.ServiceList
2121
import org.schabi.newpipe.extractor.channel.ChannelInfo
2222
import org.schabi.newpipe.extractor.stream.StreamType
2323
import java.io.IOException
24-
import java.time.Instant
2524
import java.time.LocalDate
2625
import java.time.Month
2726
import java.time.ZoneOffset
@@ -34,16 +33,51 @@ class FeedDAOTest {
3433

3534
private val serviceId = ServiceList.YouTube.serviceId
3635

37-
private val stream1 = StreamEntity(1, serviceId, "https://youtube.com/watch?v=1", "stream 1", StreamType.VIDEO_STREAM, 1000, "channel-1", "https://youtube.com/channel/1", "https://i.ytimg.com/vi/1/hqdefault.jpg", 100, "2023-01-01", Instant.parse("2023-01-01T00:00:00Z"))
38-
private val stream2 = StreamEntity(2, serviceId, "https://youtube.com/watch?v=2", "stream 2", StreamType.VIDEO_STREAM, 1000, "channel-1", "https://youtube.com/channel/1", "https://i.ytimg.com/vi/1/hqdefault.jpg", 100, "2023-01-02", Instant.parse("2023-01-02T00:00:00Z"))
39-
private val stream3 = StreamEntity(3, serviceId, "https://youtube.com/watch?v=3", "stream 3", StreamType.LIVE_STREAM, 1000, "channel-1", "https://youtube.com/channel/1", "https://i.ytimg.com/vi/1/hqdefault.jpg", 100, "2023-01-03", Instant.parse("2023-01-03T00:00:00Z"))
40-
private val stream4 = StreamEntity(4, serviceId, "https://youtube.com/watch?v=4", "stream 4", StreamType.VIDEO_STREAM, 1000, "channel-2", "https://youtube.com/channel/2", "https://i.ytimg.com/vi/1/hqdefault.jpg", 100, "2023-08-10", Instant.parse("2023-08-10T00:00:00Z"))
41-
private val stream5 = StreamEntity(5, serviceId, "https://youtube.com/watch?v=5", "stream 5", StreamType.VIDEO_STREAM, 1000, "channel-2", "https://youtube.com/channel/2", "https://i.ytimg.com/vi/1/hqdefault.jpg", 100, "2023-08-20", Instant.parse("2023-08-20T00:00:00Z"))
42-
private val stream6 = StreamEntity(6, serviceId, "https://youtube.com/watch?v=6", "stream 6", StreamType.VIDEO_STREAM, 1000, "channel-3", "https://youtube.com/channel/3", "https://i.ytimg.com/vi/1/hqdefault.jpg", 100, "2023-09-01", Instant.parse("2023-09-01T00:00:00Z"))
43-
private val stream7 = StreamEntity(7, serviceId, "https://youtube.com/watch?v=7", "stream 7", StreamType.VIDEO_STREAM, 1000, "channel-4", "https://youtube.com/channel/4", "https://i.ytimg.com/vi/1/hqdefault.jpg", 100, "2023-08-10", Instant.parse("2023-08-10T00:00:00Z"))
36+
private val stream1 =
37+
createStreamEntity(
38+
1, "https://youtube.com/watch?v=1", "stream 1", uploader = "channel-1",
39+
uploaderUrl = "https://youtube.com/channel/1", date = LocalDate.of(2023, Month.JANUARY, 2),
40+
)
41+
private val stream2 =
42+
createStreamEntity(
43+
2, "https://youtube.com/watch?v=2", "stream 2", uploader = "channel-1",
44+
uploaderUrl = "https://youtube.com/channel/1", date = LocalDate.of(2023, Month.JANUARY, 2),
45+
)
46+
private val stream3 =
47+
createStreamEntity(
48+
3, "https://youtube.com/watch?v=3", "stream 3", StreamType.LIVE_STREAM,
49+
"channel-1", "https://youtube.com/channel/1", LocalDate.of(2023, Month.JANUARY, 3),
50+
)
51+
private val stream4 =
52+
createStreamEntity(
53+
4, "https://youtube.com/watch?v=4", "stream 4", uploader = "channel-2",
54+
uploaderUrl = "https://youtube.com/channel/2", date = LocalDate.of(2023, Month.AUGUST, 10),
55+
)
56+
private val stream5 =
57+
createStreamEntity(
58+
5, "https://youtube.com/watch?v=5", "stream 5", uploader = "channel-2",
59+
uploaderUrl = "https://youtube.com/channel/2", date = LocalDate.of(2023, Month.AUGUST, 20),
60+
)
61+
private val stream6 =
62+
createStreamEntity(
63+
6, "https://youtube.com/watch?v=6", "stream 6", uploader = "channel-3",
64+
uploaderUrl = "https://youtube.com/channel/3", date = LocalDate.of(2023, Month.SEPTEMBER, 1),
65+
)
66+
private val stream7 =
67+
createStreamEntity(
68+
7, "https://youtube.com/watch?v=7", "stream 7", uploader = "channel-4",
69+
uploaderUrl = "https://youtube.com/channel/4", date = LocalDate.of(2023, Month.AUGUST, 10),
70+
)
71+
72+
private val allStreams = listOf(stream1, stream2, stream3, stream4, stream5, stream6, stream7)
4473

45-
private val allStreams = listOf(
46-
stream1, stream2, stream3, stream4, stream5, stream6, stream7
74+
private fun createStreamEntity(
75+
uid: Long, url: String, title: String, type: StreamType = StreamType.VIDEO_STREAM,
76+
uploader: String, uploaderUrl: String, date: LocalDate,
77+
) = StreamEntity(
78+
uid, serviceId, url, title, type, duration = 1000, uploader, uploaderUrl,
79+
thumbnailUrl = "https://i.ytimg.com/vi/1/hqdefault.jpg", viewCount = 100, textualUploadDate = date.toString(),
80+
uploadInstant = date.atStartOfDay(ZoneOffset.UTC).toInstant(),
4781
)
4882

4983
@Before

0 commit comments

Comments
 (0)