1
0
mirror of https://gitlab.shinice.net/pixeldroid/PixelDroid synced 2024-12-25 14:34:12 +01:00

Merge pull request #42 from H-PixelDroid/settingsUI

Added tests for the settings UI
This commit is contained in:
Andrew Dobis 2020-03-12 19:17:34 +01:00 committed by GitHub
commit f124af3800
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,11 +2,8 @@ package com.h.pixeldroid
import android.view.Gravity import android.view.Gravity
import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.ViewAction import androidx.test.espresso.Espresso.pressBack
import androidx.test.espresso.action.CoordinatesProvider import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.action.GeneralClickAction
import androidx.test.espresso.action.Press
import androidx.test.espresso.action.Tap
import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.DrawerActions import androidx.test.espresso.contrib.DrawerActions
import androidx.test.espresso.contrib.DrawerMatchers.isClosed import androidx.test.espresso.contrib.DrawerMatchers.isClosed
@ -32,7 +29,7 @@ class SettingsTest {
.check(matches(isClosed(Gravity.LEFT))) // Left Drawer should be closed. .check(matches(isClosed(Gravity.LEFT))) // Left Drawer should be closed.
.perform(DrawerActions.open()); // Open Drawer .perform(DrawerActions.open()); // Open Drawer
// Start the screen of your activity. // Start the screen of the activity.
onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_settings)) onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_settings))
// Check that settings activity was opened. // Check that settings activity was opened.
@ -46,10 +43,26 @@ class SettingsTest {
.check(matches(isClosed(Gravity.LEFT))) // Left Drawer should be closed. .check(matches(isClosed(Gravity.LEFT))) // Left Drawer should be closed.
.perform(DrawerActions.open()); // Open Drawer .perform(DrawerActions.open()); // Open Drawer
// Start the screen of your activity. // Start the screen of the activity.
onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_account)) onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_account))
// Check that profile activity was opened. // Check that profile activity was opened.
onView(withId(R.id.posts)).check(matches(withText("Posts"))) onView(withId(R.id.posts)).check(matches(withText("Posts")))
} }
@Test
fun testOnBackPressed() {
// Open Drawer to click on navigation.
onView(withId(R.id.drawer_layout))
.check(matches(isClosed(Gravity.LEFT))) // Left Drawer should be closed.
.perform(DrawerActions.open()); // Open Drawer
// Start the screen of your activity.
onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_settings))
onView(withId(R.id.settings)).perform(ViewActions.pressBack())
// Check that profile activity was opened.
onView(withId(R.id.button_start_login)).check(matches(withText("start login")))
}
} }