Compare commits

..

1 Commits

Author SHA1 Message Date
794f80224a
increase coverage 2020-01-23 17:37:02 +01:00
4 changed files with 124 additions and 9 deletions

View File

@ -24,6 +24,10 @@ android {
minifyEnabled false minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} }
debug {
testCoverageEnabled = true
}
} }
packagingOptions { packagingOptions {
exclude 'META-INF/atomicfu.kotlin_module' exclude 'META-INF/atomicfu.kotlin_module'

View File

@ -1,13 +1,11 @@
package it.unisannio.ding.ids.wedroid.app.view package it.unisannio.ding.ids.wedroid.app.view
import androidx.test.espresso.Espresso.closeSoftKeyboard
import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.action.ViewActions.*
import androidx.test.espresso.action.ViewActions.swipeDown
import androidx.test.espresso.action.ViewActions.swipeLeft
import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.RecyclerViewActions import androidx.test.espresso.contrib.RecyclerViewActions
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.*
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest import androidx.test.filters.LargeTest
import androidx.test.rule.ActivityTestRule import androidx.test.rule.ActivityTestRule
@ -24,19 +22,80 @@ class BoardsListsActivityTest {
@get:Rule @get:Rule
val activityRule = ActivityTestRule(BoardsListsActivity::class.java) val activityRule = ActivityTestRule(BoardsListsActivity::class.java)
fun swipeLeftToDelete() { @Test
fun openBoard() {
onView(withId(R.id.boardList)) onView(withId(R.id.boardList))
.perform( .perform(
RecyclerViewActions.actionOnItemAtPosition<BoardsListAdapter.BoardViewHolder>( RecyclerViewActions.actionOnItemAtPosition<BoardsListAdapter.BoardViewHolder>(
0, swipeLeft() 0, click()
) )
) )
onView(withId(R.id.getLists))
.check(matches(isDisplayed()))
} }
@Test
fun openBoardLists() {
onView(withId(R.id.boardList))
.perform(
RecyclerViewActions.actionOnItemAtPosition<BoardsListAdapter.BoardViewHolder>(
0, click()
)
)
onView(withId(R.id.getLists))
.perform(click())
onView(withId(R.id.synchronize))
.check(matches(isDisplayed()))
}
@Test
fun addNewCard() {
onView(withId(R.id.boardList))
.perform(
RecyclerViewActions.actionOnItemAtPosition<BoardsListAdapter.BoardViewHolder>(
0, click()
)
)
onView(withId(R.id.getLists))
.perform(click())
onView(withId(R.id.buttonAddCard))
.perform(click())
onView(withId(R.id.edittext))
.perform(typeText("card test"))
closeSoftKeyboard()
onView(withText("OK"))
.perform(click())
onView(withId(R.id.synchronize))
.check(matches(isDisplayed()))
}
@Test
fun synchronizeBoard() {
onView(withId(R.id.boardList))
.perform(
RecyclerViewActions.actionOnItemAtPosition<BoardsListAdapter.BoardViewHolder>(
1, click()
)
)
onView(withId(R.id.getLists))
.perform(click())
onView(withId(R.id.synchronize))
.perform(click())
}
@Test
fun pullToRefresh() { fun pullToRefresh() {
onView(withId(R.id.pullToRefresh)) onView(withId(R.id.pullToRefresh))
.perform(swipeDown()) .perform(swipeDown())
} }
@Test @Test
@ -48,5 +107,45 @@ class BoardsListsActivityTest {
.check(matches(isDisplayed())) .check(matches(isDisplayed()))
} }
@Test
fun newPrivateBoard() {
onView(withId(R.id.fab))
.perform(click())
onView(withId(R.id.newBoardName))
.perform(typeText("test private-board"))
closeSoftKeyboard()
onView(withId(R.id.newBoardDone))
.perform(click())
onView(withId(R.id.fab))
.check(matches(isDisplayed()))
}
@Test
fun newPublicBoard() {
onView(withId(R.id.fab))
.perform(click())
onView(withId(R.id.newBoardName))
.perform(typeText("test public-board"))
closeSoftKeyboard()
onView(withId(R.id.newBoardPermission))
.perform(click())
onView(withId(R.id.newBoardDone))
.perform(click())
onView(withId(R.id.fab))
.check(matches(isDisplayed()))
}
@Test
fun cancelNewBoard() {
onView(withId(R.id.fab))
.perform(click())
onView(withId(R.id.newBoardCancel))
.perform()
}
} }

View File

@ -84,4 +84,17 @@ class LoginActivityTest {
.inRoot(withDecorView(not(activityRule.activity.window.decorView))) .inRoot(withDecorView(not(activityRule.activity.window.decorView)))
.check(matches(isDisplayed())) .check(matches(isDisplayed()))
} }
@Test
fun loginWithWrongInstance(){
onView(withId(R.id.instanceServer))
.perform(typeText("https://duckduckgo.com"))
onView(withId(R.id.username))
.perform(typeText("username"))
onView(withId(R.id.password))
.perform(typeText("password"))
closeSoftKeyboard()
onView(withId(R.id.button))
.perform(click())
}
} }

View File

@ -32,6 +32,5 @@ class NewBoardActivityTest {
.inRoot(withDecorView(not(activityRule.activity.window.decorView))) .inRoot(withDecorView(not(activityRule.activity.window.decorView)))
.check(matches(isDisplayed())) .check(matches(isDisplayed()))
} }
} }