release 0.1 #30

Manually merged
noemi3 merged 150 commits from release/0.1 into master 2020-01-18 14:59:02 +00:00
4 changed files with 77 additions and 4 deletions
Showing only changes of commit f2908ed101 - Show all commits

View File

@ -70,6 +70,10 @@ dependencies {
testImplementation "com.squareup.okhttp3:mockwebserver:4.2.1" testImplementation "com.squareup.okhttp3:mockwebserver:4.2.1"
androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 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:retrofit:2.6.2"
implementation "com.squareup.retrofit2:converter-gson:2.6.2" implementation "com.squareup.retrofit2:converter-gson:2.6.2"

View File

@ -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()))
}
}

View File

@ -31,7 +31,7 @@ class LoginActivity : AppCompatActivity() {
} }
fun loginButton(v: View) { 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) Toast.makeText(this, "Riempire tutti i campi", Toast.LENGTH_LONG)
.show() .show()
return return
@ -43,7 +43,7 @@ class LoginActivity : AppCompatActivity() {
val service = Retrofit.Builder() val service = Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create()) .addConverterFactory(GsonConverterFactory.create())
.baseUrl(istanceServer.text.toString()) .baseUrl(instanceServer.text.toString())
.build() .build()
.create(LoginService::class.java) .create(LoginService::class.java)
@ -69,7 +69,7 @@ class LoginActivity : AppCompatActivity() {
return return
} }
val users = response.body() val users = response.body()
sph.baseUrl = istanceServer.text.toString() sph.baseUrl = instanceServer.text.toString()
sph.token = users?.token sph.token = users?.token
sph.userId = users?.id sph.userId = users?.id

View File

@ -42,7 +42,7 @@
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
<EditText <EditText
android:id="@+id/istanceServer" android:id="@+id/instanceServer"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="50dp" android:layout_marginBottom="50dp"