For #23858: replaces opened app verification with intent matching

pull/543/head
sv-ohorvath 2 years ago committed by mergify[bot]
parent acb6f5429b
commit 9c6a127a40

@ -16,6 +16,7 @@ object Constants {
const val PHONE_APP = "com.android.dialer"
}
const val SPEECH_RECOGNITION = "android.speech.action.RECOGNIZE_SPEECH"
const val LONG_CLICK_DURATION: Long = 5000
const val LISTS_MAXSWIPES: Int = 3
}

@ -14,6 +14,7 @@ import android.graphics.Canvas
import android.graphics.Color
import android.net.Uri
import android.os.Build
import android.util.Log
import android.view.View
import androidx.browser.customtabs.CustomTabsIntent
import androidx.test.espresso.Espresso
@ -36,6 +37,7 @@ import androidx.test.uiautomator.UiObjectNotFoundException
import androidx.test.uiautomator.UiScrollable
import androidx.test.uiautomator.UiSelector
import androidx.test.uiautomator.Until
import java.util.regex.Pattern
import junit.framework.AssertionFailedError
import mozilla.components.browser.state.search.SearchEngine
import mozilla.components.support.ktx.android.content.appName
@ -53,7 +55,6 @@ import org.mozilla.fenix.helpers.idlingresource.NetworkConnectionIdlingResource
import org.mozilla.fenix.ui.robots.BrowserRobot
import org.mozilla.fenix.ui.robots.mDevice
import org.mozilla.fenix.utils.IntentUtils
import java.util.regex.Pattern
object TestHelper {
@ -232,6 +233,7 @@ object TestHelper {
intended(toPackage(appPackageName))
} catch (e: AssertionFailedError) {
e.printStackTrace()
Log.e("TestLog", "intent to $appPackageName not sent or doesn't match")
}
} else {
BrowserRobot().verifyUrl(url)

@ -24,6 +24,8 @@ import androidx.test.espresso.ViewInteraction
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.closeSoftKeyboard
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.matcher.IntentMatchers
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
@ -43,11 +45,13 @@ import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.Constants
import org.mozilla.fenix.helpers.Constants.LONG_CLICK_DURATION
import org.mozilla.fenix.helpers.Constants.PackageName
import org.mozilla.fenix.helpers.Constants.SPEECH_RECOGNITION
import org.mozilla.fenix.helpers.SessionLoadedIdlingResource
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTimeShort
import org.mozilla.fenix.helpers.TestHelper.isPackageInstalled
import org.mozilla.fenix.helpers.TestHelper.packageName
import org.mozilla.fenix.helpers.TestHelper.waitForObjects
import org.mozilla.fenix.helpers.click
@ -88,9 +92,9 @@ class SearchRobot {
allowPermission.click()
}
mDevice.waitNotNull(
Until.findObject(By.pkg(PackageName.GOOGLE_QUICK_SEARCH)), waitingTime
)
if (isPackageInstalled(Constants.PackageName.GOOGLE_QUICK_SEARCH)) {
Intents.intended(IntentMatchers.hasAction(SPEECH_RECOGNITION))
}
}
}

Loading…
Cancel
Save