-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Autoconvert the rest to Kotlin as well
- Loading branch information
Showing
28 changed files
with
1,494 additions
and
1,656 deletions.
There are no files selected for viewing
46 changes: 0 additions & 46 deletions
46
app/src/androidTest/java/org/schabi/newpipe/error/ErrorInfoTest.java
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
app/src/androidTest/java/org/schabi/newpipe/error/ErrorInfoTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.schabi.newpipe.error | ||
|
||
import android.os.Parcel | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.filters.LargeTest | ||
import org.junit.Assert | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.schabi.newpipe.R | ||
import org.schabi.newpipe.extractor.ServiceList | ||
import org.schabi.newpipe.extractor.exceptions.ParsingException | ||
|
||
/** | ||
* Instrumented tests for [ErrorInfo]. | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
@LargeTest | ||
class ErrorInfoTest { | ||
@Test | ||
fun errorInfoTestParcelable() { | ||
val info = ErrorInfo(ParsingException("Hello"), | ||
UserAction.USER_REPORT, "request", ServiceList.YouTube.serviceId) | ||
// Obtain a Parcel object and write the parcelable object to it: | ||
val parcel = Parcel.obtain() | ||
info.writeToParcel(parcel, 0) | ||
parcel.setDataPosition(0) | ||
val infoFromParcel = ErrorInfo.CREATOR.createFromParcel(parcel) as ErrorInfo | ||
Assert.assertTrue(infoFromParcel.stackTraces.contentToString().contains(ErrorInfoTest::class.java.getSimpleName())) | ||
Assert.assertEquals(UserAction.USER_REPORT, infoFromParcel.userAction) | ||
Assert.assertEquals(ServiceList.YouTube.serviceInfo.name, | ||
infoFromParcel.serviceName) | ||
Assert.assertEquals("request", infoFromParcel.request) | ||
Assert.assertEquals(R.string.parsing_error.toLong(), infoFromParcel.messageStringId.toLong()) | ||
parcel.recycle() | ||
} | ||
} |
82 changes: 0 additions & 82 deletions
82
app/src/androidTest/java/org/schabi/newpipe/local/subscription/SubscriptionManagerTest.java
This file was deleted.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
app/src/androidTest/java/org/schabi/newpipe/local/subscription/SubscriptionManagerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package org.schabi.newpipe.local.subscription | ||
|
||
import androidx.test.core.app.ApplicationProvider | ||
import org.junit.After | ||
import org.junit.Assert | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.schabi.newpipe.database.AppDatabase | ||
import org.schabi.newpipe.database.feed.model.FeedGroupEntity | ||
import org.schabi.newpipe.database.subscription.SubscriptionEntity | ||
import org.schabi.newpipe.database.subscription.SubscriptionEntity.Companion.from | ||
import org.schabi.newpipe.extractor.channel.ChannelInfo | ||
import org.schabi.newpipe.extractor.exceptions.ExtractionException | ||
import org.schabi.newpipe.testUtil.TestDatabase.Companion.createReplacingNewPipeDatabase | ||
import org.schabi.newpipe.testUtil.TrampolineSchedulerRule | ||
import java.io.IOException | ||
|
||
class SubscriptionManagerTest { | ||
private var database: AppDatabase? = null | ||
private var manager: SubscriptionManager? = null | ||
|
||
@Rule | ||
var trampolineScheduler = TrampolineSchedulerRule() | ||
private val assertOneSubscriptionEntity: SubscriptionEntity | ||
private get() { | ||
val entities = manager | ||
.getSubscriptions(FeedGroupEntity.GROUP_ALL_ID, "", false) | ||
.blockingFirst() | ||
Assert.assertEquals(1, entities.size.toLong()) | ||
return entities[0] | ||
} | ||
|
||
@Before | ||
fun setup() { | ||
database = createReplacingNewPipeDatabase() | ||
manager = SubscriptionManager(ApplicationProvider.getApplicationContext()) | ||
} | ||
|
||
@After | ||
fun cleanUp() { | ||
database!!.close() | ||
} | ||
|
||
@Test | ||
@Throws(ExtractionException::class, IOException::class) | ||
fun testInsert() { | ||
val info = ChannelInfo.getInfo("https://www.youtube.com/c/3blue1brown") | ||
val subscription = from(info) | ||
manager!!.insertSubscription(subscription) | ||
val readSubscription = assertOneSubscriptionEntity | ||
|
||
// the uid has changed, since the uid is chosen upon inserting, but the rest should match | ||
Assert.assertEquals(subscription.getServiceId().toLong(), readSubscription.getServiceId().toLong()) | ||
Assert.assertEquals(subscription.getUrl(), readSubscription.getUrl()) | ||
Assert.assertEquals(subscription.getName(), readSubscription.getName()) | ||
Assert.assertEquals(subscription.getAvatarUrl(), readSubscription.getAvatarUrl()) | ||
Assert.assertEquals(subscription.getSubscriberCount(), readSubscription.getSubscriberCount()) | ||
Assert.assertEquals(subscription.getDescription(), readSubscription.getDescription()) | ||
} | ||
|
||
@Test | ||
@Throws(ExtractionException::class, IOException::class) | ||
fun testUpdateNotificationMode() { | ||
val info = ChannelInfo.getInfo("https://www.youtube.com/c/veritasium") | ||
val subscription = from(info) | ||
subscription.setNotificationMode(0) | ||
manager!!.insertSubscription(subscription) | ||
manager!!.updateNotificationMode(subscription.getServiceId(), subscription.getUrl()!!, 1) | ||
.blockingAwait() | ||
val anotherSubscription = assertOneSubscriptionEntity | ||
Assert.assertEquals(0, subscription.getNotificationMode().toLong()) | ||
Assert.assertEquals(subscription.getUrl(), anotherSubscription.getUrl()) | ||
Assert.assertEquals(1, anotherSubscription.getNotificationMode().toLong()) | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
app/src/debug/java/org/schabi/newpipe/settings/DebugSettingsBVDLeakCanary.java
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
app/src/debug/java/org/schabi/newpipe/settings/DebugSettingsBVDLeakCanary.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.schabi.newpipe.settings | ||
|
||
import android.content.Intent | ||
import leakcanary.LeakCanary.newLeakDisplayActivityIntent | ||
import org.schabi.newpipe.settings.DebugSettingsFragment.DebugSettingsBVDLeakCanaryAPI | ||
|
||
/** | ||
* Build variant dependent (BVD) leak canary API implementation for the debug settings fragment. | ||
* This class is loaded via reflection by | ||
* [DebugSettingsFragment.DebugSettingsBVDLeakCanaryAPI]. | ||
*/ | ||
@Suppress("unused") // Class is used but loaded via reflection | ||
|
||
class DebugSettingsBVDLeakCanary : DebugSettingsBVDLeakCanaryAPI { | ||
override fun getNewLeakDisplayActivityIntent(): Intent? { | ||
return newLeakDisplayActivityIntent() | ||
} | ||
} |
106 changes: 0 additions & 106 deletions
106
app/src/test/java/org/schabi/newpipe/database/playlist/PlaylistLocalItemTest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.