diff --git a/app/build.gradle b/app/build.gradle index 4180076..8ad6a27 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -24,6 +24,10 @@ android { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } + + debug { + testCoverageEnabled = true + } } packagingOptions { exclude 'META-INF/atomicfu.kotlin_module' diff --git a/app/src/androidTest/java/it/unisannio/ding/ids/wedroid/app/view/BoardsListsActivityTest.kt b/app/src/androidTest/java/it/unisannio/ding/ids/wedroid/app/view/BoardsListsActivityTest.kt index 6fe7e0a..82b0dd5 100644 --- a/app/src/androidTest/java/it/unisannio/ding/ids/wedroid/app/view/BoardsListsActivityTest.kt +++ b/app/src/androidTest/java/it/unisannio/ding/ids/wedroid/app/view/BoardsListsActivityTest.kt @@ -1,13 +1,11 @@ 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.swipeDown -import androidx.test.espresso.action.ViewActions.swipeLeft +import androidx.test.espresso.action.ViewActions.* import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.contrib.RecyclerViewActions -import androidx.test.espresso.matcher.ViewMatchers.isDisplayed -import androidx.test.espresso.matcher.ViewMatchers.withId +import androidx.test.espresso.matcher.ViewMatchers.* import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest import androidx.test.rule.ActivityTestRule @@ -24,19 +22,80 @@ class BoardsListsActivityTest { @get:Rule val activityRule = ActivityTestRule(BoardsListsActivity::class.java) - fun swipeLeftToDelete() { + @Test + fun openBoard() { onView(withId(R.id.boardList)) .perform( RecyclerViewActions.actionOnItemAtPosition( - 0, swipeLeft() + 0, click() ) ) + + onView(withId(R.id.getLists)) + .check(matches(isDisplayed())) } + @Test + fun openBoardLists() { + onView(withId(R.id.boardList)) + .perform( + RecyclerViewActions.actionOnItemAtPosition( + 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( + 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( + 1, click() + ) + ) + + onView(withId(R.id.getLists)) + .perform(click()) + + onView(withId(R.id.synchronize)) + .perform(click()) + } + + @Test fun pullToRefresh() { onView(withId(R.id.pullToRefresh)) .perform(swipeDown()) - } @Test @@ -48,5 +107,45 @@ class BoardsListsActivityTest { .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() + } } diff --git a/app/src/androidTest/java/it/unisannio/ding/ids/wedroid/app/view/LoginActivityTest.kt b/app/src/androidTest/java/it/unisannio/ding/ids/wedroid/app/view/LoginActivityTest.kt index 62af7b7..f4f354d 100644 --- a/app/src/androidTest/java/it/unisannio/ding/ids/wedroid/app/view/LoginActivityTest.kt +++ b/app/src/androidTest/java/it/unisannio/ding/ids/wedroid/app/view/LoginActivityTest.kt @@ -84,4 +84,17 @@ class LoginActivityTest { .inRoot(withDecorView(not(activityRule.activity.window.decorView))) .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()) + } } \ No newline at end of file diff --git a/app/src/androidTest/java/it/unisannio/ding/ids/wedroid/app/view/NewBoardActivityTest.kt b/app/src/androidTest/java/it/unisannio/ding/ids/wedroid/app/view/NewBoardActivityTest.kt index 4f49761..bb4fba3 100644 --- a/app/src/androidTest/java/it/unisannio/ding/ids/wedroid/app/view/NewBoardActivityTest.kt +++ b/app/src/androidTest/java/it/unisannio/ding/ids/wedroid/app/view/NewBoardActivityTest.kt @@ -32,6 +32,5 @@ class NewBoardActivityTest { .inRoot(withDecorView(not(activityRule.activity.window.decorView))) .check(matches(isDisplayed())) } - }