diff --git a/MobileAuthApp/app/build.gradle b/MobileAuthApp/app/build.gradle index a65bc6e..9a0b3dc 100644 --- a/MobileAuthApp/app/build.gradle +++ b/MobileAuthApp/app/build.gradle @@ -44,7 +44,9 @@ dependencies { implementation 'androidx.legacy:legacy-support-v4:1.0.0' testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test:rules:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + debugImplementation 'androidx.fragment:fragment-testing:1.4.0' //To use activityViewModels implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" diff --git a/MobileAuthApp/app/src/androidTest/java/com/tarkvaraprojekt/mobileauthapp/UC4Test.kt b/MobileAuthApp/app/src/androidTest/java/com/tarkvaraprojekt/mobileauthapp/UC4Test.kt new file mode 100644 index 0000000..c41ab64 --- /dev/null +++ b/MobileAuthApp/app/src/androidTest/java/com/tarkvaraprojekt/mobileauthapp/UC4Test.kt @@ -0,0 +1,50 @@ +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.action.ViewActions.* +import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.RootMatchers.* +import androidx.test.espresso.matcher.ViewMatchers.* +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 +import java.util.concurrent.TimeUnit + +@RunWith(AndroidJUnit4::class) +class UC4Test { + @get:Rule + var activityActivityTestRule: ActivityTestRule = ActivityTestRule( + MainActivity::class.java + ) + + @Before + fun setUp() { + IdlingPolicies.setMasterPolicyTimeout(1, TimeUnit.SECONDS) + IdlingPolicies.setIdlingResourceTimeout(1, TimeUnit.SECONDS) + activityActivityTestRule.activity + .supportFragmentManager.beginTransaction() + } + + @After + fun tearDown() { + } + + @Test + 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())) + } +} \ No newline at end of file