fix #23
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
noemi3 2020-01-07 11:04:15 +01:00
parent ac590e418d
commit 82ee1f5f7e
3 changed files with 35 additions and 12 deletions

View File

@ -32,7 +32,7 @@ class LoginActivityTest {
onView(withId(R.id.button)) onView(withId(R.id.button))
.perform(click()) .perform(click())
onView(withText("Riempire tutti i campi")) onView(withText(R.string.login_empty_field))
.inRoot(withDecorView(not(activityRule.activity.window.decorView))) .inRoot(withDecorView(not(activityRule.activity.window.decorView)))
.check(matches(isDisplayed())) .check(matches(isDisplayed()))
} }
@ -40,13 +40,14 @@ class LoginActivityTest {
@Test @Test
fun loginWithEmptyUsername() { fun loginWithEmptyUsername() {
onView(withId(R.id.instanceServer)) onView(withId(R.id.instanceServer))
.perform(typeText("instanceServer")) .perform(typeText("https://wekan.com"))
onView(withId(R.id.password)) onView(withId(R.id.password))
.perform(typeText("password")) .perform(typeText("password"))
closeSoftKeyboard() closeSoftKeyboard()
onView(withId(R.id.button)) onView(withId(R.id.button))
.perform(click()) .perform(click())
onView(withText("Riempire tutti i campi"))
onView(withText(R.string.login_empty_field))
.inRoot(withDecorView(not(activityRule.activity.window.decorView))) .inRoot(withDecorView(not(activityRule.activity.window.decorView)))
.check(matches(isDisplayed())) .check(matches(isDisplayed()))
@ -55,15 +56,32 @@ class LoginActivityTest {
@Test @Test
fun loginWithEmptyPassword() { fun loginWithEmptyPassword() {
onView(withId(R.id.instanceServer)) onView(withId(R.id.instanceServer))
.perform(typeText("instanceServer")) .perform(typeText("https://wekan.com"))
onView(withId(R.id.username)) onView(withId(R.id.username))
.perform(typeText("username")) .perform(typeText("username"))
closeSoftKeyboard() closeSoftKeyboard()
onView(withId(R.id.button)) onView(withId(R.id.button))
.perform(click()) .perform(click())
onView(withText("Riempire tutti i campi"))
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))) .inRoot(withDecorView(not(activityRule.activity.window.decorView)))
.check(matches(isDisplayed())) .check(matches(isDisplayed()))
} }
} }

View File

@ -33,7 +33,7 @@ class LoginActivity : AppCompatActivity() {
fun loginButton(v: View) { fun loginButton(v: View) {
if (username.text.isBlank() || instanceServer.text.isBlank() || password.text.isBlank()) { if (username.text.isBlank() || instanceServer.text.isBlank() || password.text.isBlank()) {
Toast.makeText(this, "Riempire tutti i campi", Toast.LENGTH_LONG) Toast.makeText(this, R.string.login_empty_field, Toast.LENGTH_LONG)
.show() .show()
return return
} }
@ -43,9 +43,9 @@ class LoginActivity : AppCompatActivity() {
val instanceServerText = instanceServer.text.toString() val instanceServerText = instanceServer.text.toString()
if (!URLUtil.isValidUrl(instanceServerText)){ if (!URLUtil.isValidUrl(instanceServerText)){
Toast.makeText(this, "Formato URL non valido", Toast.LENGTH_LONG) Toast.makeText(this, R.string.login_unformed_instance, Toast.LENGTH_LONG)
.show() .show()
return return
} }
val service = Retrofit.Builder() val service = Retrofit.Builder()
@ -58,7 +58,7 @@ class LoginActivity : AppCompatActivity() {
override fun onFailure(call: Call<UserPrototype>, t: Throwable) { override fun onFailure(call: Call<UserPrototype>, t: Throwable) {
Toast.makeText( Toast.makeText(
applicationContext, applicationContext,
"Controlla la tua connessione internet", R.string.login_network_error,
Toast.LENGTH_LONG Toast.LENGTH_LONG
).show() ).show()
} }
@ -68,7 +68,7 @@ class LoginActivity : AppCompatActivity() {
if (response.code() != 200) { if (response.code() != 200) {
Toast.makeText( Toast.makeText(
applicationContext, applicationContext,
"Credenziali non corrette", R.string.login_wrong_field,
Toast.LENGTH_LONG Toast.LENGTH_LONG
).show() ).show()
return return
@ -80,7 +80,7 @@ class LoginActivity : AppCompatActivity() {
Toast.makeText( Toast.makeText(
applicationContext, applicationContext,
"Login effettuato con successo", R.string.login_success,
Toast.LENGTH_LONG Toast.LENGTH_LONG
).show() ).show()

View File

@ -8,4 +8,9 @@
<string name="new_board_done_button">Done</string> <string name="new_board_done_button">Done</string>
<string name="on_null_new_board_name">There was a problem with the name of the new board</string> <string name="on_null_new_board_name">There was a problem with the name of the new board</string>
<string name="on_add_new_board_error">It was not possible to add a new board</string> <string name="on_add_new_board_error">It was not possible to add a new board</string>
<string name="login_empty_field">Riempire tutti i campi</string>
<string name="login_unformed_instance">Formato URL non valido</string>
<string name="login_network_error">Controlla la tua connessione internet</string>
<string name="login_wrong_field">Credenziali non corrette</string>
<string name="login_success">Login effettuato con successo</string>
</resources> </resources>