87 lines
2.9 KiB
Kotlin
87 lines
2.9 KiB
Kotlin
package it.unisannio.ding.ids.wedroid.app.view
|
|
|
|
import androidx.test.espresso.Espresso.closeSoftKeyboard
|
|
import androidx.test.espresso.Espresso.onView
|
|
import androidx.test.espresso.action.ViewActions.click
|
|
import androidx.test.espresso.action.ViewActions.typeText
|
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
|
import androidx.test.espresso.matcher.RootMatchers.withDecorView
|
|
import androidx.test.espresso.matcher.ViewMatchers.*
|
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
import androidx.test.filters.LargeTest
|
|
import androidx.test.rule.ActivityTestRule
|
|
import it.unisannio.ding.ids.wedroid.app.R
|
|
import org.hamcrest.CoreMatchers.not
|
|
import org.junit.Rule
|
|
import org.junit.Test
|
|
import org.junit.runner.RunWith
|
|
|
|
@RunWith(AndroidJUnit4::class)
|
|
@LargeTest
|
|
class LoginActivityTest {
|
|
@get:Rule
|
|
val activityRule = ActivityTestRule(LoginActivity::class.java)
|
|
|
|
@Test
|
|
fun loginWithEmptyUrl() {
|
|
onView(withId(R.id.username))
|
|
.perform(typeText("username"))
|
|
onView(withId(R.id.password))
|
|
.perform(typeText("password"))
|
|
closeSoftKeyboard()
|
|
onView(withId(R.id.button))
|
|
.perform(click())
|
|
|
|
onView(withText(R.string.login_empty_field))
|
|
.inRoot(withDecorView(not(activityRule.activity.window.decorView)))
|
|
.check(matches(isDisplayed()))
|
|
}
|
|
|
|
@Test
|
|
fun loginWithEmptyUsername() {
|
|
onView(withId(R.id.instanceServer))
|
|
.perform(typeText("https://wekan.com"))
|
|
onView(withId(R.id.password))
|
|
.perform(typeText("password"))
|
|
closeSoftKeyboard()
|
|
onView(withId(R.id.button))
|
|
.perform(click())
|
|
|
|
onView(withText(R.string.login_empty_field))
|
|
.inRoot(withDecorView(not(activityRule.activity.window.decorView)))
|
|
.check(matches(isDisplayed()))
|
|
|
|
}
|
|
|
|
@Test
|
|
fun loginWithEmptyPassword() {
|
|
onView(withId(R.id.instanceServer))
|
|
.perform(typeText("https://wekan.com"))
|
|
onView(withId(R.id.username))
|
|
.perform(typeText("username"))
|
|
closeSoftKeyboard()
|
|
onView(withId(R.id.button))
|
|
.perform(click())
|
|
|
|
onView(withText(R.string.login_empty_field))
|
|
.inRoot(withDecorView(not(activityRule.activity.window.decorView)))
|
|
.check(matches(isDisplayed()))
|
|
}
|
|
|
|
@Test
|
|
fun loginWithUnformedInstance(){
|
|
onView(withId(R.id.instanceServer))
|
|
.perform(typeText("not an URL"))
|
|
onView(withId(R.id.username))
|
|
.perform(typeText("username"))
|
|
onView(withId(R.id.password))
|
|
.perform(typeText("password"))
|
|
closeSoftKeyboard()
|
|
onView(withId(R.id.button))
|
|
.perform(click())
|
|
|
|
onView(withText(R.string.login_unformed_instance))
|
|
.inRoot(withDecorView(not(activityRule.activity.window.decorView)))
|
|
.check(matches(isDisplayed()))
|
|
}
|
|
} |