From 7001ebd4e06131de84743718a62dc8f18f8fd16d Mon Sep 17 00:00:00 2001 From: Justin McClain Date: Thu, 10 Aug 2023 21:53:44 +0000 Subject: [PATCH] Updating RemoteAuthEnrollIntroductionTest and RemoteAuthEnrollFinishTest Updating tests to use onView and withId like other RemoteAuth UX tests. Bug: b/290769765 Test: atest RemoteAuthEnrollIntroductionTest RemoteAuthEnrollFinishTest Change-Id: Ib3367b6ed39a5506b3777cb6dd1b909ce6e85502 --- .../finish/RemoteAuthEnrollFinishTest.kt | 46 ++++++++----------- .../RemoteAuthEnrollIntroductionTest.kt | 42 ++++++++--------- 2 files changed, 37 insertions(+), 51 deletions(-) diff --git a/tests/robotests/src/com/android/settings/remoteauth/finish/RemoteAuthEnrollFinishTest.kt b/tests/robotests/src/com/android/settings/remoteauth/finish/RemoteAuthEnrollFinishTest.kt index 0f9911b3df2..1ad7dd89692 100644 --- a/tests/robotests/src/com/android/settings/remoteauth/finish/RemoteAuthEnrollFinishTest.kt +++ b/tests/robotests/src/com/android/settings/remoteauth/finish/RemoteAuthEnrollFinishTest.kt @@ -16,48 +16,40 @@ package com.android.settings.remoteauth.finish - -import android.content.Context import android.os.Bundle import androidx.fragment.app.testing.launchFragmentInContainer -import androidx.test.core.app.ApplicationProvider +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.ViewMatchers.* import com.android.settings.R -import com.google.android.setupdesign.GlifLayout -import com.google.common.truth.Truth.assertThat - +import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner @RunWith(RobolectricTestRunner::class) class RemoteAuthEnrollFinishTest { - private var mContext: Context = ApplicationProvider.getApplicationContext() + + @Before + fun setup() { + launchFragmentInContainer(Bundle(), R.style.SudThemeGlif) + } @Test fun testRemoteAuthenticatorEnrollFinish_hasHeader() { - launchFragmentInContainer( - Bundle(), - com.google.android.setupdesign.R.style.SudThemeGlif, - ).onFragment { - assertThat((it.view as GlifLayout).headerText) - .isEqualTo( - mContext.getString(R.string.security_settings_remoteauth_enroll_finish_title) - ) - } + onView(withText(R.string.security_settings_remoteauth_enroll_finish_title)).check( + matches( + isDisplayed() + ) + ) } @Test fun testRemoteAuthenticatorEnrollFinish_hasDescription() { - launchFragmentInContainer( - Bundle(), - com.google.android.setupdesign.R.style.SudThemeGlif, - ).onFragment { - assertThat((it.view as GlifLayout).descriptionText) - .isEqualTo( - mContext.getString( - R.string.security_settings_remoteauth_enroll_finish_description - ) - ) - } + onView(withText(R.string.security_settings_remoteauth_enroll_finish_description)).check( + matches( + isDisplayed() + ) + ) } } diff --git a/tests/robotests/src/com/android/settings/remoteauth/introduction/RemoteAuthEnrollIntroductionTest.kt b/tests/robotests/src/com/android/settings/remoteauth/introduction/RemoteAuthEnrollIntroductionTest.kt index 1ca011905db..6855e9f0dc3 100644 --- a/tests/robotests/src/com/android/settings/remoteauth/introduction/RemoteAuthEnrollIntroductionTest.kt +++ b/tests/robotests/src/com/android/settings/remoteauth/introduction/RemoteAuthEnrollIntroductionTest.kt @@ -16,45 +16,39 @@ package com.android.settings.remoteauth.introduction -import android.content.Context import android.os.Bundle import androidx.fragment.app.testing.launchFragmentInContainer -import androidx.test.core.app.ApplicationProvider +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.ViewMatchers.* import com.android.settings.R -import com.google.android.setupdesign.GlifLayout -import com.google.common.truth.Truth.assertThat - +import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner @RunWith(RobolectricTestRunner::class) class RemoteAuthEnrollIntroductionTest { - private var mContext: Context = ApplicationProvider.getApplicationContext() + @Before + fun setUp() { + launchFragmentInContainer(Bundle(), R.style.SudThemeGlif) + } @Test fun testRemoteAuthenticatorEnrollIntroduction_hasHeader() { - launchFragmentInContainer( - Bundle(), - com.google.android.setupdesign.R.style.SudThemeGlif, - ).onFragment { - assertThat((it.view as GlifLayout).headerText) - .isEqualTo(mContext.getString(R.string.security_settings_remoteauth_enroll_introduction_title)) - } + onView(withText(R.string.security_settings_remoteauth_enroll_introduction_title)).check( + matches( + isDisplayed() + ) + ) } @Test fun testRemoteAuthenticatorEnrollIntroduction_hasDescription() { - launchFragmentInContainer( - Bundle(), - com.google.android.setupdesign.R.style.SudThemeGlif, - ).onFragment { - assertThat((it.view as GlifLayout).descriptionText) - .isEqualTo( - mContext.getString( - R.string.security_settings_remoteauth_enroll_introduction_message - ) - ) - } + onView(withText(R.string.security_settings_remoteauth_enroll_introduction_message)).check( + matches( + isDisplayed() + ) + ) } }