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

Release 0.21.9 #6840

Merged
merged 138 commits into from
Aug 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
f47ae36
[Bandcamp Add v21 styles
TobiGr Jun 8, 2021
060f09f
Apply service color to switches
TobiGr Jun 8, 2021
6ab4787
Use SwitchCompat to make switch uniform across versions
Stypox Jun 9, 2021
272d589
Convert related_items_header to ConstraintLayout
Stypox Jun 9, 2021
fa1d7ff
Const text width for metadata; scrollable tags layout
Stypox Jun 9, 2021
40a2df8
Move tags layout at the bottom, use multiple lines
Stypox Jun 13, 2021
9767e98
Remove option to immediately commit pref changes on import
XiangRongLin Jun 20, 2021
0bdf8de
Resolve sonar issues in ContentSettingsFragment
XiangRongLin Jun 20, 2021
785c037
Remove variable ContentSettingsFragment.lastImportExportDataUri
XiangRongLin Jun 20, 2021
72d305b
Update AndroidX Fragment to 1.3.5
TacoTheDank Jun 20, 2021
e5a1438
Fix onActivityResult deprecation in DownloadSettingsFragment
TacoTheDank Jun 20, 2021
ae39b31
Fix onActivityResult deprecation in DownloadDialog
TacoTheDank Jun 20, 2021
02b0909
Fix onActivityResult deprecation in MissionsFragment
TacoTheDank Jun 20, 2021
08d4651
Add mavenCentral, de-prioritize jcenter
TacoTheDank Jun 20, 2021
afe06b3
Update some libraries
TacoTheDank Jun 20, 2021
cb1a138
#6081: Disable feed click handlers during refresh
Douile Jun 22, 2021
aaa3e20
service.onDestroy() should only be called from the system and not man…
evermind-zz Jun 22, 2021
22a4a4b
move null checks for player and playerService to helper methods
evermind-zz Jun 23, 2021
e30a552
remove duplicated code for toggle Fullscreen
evermind-zz Jun 23, 2021
4358133
use viewBinding correctly
evermind-zz Jun 23, 2021
48c2c15
convert PlayerHolder to Singleton, handle context within, bugfix Serv…
evermind-zz Jun 24, 2021
f78d2a5
Prevent error msg: 'Unrecoverable player error occurred' while playin…
evermind-zz Jun 3, 2021
9c636f5
Specify emulator-build version in CI job
XiangRongLin Jul 6, 2021
573839c
Update Gradle to 7.x, AGP to 4.2.x
TacoTheDank Jul 6, 2021
85e864a
Made the thumbnail in the minimized player visible again
litetex Jul 6, 2021
6711dae
Use GestureDetectorCompat.
Isira-Seneviratne Jul 10, 2021
2e053ea
Fix crash when refreshing feed
Douile Jul 11, 2021
e9b008e
Merge pull request #6538 from TacoTheDank/bump-gradle
TobiGr Jul 12, 2021
85d813a
Merge pull request #6540 from TacoTheDank/library-bumps
TobiGr Jul 12, 2021
4d5b687
Merge pull request #6560 from TeamNewPipe/fix_ci_emulator
TobiGr Jul 12, 2021
64efb89
Merge pull request #6616 from litetex/fix-minimized-player-thumbnail
TobiGr Jul 12, 2021
96f5cd9
Merge pull request #6463 from Stypox/metadata-tags
TobiGr Jul 12, 2021
56ea526
Add instrumented tests for LocalPlaylistManager.createPlaylist
XiangRongLin Feb 5, 2021
2aa5f68
Add comment explaining usage Schedulers.trampoline in detail
XiangRongLin Jul 6, 2021
403e336
Bump compileSdkVersion to 30.
Isira-Seneviratne Jul 13, 2021
14dab85
Merge pull request #6566 from evermind-zz/various-fixes-for-upstream
TobiGr Jul 14, 2021
1584028
Merge pull request #6531 from XiangRongLin/immediat_pref_commit
TobiGr Jul 14, 2021
dfa941a
Merge pull request #6503 from evermind-zz/fixes-for-upstream
TobiGr Jul 14, 2021
6e576a1
Added a Kotlin section in CONTRIBUTING.md
Redirion Jul 14, 2021
a2eb810
removed Extractor line
Redirion Jul 14, 2021
d3375a9
Remove api level 29 from android ci tests
XiangRongLin Jul 16, 2021
e7f339a
Merge pull request #6678 from TeamNewPipe/XiangRongLin-patch-1
TobiGr Jul 16, 2021
08d5dfa
Removed updateRelativeTimeViews when the activity is paused
litetex Jul 16, 2021
f4e2eca
Simplified code and adjusted the style so that it's similar to FeedFr…
litetex Jul 16, 2021
a932bc2
Merge pull request #6637 from Isira-Seneviratne/Use_GestureDetectorCo…
Stypox Jul 17, 2021
81107df
Added comments disabled functionallity
litetex Jun 13, 2021
75a8edf
Added corresponding required code changes from Extractor branch
litetex Jun 13, 2021
36c198f
One textview is enough for disabled comments
litetex Jun 19, 2021
e7d5011
Merge pull request #6483 from litetex/addDisabledComments
Stypox Jul 17, 2021
eef568b
Merge pull request #5531 from XiangRongLin/tests
Stypox Jul 17, 2021
43133df
Added settings for seekbar-preview-thumbnail
litetex Jun 8, 2021
2e2dbaf
Added seekbar-preview to the player layout
litetex Jun 8, 2021
253526e
Updated build.gradle so the PR-build works
litetex Jun 8, 2021
384d964
Added seekbarThumbnailPreview
litetex Jun 9, 2021
c5f2eb1
Enlarged currentDisplaySeek a bit
litetex Jun 15, 2021
88c4195
Enlarged currentDisplaySeek-text on large-handed player
litetex Jun 15, 2021
2a24532
Fine tuned padding
litetex Jun 19, 2021
a9b5ef3
Set minWidth to 10dp so that the popup player works (mostly) correctly
litetex Jun 19, 2021
0b2629e
Moved time to the top
litetex Jul 6, 2021
efd038a
Increased padding of preview thumbnail
litetex Jul 6, 2021
621af8d
Removed unused import (rebasing/merge problem)
litetex Jul 17, 2021
e2b044d
Use Kotlin methods in LicenseFragment.
Isira-Seneviratne Jul 16, 2021
baa12c7
Merge pull request #6536 from TacoTheDank/moar-onactivityresult
Stypox Jul 18, 2021
6c25ce5
Merge pull request #6456 from TeamNewPipe/feature/switch-theme
Stypox Jul 18, 2021
35e005c
Improve method order in DownloadDialog and add separator comments
Stypox Jul 18, 2021
8f55996
Call DownloadDialog dismiss() in the correct way
Stypox Jul 19, 2021
3167ab3
Merge pull request #6654 from Isira-Seneviratne/Bump_compileSdk
Stypox Jul 19, 2021
d57bfde
Merge pull request #6434 from litetex/playerSeekbarPreview
Stypox Jul 19, 2021
1721817
Use WindowInsetsCompat's getInsets() method.
Isira-Seneviratne Jul 12, 2021
c7b8bd3
Update AppCompat to 1.3.0.
Isira-Seneviratne Jul 19, 2021
46e7da4
Merge pull request #6688 from litetex/fix-some-build-warnings
Stypox Jul 19, 2021
bec8512
Merge pull request #6659 from TeamNewPipe/Redirion-kotlin-section
Stypox Jul 19, 2021
0cde08c
Merge pull request #6702 from Isira-Seneviratne/Update_AppCompat_to_1…
Redirion Jul 19, 2021
ca282f2
Merge pull request #6675 from Isira-Seneviratne/Use_Kotlin_methods
Stypox Jul 19, 2021
5ba3ef0
Fix grid span count calculation; remove duplicate methods
Stypox Jul 19, 2021
f02c6be
Fix format of some kotlin files
litetex Jul 19, 2021
f6923e0
Use the correct extractor dependency
litetex Jul 19, 2021
d8f442c
Merge pull request #6707 from litetex/use-correct-extractor-dependency
TobiGr Jul 19, 2021
4a242e4
Merge pull request #6689 from Isira-Seneviratne/Use_WindowInsetsCompa…
Stypox Jul 19, 2021
cebcaf4
Merge pull request #6706 from litetex/fix-format-of-some-kotlin-files
TobiGr Jul 19, 2021
9e2ece7
Merge pull request #6701 from Stypox/dismiss-download-dialog
TobiGr Jul 19, 2021
63fdc10
Merge pull request #6705 from Stypox/big-text-info-items
TobiGr Jul 19, 2021
c422f65
Readd api level 29 to android CI tests
XiangRongLin Jul 20, 2021
420f050
Merge branch 'master' into dev
TobiGr Jul 20, 2021
fd4e1b8
Merge pull request #6715 from TeamNewPipe/readd_api_29
TobiGr Jul 20, 2021
a9e21a3
Delete pending missions with invalid storage
Stypox Jul 21, 2021
4a2bd7b
Remove equals() method from PlayQueueItem
Stypox Jul 20, 2021
fa8630d
Use url comparison between queue items when disabling preloading
Stypox Jul 21, 2021
736cefe
Add tests for play queue items' equals()
Stypox Jul 21, 2021
1d85661
Update some AndroidX libraries
TacoTheDank Jul 21, 2021
cd86ed3
Prevent recaptcha webview from keeping youtube loaded in background
Douile Jul 22, 2021
52c1364
Use loadUrl instead of loadData
Douile Jul 22, 2021
1f9ad12
Merge pull request #6712 from Stypox/fix-duplicate-items-queue
Redirion Jul 22, 2021
39722a5
Merge pull request #6721 from Stypox/pending-mission-crash
TobiGr Jul 22, 2021
3874e16
Added support for showing when a comment has received a heart from th…
KalleStruik Jul 23, 2021
7417331
Change heart color to be red, add else clause for non hearted comment…
KalleStruik Jul 23, 2021
f709ac1
Fixed the toolbarSearchTheme
litetex Jul 26, 2021
7fd2ebc
Add ability to mark an item as played
nschulzke Jul 27, 2021
1822d21
Fix NullPointerException when checking if storage exists
Stypox Jul 27, 2021
0cb8011
Merge pull request #6733 from Douile/fix/recaptcha-webview-background…
Stypox Jul 27, 2021
7ceea2c
Merge pull request #6771 from litetex/fix-ToolbarSearchInputTheme
Stypox Jul 27, 2021
2aebf6c
Add log when existsAsFile() is called on an invalid StoredFileHelper
Stypox Jul 27, 2021
50f3b08
Consolidate edittext alert dialogs into one layout
TacoTheDank Jul 27, 2021
e2791cd
Fix deprecated fill_parent attributes
TacoTheDank Jul 27, 2021
5ceec31
Merge pull request #6720 from TacoTheDank/alertdialog-edittext
Stypox Jul 27, 2021
5924edb
Merge pull request #6782 from TacoTheDank/fix-fill-parent
Stypox Jul 27, 2021
2b41f71
Change played to watched
nschulzke Jul 27, 2021
bfac73b
Make heart visible in android studio and move logic to the right file.
KalleStruik Jul 27, 2021
f451bdb
Do not add Mark as Watched to a live stream.
nschulzke Jul 27, 2021
4c63281
Fetch the stream info via a network request if no duration is found w…
nschulzke Jul 27, 2021
bdd16e0
Add comments describing the purpose of the markAsWatched method
nschulzke Jul 28, 2021
cd713db
Merge pull request #6778 from Stypox/invalid-storage-npe
TobiGr Jul 28, 2021
9032960
Check formatting of kotlin files in CI
litetex Jul 28, 2021
0e12cde
Save the fetched duration to the database so that it can render the v…
nschulzke Jul 30, 2021
a25bb26
Merge pull request #6808 from litetex/ci-run-format-ktlin-before-buil…
Stypox Jul 31, 2021
6443961
Fix channel item span count for SubscriptionFragment
Stypox Jul 31, 2021
dc0a28b
Upsert the complete info if we fetch it for marking as watched
nschulzke Jul 31, 2021
551e8df
Merge pull request #6773 from nschulzke/mark-as-played
Stypox Aug 1, 2021
398007c
Update extractor, thus including throttling fixes
XiangRongLin Jul 28, 2021
d42a534
Merge pull request #6741 from KalleStruik/comment-hearts
Stypox Aug 1, 2021
896aec5
Merge pull request #6719 from TacoTheDank/core-lifecycle-bump
Redirion Aug 1, 2021
d324502
Use NotificationChannelCompat.
Isira-Seneviratne Jul 10, 2021
bc74bb6
Merge pull request #6633 from Isira-Seneviratne/Use_NotificationChann…
Stypox Aug 1, 2021
a9623f8
Merge pull request #6550 from Douile/fix/clickthrough-feed-refresh
Stypox Aug 1, 2021
4bf5ddb
Merge pull request #6792 from XiangRongLin/update_extractor
Stypox Aug 1, 2021
c7f75bf
Ignore paths unrelated to builds in CI (#6789)
triallax Aug 2, 2021
4291877
Merge branch 'master' into dev
Stypox Aug 4, 2021
340a84e
Release 0.21.9 (975)
Stypox Aug 4, 2021
23a6973
v0.21.9 (975) changelog
Stypox Aug 4, 2021
a2297fb
Fix play queue theme
Stypox Aug 4, 2021
c3349e1
Merge pull request #6847 from Stypox/play-queue-theme
TobiGr Aug 4, 2021
a3440cc
Merge pull request #6814 from Stypox/channel-grid-span-count
Stypox Aug 5, 2021
9dd2a82
Update extractor version
TobiGr Aug 10, 2021
4e15f0d
Translated using Weblate (Finnish)
weblate Aug 22, 2021
82fbbbe
Fixed plurals
TobiGr Aug 22, 2021
d1ce8e7
Removed unsued string from translations: item_in_history
TobiGr Aug 22, 2021
ccc2d89
Update extractor version to 0.21.9
TobiGr Aug 22, 2021
8715e7d
Only show "mark as watched" context menu entry when watch history is…
TobiGr Aug 22, 2021
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
4 changes: 4 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ You'll see *exactly* what is sent, be able to add **your comments**, and then se
* Create PRs that cover only **one specific issue/solution/bug**. Do not create PRs that are huge monoliths and could have been split into multiple independent contributions.
* NewPipe uses [NewPipeExtractor](https://github.com/TeamNewPipe/NewPipeExtractor) to fetch data from services. If you need to change something there, you must test your changes in NewPipe. Telling NewPipe to use your extractor version can be accomplished by editing the `app/build.gradle` file: the comments under the "NewPipe libraries" section of `dependencies` will help you out.

### Kotlin in NewPipe
* NewPipe will remain mostly Java for time being
* Contributions containing a simple conversion from Java to Kotlin should be avoided. Conversions to Kotlin should only be done if Kotlin actually brings improvements like bug fixes or better performance which are not, or only with much more effort, implementable in Java. The core team sees Java as an easier to learn and generally well adopted programming language.

### Creating a Pull Request (PR)

* Make changes on a **separate branch** with a meaningful name, not on the _master_ branch or the _dev_ branch. This is commonly known as *feature branch workflow*. You may then send your changes as a pull request (PR) on GitHub.
Expand Down
72 changes: 43 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ on:
branches:
- dev
- master
paths-ignore:
- 'README*.md'
- 'fastlane/**'
- 'assets/**'
- '.github/**/*.md'
push:
branches:
- dev
- master
paths-ignore:
- 'README*.md'
- 'fastlane/**'
- 'assets/**'
- '.github/**/*.md'

jobs:
build-and-test-jvm:
Expand All @@ -34,6 +44,9 @@ jobs:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle

- name: Check if kotlin files are formatted correctly
run: ./gradlew runKtlint

- name: Build debug APK and run jvm tests
run: ./gradlew assembleDebug lintDebug testDebugUnitTest --stacktrace
Expand All @@ -44,35 +57,36 @@ jobs:
name: app
path: app/build/outputs/apk/debug/*.apk

# Disabled until emulator works again. see https://github.com/TeamNewPipe/NewPipe/pull/6560
# test-android:
# macos has hardware acceleration. See android-emulator-runner action
# runs-on: macos-latest
# strategy:
# matrix:
# api-level 19 is min sdk, but throws errors related to desugaring
# api-level: [21, 29]
# steps:
# - uses: actions/checkout@v2
#
# - name: set up JDK 8
# uses: actions/setup-java@v2
# with:
# java-version: 8
# distribution: "adopt"
#
# - name: Cache Gradle dependencies
# uses: actions/cache@v2
# with:
# path: ~/.gradle/caches
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
# restore-keys: ${{ runner.os }}-gradle
#
# - name: Run android tests
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: ${{ matrix.api-level }}
# script: ./gradlew connectedCheck
test-android:
# macos has hardware acceleration. See android-emulator-runner action
runs-on: macos-latest
strategy:
matrix:
# api-level 19 is min sdk, but throws errors related to desugaring
api-level: [ 21, 29 ]
steps:
- uses: actions/checkout@v2

- name: set up JDK 8
uses: actions/setup-java@v2
with:
java-version: 8
distribution: "adopt"

- name: Cache Gradle dependencies
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle

- name: Run android tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
# workaround to emulator bug: https://github.com/ReactiveCircus/android-emulator-runner/issues/160
emulator-build: 7425822
script: ./gradlew connectedCheck

# sonar:
# runs-on: ubuntu-latest
Expand Down
40 changes: 20 additions & 20 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ apply plugin: 'kotlin-kapt'
apply plugin: 'checkstyle'

android {
compileSdkVersion 29
buildToolsVersion '29.0.3'
compileSdkVersion 30
buildToolsVersion '30.0.3'

defaultConfig {
applicationId "org.schabi.newpipe"
resValue "string", "app_name", "NewPipe"
minSdkVersion 19
targetSdkVersion 29
versionCode 974
versionName "0.21.8"
versionCode 975
versionName "0.21.9"

multiDexEnabled true

Expand Down Expand Up @@ -101,17 +101,17 @@ android {
ext {
checkstyleVersion = '8.38'

androidxLifecycleVersion = '2.2.0'
androidxLifecycleVersion = '2.3.1'
androidxRoomVersion = '2.3.0'

icepickVersion = '3.2.0'
exoPlayerVersion = '2.12.3'
googleAutoServiceVersion = '1.0-rc7'
googleAutoServiceVersion = '1.0'
groupieVersion = '2.8.1'
markwonVersion = '4.6.0'
markwonVersion = '4.6.2'

leakCanaryVersion = '2.5'
stethoVersion = '1.5.1'
stethoVersion = '1.6.0'
mockitoVersion = '3.6.0'
}

Expand All @@ -121,7 +121,7 @@ configurations {
}

checkstyle {
configDir rootProject.file(".")
getConfigDirectory().set(rootProject.file("."))
ignoreFailures false
showViolations true
toolVersion = checkstyleVersion
Expand All @@ -140,8 +140,8 @@ task runCheckstyle(type: Checkstyle) {
showViolations true

reports {
xml.enabled true
html.enabled true
xml.getRequired().set(true)
html.getRequired().set(true)
}
}

Expand All @@ -151,15 +151,15 @@ def inputFiles = project.fileTree(dir: "src", include: "**/*.kt")
task runKtlint(type: JavaExec) {
inputs.files(inputFiles)
outputs.dir(outputDir)
main = "com.pinterest.ktlint.Main"
getMainClass().set("com.pinterest.ktlint.Main")
classpath = configurations.ktlint
args "src/**/*.kt"
}

task formatKtlint(type: JavaExec) {
inputs.files(inputFiles)
outputs.dir(outputDir)
main = "com.pinterest.ktlint.Main"
getMainClass().set("com.pinterest.ktlint.Main")
classpath = configurations.ktlint
args "-F", "src/**/*.kt"
}
Expand All @@ -186,7 +186,7 @@ dependencies {
// name and the commit hash with the commit hash of the (pushed) commit you want to test
// This works thanks to JitPack: https://jitpack.io/
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.21.8'
implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.21.9'

/** Checkstyle **/
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"
Expand All @@ -196,16 +196,16 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}"

/** AndroidX **/
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.documentfile:documentfile:1.0.1'
implementation 'androidx.fragment:fragment-ktx:1.3.5'
implementation 'androidx.fragment:fragment-ktx:1.3.6'
implementation "androidx.lifecycle:lifecycle-livedata:${androidxLifecycleVersion}"
implementation "androidx.lifecycle:lifecycle-viewmodel:${androidxLifecycleVersion}"
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation 'androidx.media:media:1.2.1'
implementation 'androidx.media:media:1.3.1'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
Expand Down Expand Up @@ -237,8 +237,8 @@ dependencies {
kapt "com.google.auto.service:auto-service:${googleAutoServiceVersion}"

// Manager for complex RecyclerView layouts
implementation "com.xwray:groupie:${groupieVersion}"
implementation "com.xwray:groupie-viewbinding:${groupieVersion}"
implementation "com.github.lisawray.groupie:groupie:${groupieVersion}"
implementation "com.github.lisawray.groupie:groupie-viewbinding:${groupieVersion}"

// Circular ImageView
implementation "de.hdodenhof:circleimageview:3.1.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package org.schabi.newpipe.local.playlist

import androidx.room.Room
import androidx.test.core.app.ApplicationProvider
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.TrampolineSchedulerRule
import java.util.concurrent.TimeUnit

class LocalPlaylistManagerTest {

private lateinit var manager: LocalPlaylistManager
private lateinit var database: AppDatabase

@get:Rule
val trampolineScheduler = TrampolineSchedulerRule()

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

@Before
fun setup() {
database = Room.inMemoryDatabaseBuilder(
ApplicationProvider.getApplicationContext(),
AppDatabase::class.java
)
.allowMainThreadQueries()
.build()

manager = LocalPlaylistManager(database)
}

@After
fun cleanUp() {
database.close()
}

@Test
fun createPlaylist() {
val stream = StreamEntity(
serviceId = 1, url = "https://newpipe.net/", title = "title",
streamType = StreamType.VIDEO_STREAM, duration = 1, uploader = "uploader"
)

val result = manager.createPlaylist("name", listOf(stream))

// This should not behave like this.
// Currently list of all stream ids is returned instead of playlist id
result.test().await().assertValue(listOf(1L))
}

@Test
fun createPlaylist_emptyPlaylistMustReturnEmpty() {
val result = manager.createPlaylist("name", emptyList())

// This should not behave like this.
// It should throw an error because currently the result is null
result.test().await().assertComplete()
manager.playlists.test().awaitCount(1).assertValue(emptyList())
}

@Test()
fun createPlaylist_nonExistentStreamsAreUpserted() {
val stream = StreamEntity(
serviceId = 1, url = "https://newpipe.net/", title = "title",
streamType = StreamType.VIDEO_STREAM, duration = 1, uploader = "uploader"
)
database.streamDAO().insert(stream)
val upserted = StreamEntity(
serviceId = 1, url = "https://newpipe.net/2", title = "title2",
streamType = StreamType.VIDEO_STREAM, duration = 1, uploader = "uploader"
)

val result = manager.createPlaylist("name", listOf(stream, upserted))

result.test().await().assertComplete()
database.streamDAO().all.test().awaitCount(1).assertValue(listOf(stream, upserted))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.schabi.newpipe.testUtil

import io.reactivex.rxjava3.android.plugins.RxAndroidPlugins
import io.reactivex.rxjava3.plugins.RxJavaPlugins
import io.reactivex.rxjava3.schedulers.Schedulers
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement

/**
* Always run on [Schedulers.trampoline].
* This executes the task in the current thread in FIFO manner.
* This ensures that tasks are run quickly inside the tests
* and not scheduled away to another thread for later execution
*/
class TrampolineSchedulerRule : TestRule {

private val scheduler = Schedulers.trampoline()

override fun apply(base: Statement, description: Description): Statement =
object : Statement() {
override fun evaluate() {
try {
RxJavaPlugins.setComputationSchedulerHandler { scheduler }
RxJavaPlugins.setIoSchedulerHandler { scheduler }
RxJavaPlugins.setNewThreadSchedulerHandler { scheduler }
RxJavaPlugins.setSingleSchedulerHandler { scheduler }
RxAndroidPlugins.setInitMainThreadSchedulerHandler { scheduler }

base.evaluate()
} finally {
RxJavaPlugins.reset()
RxAndroidPlugins.reset()
}
}
}
}
Loading