mirror of https://github.com/readrops/Readrops.git
Add test for OPML read case
This commit is contained in:
parent
b3dd60e1fb
commit
e92367bbc1
|
@ -18,6 +18,10 @@ android {
|
|||
abortOnError false
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
androidTest.assets.srcDirs += files("$projectDir/androidTest/assets".toString())
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled true
|
||||
|
@ -48,6 +52,7 @@ dependencies {
|
|||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<opml version="2.0">
|
||||
<body>
|
||||
<outline text="Folder 1" title="Folder 1">
|
||||
<outline text="Subfolder 1" title="SubFolder 1">
|
||||
<outline title="The Verge" xmlUrl='http://www.theverge.com/rss/index.xml' htmlUrl="http://www.theverge.com" />
|
||||
<outline title="TechCrunch" xmlUrl='https://techcrunch.com/feed/' htmlUrl="https://techcrunch.com/" />
|
||||
<outline xmlUrl='http://feeds.mashable.com/Mashable' />
|
||||
<outline xmlUrl='http://www.engadget.com/rss.xml' />
|
||||
</outline>
|
||||
|
||||
<outline text="Subfolder 2" title="Subfolder 2">
|
||||
<outline text="Sub subfolder 1" title="Sub subfolder 1">
|
||||
<outline title="The Verge" xmlUrl='http://www.theverge.com/rss/index.xml' htmlUrl="http://www.theverge.com" />
|
||||
<outline title="TechCrunch" xmlUrl='https://techcrunch.com/feed/' htmlUrl="https://techcrunch.com/" />
|
||||
</outline>
|
||||
<outline text="Sub subfolder 2" title="Sub subfolder 2">
|
||||
</outline>
|
||||
<outline xmlUrl='http://www.engadget.com/rss.xml' />
|
||||
</outline>
|
||||
<outline xmlUrl='http://feeds.mashable.com/Mashable' />
|
||||
<outline xmlUrl='http://www.engadget.com/rss.xml' />
|
||||
</outline>
|
||||
|
||||
<outline title="The Verge" xmlUrl='http://www.theverge.com/rss/index.xml' htmlUrl="http://www.theverge.com" />
|
||||
<outline title="TechCrunch" xmlUrl='https://techcrunch.com/feed/' htmlUrl="https://techcrunch.com/" />
|
||||
</body>
|
||||
</opml>
|
|
@ -0,0 +1,44 @@
|
|||
package com.readrops.api
|
||||
|
||||
import android.content.Context
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.readrops.api.opml.OPMLParser
|
||||
import com.readrops.db.entities.Feed
|
||||
import com.readrops.db.entities.Folder
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import junit.framework.TestCase.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class OPMLParserTest {
|
||||
|
||||
private val context: Context = InstrumentationRegistry.getInstrumentation().context
|
||||
|
||||
@Test
|
||||
fun readOpmlTest() {
|
||||
val stream = context.resources.assets.open("subscriptions.opml")
|
||||
|
||||
var foldersAndFeeds: Map<Folder?, List<Feed>>? = null
|
||||
|
||||
OPMLParser.read(stream)
|
||||
.observeOn(Schedulers.trampoline())
|
||||
.subscribeOn(Schedulers.trampoline())
|
||||
.subscribe { result -> foldersAndFeeds = result }
|
||||
|
||||
assertEquals(foldersAndFeeds?.size, 6)
|
||||
|
||||
assertEquals(foldersAndFeeds?.get(Folder("Folder 1"))?.size, 2)
|
||||
assertEquals(foldersAndFeeds?.get(Folder("Subfolder 1"))?.size, 4)
|
||||
assertEquals(foldersAndFeeds?.get(Folder("Subfolder 2"))?.size, 1)
|
||||
assertEquals(foldersAndFeeds?.get(Folder("Sub subfolder 1"))?.size, 2)
|
||||
assertEquals(foldersAndFeeds?.get(Folder("Sub subfolder 2"))?.size, 0)
|
||||
assertEquals(foldersAndFeeds?.get(null)?.size, 2)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun writeOpmlTest() {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue