release 0.1 #30
@ -70,6 +70,10 @@ dependencies {
|
||||
testImplementation "com.squareup.okhttp3:mockwebserver:4.2.1"
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||
androidTestImplementation 'androidx.test:rules:1.2.0'
|
||||
|
||||
|
||||
|
||||
implementation "com.squareup.retrofit2:retrofit:2.6.2"
|
||||
implementation "com.squareup.retrofit2:converter-gson:2.6.2"
|
||||
|
@ -0,0 +1,69 @@
|
||||
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("Riempire tutti i campi"))
|
||||
.inRoot(withDecorView(not(activityRule.activity.window.decorView)))
|
||||
.check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun loginWithEmptyUsername() {
|
||||
onView(withId(R.id.instanceServer))
|
||||
.perform(typeText("instanceServer"))
|
||||
onView(withId(R.id.password))
|
||||
.perform(typeText("password"))
|
||||
closeSoftKeyboard()
|
||||
onView(withId(R.id.button))
|
||||
.perform(click())
|
||||
onView(withText("Riempire tutti i campi"))
|
||||
.inRoot(withDecorView(not(activityRule.activity.window.decorView)))
|
||||
.check(matches(isDisplayed()))
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
fun loginWithEmptyPassword() {
|
||||
onView(withId(R.id.instanceServer))
|
||||
.perform(typeText("instanceServer"))
|
||||
onView(withId(R.id.username))
|
||||
.perform(typeText("username"))
|
||||
closeSoftKeyboard()
|
||||
onView(withId(R.id.button))
|
||||
.perform(click())
|
||||
onView(withText("Riempire tutti i campi"))
|
||||
.inRoot(withDecorView(not(activityRule.activity.window.decorView)))
|
||||
.check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
}
|
@ -31,7 +31,7 @@ class LoginActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
fun loginButton(v: View) {
|
||||
if (username.text.isBlank() || istanceServer.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)
|
||||
.show()
|
||||
return
|
||||
@ -43,7 +43,7 @@ class LoginActivity : AppCompatActivity() {
|
||||
|
||||
val service = Retrofit.Builder()
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.baseUrl(istanceServer.text.toString())
|
||||
.baseUrl(instanceServer.text.toString())
|
||||
.build()
|
||||
.create(LoginService::class.java)
|
||||
|
||||
@ -69,7 +69,7 @@ class LoginActivity : AppCompatActivity() {
|
||||
return
|
||||
}
|
||||
val users = response.body()
|
||||
sph.baseUrl = istanceServer.text.toString()
|
||||
sph.baseUrl = instanceServer.text.toString()
|
||||
sph.token = users?.token
|
||||
sph.userId = users?.id
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/istanceServer"
|
||||
android:id="@+id/instanceServer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="50dp"
|
||||
|
Loading…
Reference in New Issue
Block a user