mirror of
https://gitlab.shinice.net/pixeldroid/PixelDroid
synced 2024-12-25 06:23:58 +01:00
Added tests for the settings UI
This commit is contained in:
parent
26427d5377
commit
191a499a04
@ -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")))
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user