mirror of
https://github.com/nextcloud/talk-android
synced 2025-02-01 20:22:03 +00:00
update test cases
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
55585e9ef0
commit
d3286bf6bc
@ -2,7 +2,10 @@ package com.nextcloud.talk.activities
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import com.nextcloud.talk.data.user.model.UserNgEntity
|
||||
import org.junit.Assert.assertTrue
|
||||
import com.nextcloud.talk.users.UserManager
|
||||
import io.reactivex.Observer
|
||||
import io.reactivex.disposables.Disposable
|
||||
import org.junit.Assert.fail
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
@ -15,39 +18,41 @@ class MainActivityTest {
|
||||
)
|
||||
|
||||
@Test
|
||||
suspend fun login() {
|
||||
fun login() {
|
||||
val sut = activityRule.launchActivity(null)
|
||||
|
||||
sut.usersRepository.insertUser(
|
||||
UserNgEntity(
|
||||
0,
|
||||
"test",
|
||||
"test",
|
||||
"http://server/nc",
|
||||
"test",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
scheduledForDeletion = false
|
||||
sut.userManager.createOrUpdateUser(
|
||||
"test",
|
||||
UserManager.UserAttributes(
|
||||
id = 0,
|
||||
serverUrl = "http://server/nc",
|
||||
currentUser = false,
|
||||
userId = "test",
|
||||
token = "test",
|
||||
displayName = null,
|
||||
pushConfigurationState = null,
|
||||
capabilities = null,
|
||||
certificateAlias = null,
|
||||
externalSignalingServer = null
|
||||
)
|
||||
)
|
||||
).subscribe(object : Observer<UserNgEntity?> {
|
||||
override fun onSubscribe(d: Disposable) {
|
||||
// unused atm
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(2000)
|
||||
} catch (e: InterruptedException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
override fun onNext(user: UserNgEntity) {
|
||||
sut.runOnUiThread { sut.resetConversationsList() }
|
||||
|
||||
sut.runOnUiThread { sut.resetConversationsList() }
|
||||
println("User: " + user.id + " / " + user.userId + " / " + user.baseUrl)
|
||||
}
|
||||
|
||||
assertTrue(sut.usersRepository.getUserWithUsernameAndServer("test", "http://server/nc") != null)
|
||||
override fun onError(e: Throwable) {
|
||||
fail("No user created")
|
||||
}
|
||||
|
||||
try {
|
||||
} catch (e: InterruptedException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
override fun onComplete() {
|
||||
// unused atm
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -143,10 +143,7 @@ public class LoginIT {
|
||||
onView(withId(R.id.user_name)).check(matches(withText("User One")));
|
||||
|
||||
activityScenario.onActivity(activity -> {
|
||||
assertEquals(loginName, Objects.requireNonNull(activity.usersRepository.getActiveUser()).getUserId());
|
||||
assertEquals(loginName, Objects.requireNonNull(activity.userManager.getCurrentUser()).getUserId());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -303,6 +303,10 @@ class UserManager internal constructor(private val userRepository: UsersReposito
|
||||
return userRepository.getUserWithIdLiveData(user!!.id)
|
||||
}
|
||||
|
||||
fun getUserWithUsernameAndServer(username: String, server: String): Observable<UserNgEntity?> {
|
||||
return userRepository.getUserWithUsernameAndServer(username, server)
|
||||
}
|
||||
|
||||
private fun updateUserData(user: UserNgEntity, userAttributes: UserAttributes) {
|
||||
updateUserIdIfNeeded(userAttributes, user)
|
||||
updateTokenIfNeeded(userAttributes, user)
|
||||
|
Loading…
Reference in New Issue
Block a user