mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-21 12:39:58 +01:00
initial idea to login in during tests
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
aaa9567c19
commit
5ad48b3757
@ -159,6 +159,7 @@ ext {
|
|||||||
retrofit2Version = "2.9.0"
|
retrofit2Version = "2.9.0"
|
||||||
workVersion = "2.6.0"
|
workVersion = "2.6.0"
|
||||||
markwonVersion = "4.6.2"
|
markwonVersion = "4.6.2"
|
||||||
|
espressoVersion = "3.4.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations.all {
|
configurations.all {
|
||||||
@ -296,6 +297,13 @@ dependencies {
|
|||||||
testImplementation "org.powermock:powermock-module-junit4:${powermockVersion}"
|
testImplementation "org.powermock:powermock-module-junit4:${powermockVersion}"
|
||||||
testImplementation "org.powermock:powermock-api-mockito2:${powermockVersion}"
|
testImplementation "org.powermock:powermock-api-mockito2:${powermockVersion}"
|
||||||
|
|
||||||
|
// Espresso core
|
||||||
|
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
|
||||||
|
androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
|
||||||
|
androidTestImplementation "androidx.test.espresso:espresso-web:$espressoVersion"
|
||||||
|
androidTestImplementation "androidx.test.espresso:espresso-accessibility:$espressoVersion"
|
||||||
|
androidTestImplementation('com.android.support.test.espresso:espresso-intents:3.0.2')
|
||||||
|
|
||||||
androidTestImplementation ('androidx.test.espresso:espresso-core:3.4.0', {
|
androidTestImplementation ('androidx.test.espresso:espresso-core:3.4.0', {
|
||||||
exclude group: 'com.android.support', module: 'support-annotations'
|
exclude group: 'com.android.support', module: 'support-annotations'
|
||||||
})
|
})
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
package com.nextcloud.talk.activities
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||||
|
import com.nextcloud.talk.models.database.UserEntity
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
|
import io.reactivex.schedulers.Schedulers
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class MainActivityTest {
|
||||||
|
@get:Rule
|
||||||
|
val activityRule: IntentsTestRule<MainActivity> = IntentsTestRule(
|
||||||
|
MainActivity::class.java,
|
||||||
|
true,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun login() {
|
||||||
|
val sut = activityRule.launchActivity(null)
|
||||||
|
sut.userUtils.createOrUpdateUser(
|
||||||
|
"test",
|
||||||
|
"test",
|
||||||
|
"http://10.0.2.2/nc",
|
||||||
|
"test",
|
||||||
|
null,
|
||||||
|
true,
|
||||||
|
"test",
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(
|
||||||
|
{ userEntity: UserEntity? -> Log.i("test", "stored: " + userEntity.toString()) },
|
||||||
|
{ throwable: Throwable? -> Log.e("test", "throwable") },
|
||||||
|
{ Log.d("test", "complete") }
|
||||||
|
)
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(2000)
|
||||||
|
} catch (e: InterruptedException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
sut.runOnUiThread { sut.resetConversationsList() }
|
||||||
|
|
||||||
|
assertTrue(sut.userUtils.getIfUserWithUsernameAndServer("test", "http://10.0.2.2/nc"))
|
||||||
|
|
||||||
|
try {
|
||||||
|
} catch (e: InterruptedException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -268,7 +268,7 @@ public class UserUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return dataStore.upsert(user)
|
return dataStore.upsert(user)
|
||||||
.toObservable()
|
.toObservable()
|
||||||
.subscribeOn(Schedulers.io());
|
.subscribeOn(Schedulers.io());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user