From a61ea0b6cc9bd790d0aff730bc6f1b94e9a39e51 Mon Sep 17 00:00:00 2001 From: stargateprovider Date: Sat, 4 Dec 2021 14:28:52 +0200 Subject: [PATCH] UC4 test --- .../tarkvaraprojekt/mobileauthapp/UC4Test.kt | 35 ++++--------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/MobileAuthApp/app/src/androidTest/java/com/tarkvaraprojekt/mobileauthapp/UC4Test.kt b/MobileAuthApp/app/src/androidTest/java/com/tarkvaraprojekt/mobileauthapp/UC4Test.kt index 72f86b7..c41ab64 100644 --- a/MobileAuthApp/app/src/androidTest/java/com/tarkvaraprojekt/mobileauthapp/UC4Test.kt +++ b/MobileAuthApp/app/src/androidTest/java/com/tarkvaraprojekt/mobileauthapp/UC4Test.kt @@ -1,9 +1,9 @@ package com.tarkvaraprojekt.mobileauthapp import androidx.fragment.app.testing.launchFragmentInContainer +import androidx.lifecycle.Lifecycle import androidx.test.espresso.Espresso.onView import androidx.test.espresso.IdlingPolicies -import androidx.test.espresso.NoMatchingViewException import androidx.test.espresso.action.ViewActions.* import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.matcher.RootMatchers.* @@ -12,6 +12,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.rule.ActivityTestRule import org.hamcrest.CoreMatchers.`is` import org.hamcrest.CoreMatchers.not +import org.junit.Assert.* import org.junit.* import org.junit.runner.RunWith @@ -26,8 +27,8 @@ class UC4Test { @Before fun setUp() { - IdlingPolicies.setMasterPolicyTimeout(3, TimeUnit.SECONDS) - IdlingPolicies.setIdlingResourceTimeout(3, TimeUnit.SECONDS) + IdlingPolicies.setMasterPolicyTimeout(1, TimeUnit.SECONDS) + IdlingPolicies.setIdlingResourceTimeout(1, TimeUnit.SECONDS) activityActivityTestRule.activity .supportFragmentManager.beginTransaction() } @@ -36,36 +37,14 @@ class UC4Test { fun tearDown() { } - fun navigateToCANView() { - onView(withId(R.id.menu_settings_option)).perform(click()) - try { - // Delete existing CAN - onView(withText(R.string.can_delete)).perform(click()) - } catch (ignore: NoMatchingViewException) {} - - onView(withId(R.id.can_menu_action)).perform(click()) - } - @Test - fun validCAN() { - navigateToCANView() + fun test() { + onView(withId(R.id.menu_settings_option)).perform(click()) + onView(withId(R.id.can_menu_action)).perform(click()) onView(supportsInputMethods()).perform(typeText("123456")) onView(withId(R.id.next_button)).perform(click()) - onView(withText(R.string.can_status_saved)).inRoot( withDecorView(not(`is`(activityActivityTestRule.activity.getWindow().getDecorView()))) ).check(matches(isDisplayed())) } - - @Test - fun invalidCAN() { - navigateToCANView() - onView(supportsInputMethods()).perform(typeText("12345")) - onView(withId(R.id.next_button)).perform(click()) - - onView(withText(R.string.length_can)).inRoot( - withDecorView(not(`is`(activityActivityTestRule.activity.getWindow().getDecorView()))) - ).check(matches(isDisplayed())) - onView(withId(R.id.next_button)).check(matches(isDisplayed())) - } } \ No newline at end of file