Skip to content

Commit cd95ec4

Browse files
committed
Merge branch 'dev' into pr2335
2 parents fcd2d63 + ee19ea6 commit cd95ec4

107 files changed

Lines changed: 1426 additions & 824 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
java-version: 11
4040
distribution: "temurin"
4141
cache: 'gradle'
42-
42+
4343
- name: Build debug APK and run jvm tests
4444
run: ./gradlew assembleDebug lintDebug testDebugUnitTest --stacktrace -DskipFormatKtlint
4545

@@ -54,7 +54,7 @@ jobs:
5454
runs-on: macos-latest
5555
strategy:
5656
matrix:
57-
# api-level 19 is min sdk, but throws errors related to desugaring
57+
# api-level 19 is min sdk, but throws errors related to desugaring
5858
api-level: [ 21, 29 ]
5959
steps:
6060
- uses: actions/checkout@v2
@@ -72,31 +72,31 @@ jobs:
7272
api-level: ${{ matrix.api-level }}
7373
# workaround to emulator bug: https://github.com/ReactiveCircus/android-emulator-runner/issues/160
7474
emulator-build: 7425822
75-
script: ./gradlew connectedCheck
75+
script: ./gradlew connectedCheck --stacktrace
7676

77-
# sonar:
78-
# runs-on: ubuntu-latest
79-
# steps:
80-
# - uses: actions/checkout@v2
81-
# with:
82-
# fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
77+
sonar:
78+
runs-on: ubuntu-latest
79+
steps:
80+
- uses: actions/checkout@v2
81+
with:
82+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
8383

84-
# - name: Set up JDK 11
85-
# uses: actions/setup-java@v2
86-
# with:
87-
# java-version: 11 # Sonar requires JDK 11
88-
# distribution: "temurin"
89-
# cache: 'gradle'
84+
- name: Set up JDK 11
85+
uses: actions/setup-java@v2
86+
with:
87+
java-version: 11 # Sonar requires JDK 11
88+
distribution: "temurin"
89+
cache: 'gradle'
9090

91-
# - name: Cache SonarCloud packages
92-
# uses: actions/cache@v2
93-
# with:
94-
# path: ~/.sonar/cache
95-
# key: ${{ runner.os }}-sonar
96-
# restore-keys: ${{ runner.os }}-sonar
91+
- name: Cache SonarCloud packages
92+
uses: actions/cache@v2
93+
with:
94+
path: ~/.sonar/cache
95+
key: ${{ runner.os }}-sonar
96+
restore-keys: ${{ runner.os }}-sonar
9797

98-
# - name: Build and analyze
99-
# env:
100-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
101-
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
102-
# run: ./gradlew build sonarqube --info
98+
- name: Build and analyze
99+
env:
100+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
101+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
102+
run: ./gradlew build sonarqube --info

README.ja.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<p align="center"><a href="https://newpipe.net">ウェブサイト</a> &bull; <a href="https://newpipe.net/blog/">ブログ</a> &bull; <a href="https://newpipe.net/FAQ/">FAQ</a> &bull; <a href="https://newpipe.net/press/">ニュース</a></p>
1818
<hr>
1919

20-
*他の言語で読む: [English](README.md), [Español](README.es.md), [한국어](README.ko.md), [Soomaali](README.so.md), [Português Brasil](README.pt.br.md), [日本語](README.ja.md), [Română](README.ro.md), [Türkçe](README.tr.md)*
20+
*他の言語で読む: [English](README.md), [Español](README.es.md), [한국어](README.ko.md), [Soomaali](README.so.md), [Português Brasil](README.pt_BR.md), [日本語](README.ja.md), [Română](README.ro.md), [Türkçe](README.tr.md)*
2121

2222
<b>注意: これはベータ版のため、バグが発生する可能性があります。もしバグが発生した場合、GitHub のリポジトリで Issue を開いてください。</b>
2323

app/build.gradle

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
plugins {
2-
id "org.sonarqube" version "3.1.1"
2+
id "com.android.application"
3+
id "kotlin-android"
4+
id "kotlin-kapt"
5+
id "kotlin-parcelize"
6+
id "checkstyle"
7+
id "org.sonarqube" version "3.3"
38
}
49

5-
apply plugin: 'com.android.application'
6-
apply plugin: 'kotlin-android'
7-
apply plugin: 'kotlin-parcelize'
8-
apply plugin: 'kotlin-kapt'
9-
apply plugin: 'checkstyle'
10-
1110
android {
1211
compileSdkVersion 30
1312
buildToolsVersion '30.0.3'
@@ -17,8 +16,8 @@ android {
1716
resValue "string", "app_name", "NewPipe"
1817
minSdkVersion 19
1918
targetSdkVersion 29
20-
versionCode 979
21-
versionName "0.21.13"
19+
versionCode 981
20+
versionName "0.21.15"
2221

2322
multiDexEnabled true
2423

@@ -80,13 +79,13 @@ android {
8079
// Flag to enable support for the new language APIs
8180
coreLibraryDesugaringEnabled true
8281

83-
sourceCompatibility JavaVersion.VERSION_1_8
84-
targetCompatibility JavaVersion.VERSION_1_8
82+
sourceCompatibility JavaVersion.VERSION_11
83+
targetCompatibility JavaVersion.VERSION_11
8584
encoding 'utf-8'
8685
}
8786

8887
kotlinOptions {
89-
jvmTarget = JavaVersion.VERSION_1_8
88+
jvmTarget = JavaVersion.VERSION_11
9089
}
9190

9291
sourceSets {
@@ -99,21 +98,21 @@ android {
9998
}
10099

101100
ext {
102-
checkstyleVersion = '8.38'
101+
checkstyleVersion = '9.2'
103102

104103
androidxLifecycleVersion = '2.3.1'
105104
androidxRoomVersion = '2.3.0'
106105
androidxWorkVersion = '2.5.0'
107106

108107
icepickVersion = '3.2.0'
109108
exoPlayerVersion = '2.14.2'
110-
googleAutoServiceVersion = '1.0'
109+
googleAutoServiceVersion = '1.0.1'
111110
groupieVersion = '2.10.0'
112111
markwonVersion = '4.6.2'
113112

114113
leakCanaryVersion = '2.5'
115114
stethoVersion = '1.6.0'
116-
mockitoVersion = '3.6.0'
115+
mockitoVersion = '4.0.0'
117116
}
118117

119118
configurations {
@@ -190,19 +189,19 @@ dependencies {
190189
// name and the commit hash with the commit hash of the (pushed) commit you want to test
191190
// This works thanks to JitPack: https://jitpack.io/
192191
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
193-
implementation 'com.github.TeamNewPipe:NewPipeExtractor:f6f2724634'
192+
implementation 'com.github.TeamNewPipe:NewPipeExtractor:10f6cc71'
194193

195194
/** Checkstyle **/
196195
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"
197-
ktlint 'com.pinterest:ktlint:0.40.0'
196+
ktlint 'com.pinterest:ktlint:0.43.2'
198197

199198
/** Kotlin **/
200199
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}"
201200

202201
/** AndroidX **/
203202
implementation 'androidx.appcompat:appcompat:1.3.1'
204203
implementation 'androidx.cardview:cardview:1.0.0'
205-
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
204+
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
206205
implementation 'androidx.core:core-ktx:1.6.0'
207206
implementation 'androidx.documentfile:documentfile:1.0.1'
208207
implementation 'androidx.fragment:fragment-ktx:1.3.6'
@@ -221,7 +220,7 @@ dependencies {
221220
// https://developer.android.com/jetpack/androidx/releases/viewpager2#1.1.0-alpha01
222221
implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01'
223222
implementation 'androidx.webkit:webkit:1.4.0'
224-
implementation 'com.google.android.material:material:1.2.1'
223+
implementation 'com.google.android.material:material:1.4.0'
225224
implementation "androidx.work:work-runtime-ktx:${androidxWorkVersion}"
226225
implementation "androidx.work:work-rxjava3:${androidxWorkVersion}"
227226

@@ -231,7 +230,7 @@ dependencies {
231230
kapt "frankiesardo:icepick-processor:${icepickVersion}"
232231

233232
// HTML parser
234-
implementation "org.jsoup:jsoup:1.13.1"
233+
implementation "org.jsoup:jsoup:1.14.3"
235234

236235
// HTTP client
237236
//noinspection GradleDependency --> do not update okhttp to keep supporting Android 4.4 users
@@ -269,13 +268,13 @@ dependencies {
269268
implementation 'com.jakewharton:process-phoenix:2.1.2'
270269

271270
// Reactive extensions for Java VM
272-
implementation "io.reactivex.rxjava3:rxjava:3.0.7"
271+
implementation "io.reactivex.rxjava3:rxjava:3.0.13"
273272
implementation "io.reactivex.rxjava3:rxandroid:3.0.0"
274273
// RxJava binding APIs for Android UI widgets
275274
implementation "com.jakewharton.rxbinding4:rxbinding:4.0.0"
276275

277276
// Date and time formatting
278-
implementation "org.ocpsoft.prettytime:prettytime:5.0.1.Final"
277+
implementation "org.ocpsoft.prettytime:prettytime:5.0.2.Final"
279278

280279
/** Debugging **/
281280
// Memory leak detection
@@ -291,11 +290,9 @@ dependencies {
291290
testImplementation "org.mockito:mockito-core:${mockitoVersion}"
292291
testImplementation "org.mockito:mockito-inline:${mockitoVersion}"
293292

294-
androidTestImplementation "androidx.test.ext:junit:1.1.2"
293+
androidTestImplementation "androidx.test.ext:junit:1.1.3"
294+
androidTestImplementation "androidx.test:runner:1.4.0"
295295
androidTestImplementation "androidx.room:room-testing:${androidxRoomVersion}"
296-
androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0", {
297-
exclude module: 'support-annotations'
298-
}
299296
}
300297

301298
static String getGitWorkingBranch() {
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
package org.schabi.newpipe.local.history
2+
3+
import androidx.test.core.app.ApplicationProvider
4+
import org.junit.After
5+
import org.junit.Assert.assertEquals
6+
import org.junit.Assert.assertTrue
7+
import org.junit.Before
8+
import org.junit.Rule
9+
import org.junit.Test
10+
import org.junit.rules.Timeout
11+
import org.schabi.newpipe.database.AppDatabase
12+
import org.schabi.newpipe.database.history.model.SearchHistoryEntry
13+
import org.schabi.newpipe.testUtil.TestDatabase
14+
import org.schabi.newpipe.testUtil.TrampolineSchedulerRule
15+
import java.time.OffsetDateTime
16+
import java.util.concurrent.TimeUnit
17+
18+
class HistoryRecordManagerTest {
19+
20+
private lateinit var manager: HistoryRecordManager
21+
private lateinit var database: AppDatabase
22+
23+
@get:Rule
24+
val trampolineScheduler = TrampolineSchedulerRule()
25+
26+
@get:Rule
27+
val timeout = Timeout(1, TimeUnit.SECONDS)
28+
29+
@Before
30+
fun setup() {
31+
database = TestDatabase.createReplacingNewPipeDatabase()
32+
manager = HistoryRecordManager(ApplicationProvider.getApplicationContext())
33+
}
34+
35+
@After
36+
fun cleanUp() {
37+
database.close()
38+
}
39+
40+
@Test
41+
fun onSearched() {
42+
manager.onSearched(0, "Hello").test().await().assertValue(1)
43+
44+
// For some reason the Flowable returned by getAll() never completes, so we can't assert
45+
// that the number of Lists it returns is exactly 1, we can only check if the first List is
46+
// correct. Why on earth has a Flowable been used instead of a Single for getAll()?!?
47+
val entities = database.searchHistoryDAO().all.blockingFirst()
48+
assertEquals(1, entities.size)
49+
assertEquals(1, entities[0].id)
50+
assertEquals(0, entities[0].serviceId)
51+
assertEquals("Hello", entities[0].search)
52+
}
53+
54+
@Test
55+
fun deleteSearchHistory() {
56+
val entries = listOf(
57+
SearchHistoryEntry(OffsetDateTime.now(), 0, "A"),
58+
SearchHistoryEntry(OffsetDateTime.now(), 2, "A"),
59+
SearchHistoryEntry(OffsetDateTime.now(), 1, "B"),
60+
SearchHistoryEntry(OffsetDateTime.now(), 0, "B"),
61+
)
62+
63+
// make sure all 4 were inserted
64+
database.searchHistoryDAO().insertAll(entries)
65+
assertEquals(entries.size, database.searchHistoryDAO().all.blockingFirst().size)
66+
67+
// try to delete only "A" entries, "B" entries should be untouched
68+
manager.deleteSearchHistory("A").test().await().assertValue(2)
69+
val entities = database.searchHistoryDAO().all.blockingFirst()
70+
assertEquals(2, entities.size)
71+
assertTrue(entries[2].hasEqualValues(entities[0]))
72+
assertTrue(entries[3].hasEqualValues(entities[1]))
73+
74+
// assert that nothing happens if we delete a search query that does exist in the db
75+
manager.deleteSearchHistory("A").test().await().assertValue(0)
76+
val entities2 = database.searchHistoryDAO().all.blockingFirst()
77+
assertEquals(2, entities2.size)
78+
assertTrue(entries[2].hasEqualValues(entities2[0]))
79+
assertTrue(entries[3].hasEqualValues(entities2[1]))
80+
81+
// delete all remaining entries
82+
manager.deleteSearchHistory("B").test().await().assertValue(2)
83+
assertEquals(0, database.searchHistoryDAO().all.blockingFirst().size)
84+
}
85+
86+
@Test
87+
fun deleteCompleteSearchHistory() {
88+
val entries = listOf(
89+
SearchHistoryEntry(OffsetDateTime.now(), 1, "A"),
90+
SearchHistoryEntry(OffsetDateTime.now(), 2, "B"),
91+
SearchHistoryEntry(OffsetDateTime.now(), 0, "C"),
92+
)
93+
94+
// make sure all 3 were inserted
95+
database.searchHistoryDAO().insertAll(entries)
96+
assertEquals(entries.size, database.searchHistoryDAO().all.blockingFirst().size)
97+
98+
// should remove everything
99+
manager.deleteCompleteSearchHistory().test().await().assertValue(entries.size)
100+
assertEquals(0, database.searchHistoryDAO().all.blockingFirst().size)
101+
}
102+
103+
@Test
104+
fun getRelatedSearches_emptyQuery() {
105+
// make sure all entries were inserted
106+
database.searchHistoryDAO().insertAll(RELATED_SEARCHES_ENTRIES)
107+
assertEquals(
108+
RELATED_SEARCHES_ENTRIES.size,
109+
database.searchHistoryDAO().all.blockingFirst().size
110+
)
111+
112+
// make sure correct number of searches is returned and in correct order
113+
val searches = manager.getRelatedSearches("", 6, 4).blockingFirst()
114+
assertEquals(4, searches.size)
115+
assertEquals(RELATED_SEARCHES_ENTRIES[6].search, searches[0]) // A (even if in two places)
116+
assertEquals(RELATED_SEARCHES_ENTRIES[4].search, searches[1]) // B
117+
assertEquals(RELATED_SEARCHES_ENTRIES[5].search, searches[2]) // AA
118+
assertEquals(RELATED_SEARCHES_ENTRIES[2].search, searches[3]) // BA
119+
}
120+
121+
@Test
122+
fun getRelatedSearched_nonEmptyQuery() {
123+
// make sure all entries were inserted
124+
database.searchHistoryDAO().insertAll(RELATED_SEARCHES_ENTRIES)
125+
assertEquals(
126+
RELATED_SEARCHES_ENTRIES.size,
127+
database.searchHistoryDAO().all.blockingFirst().size
128+
)
129+
130+
// make sure correct number of searches is returned and in correct order
131+
val searches = manager.getRelatedSearches("A", 3, 5).blockingFirst()
132+
assertEquals(3, searches.size)
133+
assertEquals(RELATED_SEARCHES_ENTRIES[6].search, searches[0]) // A (even if in two places)
134+
assertEquals(RELATED_SEARCHES_ENTRIES[5].search, searches[1]) // AA
135+
assertEquals(RELATED_SEARCHES_ENTRIES[1].search, searches[2]) // BA
136+
137+
// also make sure that the string comparison is case insensitive
138+
val searches2 = manager.getRelatedSearches("a", 3, 5).blockingFirst()
139+
assertEquals(searches, searches2)
140+
}
141+
142+
companion object {
143+
val RELATED_SEARCHES_ENTRIES = listOf(
144+
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(7), 2, "AC"),
145+
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(6), 0, "ABC"),
146+
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(5), 1, "BA"),
147+
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(4), 3, "A"),
148+
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(2), 0, "B"),
149+
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(3), 2, "AA"),
150+
SearchHistoryEntry(OffsetDateTime.now().minusSeconds(1), 1, "A"),
151+
)
152+
}
153+
}

0 commit comments

Comments
 (0)