diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/base/BaseTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/base/BaseTest.kt index df81ac88f..c3a6be347 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/base/BaseTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/base/BaseTest.kt @@ -40,7 +40,6 @@ import androidx.test.internal.runner.junit4.statement.UiThreadStatement.runOnUiT import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.By import androidx.test.uiautomator.UiDevice -import androidx.test.uiautomator.UiSelector import androidx.test.uiautomator.Until import com.flowcrypt.email.BuildConfig import com.flowcrypt.email.Constants @@ -53,6 +52,7 @@ import com.flowcrypt.email.database.entity.AccountEntity import com.flowcrypt.email.database.entity.AttachmentEntity import com.flowcrypt.email.extensions.kotlin.toInputStream import com.flowcrypt.email.extensions.shutdown +import com.flowcrypt.email.matchers.CustomMatchers.Companion.withChipsBackgroundColor import com.flowcrypt.email.rules.FlowCryptTestSettingsRule import com.flowcrypt.email.util.FlavorSettings import com.flowcrypt.email.util.TestGeneralUtil @@ -104,9 +104,13 @@ abstract class BaseTest : BaseActivityTestImplementation { @Before fun dismissANRSystemDialogIfExists() { val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) - val waitButton = device.findObject(UiSelector().textContains("wait")) - if (waitButton.exists()) { + //a slow emulator can show "System UI isn't responding" for a few minutes after boot. + //The dialog can appear again right after we dismiss it, so we repeat it a few times + val deadline = SystemClock.uptimeMillis() + TimeUnit.SECONDS.toMillis(60) + while (SystemClock.uptimeMillis() < deadline) { + val waitButton = device.findObject(By.res("android", "aerr_wait")) ?: break waitButton.click() + device.wait(Until.gone(By.res("android", "aerr_wait")), TimeUnit.SECONDS.toMillis(5)) } //close the notification bar if needed @@ -403,6 +407,47 @@ abstract class BaseTest : BaseActivityTestImplementation { } } + /** + * Wait until the recipient chip keeps its final color during [stableForMs]. + * The chip is white while the recipient lookup is in progress, and the compose screen + * blocks sending during that time. The lookup can start asynchronously, + * so a single check can pass before it begins. + */ + protected fun waitUntilRecipientChipIsSettled( + email: String, + colorResId: Int, + stableForMs: Long = TimeUnit.SECONDS.toMillis(1), + timeoutMs: Long = TimeUnit.SECONDS.toMillis(30) + ) { + val chipMatcher = allOf( + withText(email), + withChipsBackgroundColor(getTargetContext(), colorResId) + ) + val startTime = SystemClock.uptimeMillis() + var settledSince: Long? = null + while (true) { + val now = SystemClock.uptimeMillis() + val isSettled = runCatching { + onView(chipMatcher).check(matches(isDisplayed())) + }.isSuccess + + if (isSettled) { + val since = settledSince ?: now.also { settledSince = it } + if (now - since >= stableForMs) return + } else { + settledSince = null + } + + if (now - startTime >= timeoutMs) { + //fail with a clear Espresso error + onView(chipMatcher).check(matches(isDisplayed())) + return + } + + SystemClock.sleep(100) + } + } + protected fun getIdentifierByName(name: String): Int { return getTargetContext() .resources diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/ComposeScreenFlowTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/ComposeScreenFlowTest.kt index f05ddb81e..71a31435a 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/ComposeScreenFlowTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/ComposeScreenFlowTest.kt @@ -175,6 +175,12 @@ class ComposeScreenFlowTest : BaseComposeScreenTest() { replaceText(TestConstants.RECIPIENT_WITH_PUBLIC_KEY_ON_ATTESTER), pressImeActionButton() ) + //while the lookup is in progress the screen shows the web portal password button, + //and the layout shifts when it is hidden. Also sending is blocked until the lookup is done + waitUntilRecipientChipIsSettled( + email = TestConstants.RECIPIENT_WITH_PUBLIC_KEY_ON_ATTESTER, + colorResId = RecipientChipRecyclerViewAdapter.CHIP_COLOR_RES_ID_HAS_USABLE_PUB_KEY + ) onView(withId(R.id.editTextEmailSubject)) .check(matches(isDisplayed())) .perform(scrollTo(), click(), replaceText(EMAIL_SUBJECT)) @@ -591,12 +597,19 @@ class ComposeScreenFlowTest : BaseComposeScreenTest() { EmailUtil.genAttInfoFromPubKey(secondKeyDetails, addAccountToDatabaseRule.account.email) activeActivityRule?.launch(intent) + waitForObjectWithText( + getResString(R.string.prompt_compose_security_email), + TimeUnit.SECONDS.toMillis(10) + ) openActionBarOverflowOrOptionsMenu(getTargetContext()) onView(withText(R.string.include_public_key)) .check(matches(isDisplayed())) .perform(click()) + //keys are loaded asynchronously, the list is hidden until they are ready + waitForObjectWithResourceName("listViewKeys", TimeUnit.SECONDS.toMillis(10)) + onData(withPubKeyName(att?.name)) .inAdapterView(withId(R.id.listViewKeys)) .perform(click()) diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/DraftsGmailAPITestCorrectSendingFlowTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/DraftsGmailAPITestCorrectSendingFlowTest.kt index 1f06aca03..f8eef0fd8 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/DraftsGmailAPITestCorrectSendingFlowTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/DraftsGmailAPITestCorrectSendingFlowTest.kt @@ -30,6 +30,7 @@ import com.flowcrypt.email.rules.FlowCryptMockWebServerRule import com.flowcrypt.email.rules.GrantPermissionRuleChooser import com.flowcrypt.email.rules.RetryRule import com.flowcrypt.email.rules.ScreenshotTestRule +import com.flowcrypt.email.ui.adapter.RecipientChipRecyclerViewAdapter import com.flowcrypt.email.ui.base.BaseDraftsGmailAPIFlowTest import com.flowcrypt.email.util.TestGeneralUtil import com.flowcrypt.email.viewaction.ClickOnViewInRecyclerViewItem @@ -50,6 +51,7 @@ import org.junit.rules.TestRule import org.junit.runner.RunWith import java.io.InputStreamReader import java.net.HttpURLConnection +import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.TimeUnit import java.util.zip.GZIPInputStream @@ -61,7 +63,8 @@ import java.util.zip.GZIPInputStream @RunWith(AndroidJUnit4::class) @FlowCryptTestSettings(useCommonIdling = false) class DraftsGmailAPITestCorrectSendingFlowTest : BaseDraftsGmailAPIFlowTest() { - private val sentCache = mutableListOf() + //it's filled by the mock web server thread and read by the test thread + private val sentCache = CopyOnWriteArrayList() override val mockWebServerRule: FlowCryptMockWebServerRule = FlowCryptMockWebServerRule( TestConstants.MOCK_WEB_SERVER_PORT, object : Dispatcher() { @@ -186,16 +189,23 @@ class DraftsGmailAPITestCorrectSendingFlowTest : BaseDraftsGmailAPIFlowTest() { pressImeActionButton() ) + //sending is blocked while the recipient lookup is in progress + waitUntilRecipientChipIsSettled( + email = TestConstants.RECIPIENT_WITH_PUBLIC_KEY_ON_ATTESTER, + colorResId = RecipientChipRecyclerViewAdapter.CHIP_COLOR_RES_ID_HAS_USABLE_PUB_KEY + ) + onView(withId(R.id.menuActionSend)) .check(matches(isDisplayed())) .perform(click()) - //need to wait while a message will be sent - waitUntil { + //need to wait while a message will be sent. Right after clicking 'Send' the message may not + //be added to the outbox yet, so an empty outbox alone doesn't mean the message was sent + waitUntil(TimeUnit.SECONDS.toMillis(30)) { val countOfOutgoingMessages = runBlocking { roomDatabase.msgDao().getOutboxMsgsSuspend(addAccountToDatabaseRule.account.email).size } - countOfOutgoingMessages == 0 + countOfOutgoingMessages == 0 && sentCache.isNotEmpty() } assertEquals(0, runBlocking { diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/base/BaseComposeGmailFlow.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/base/BaseComposeGmailFlow.kt index 656e7e2aa..8fb1dba76 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/base/BaseComposeGmailFlow.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/base/BaseComposeGmailFlow.kt @@ -6,6 +6,7 @@ package com.flowcrypt.email.ui.base import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.action.ViewActions.scrollTo import androidx.test.espresso.assertion.ViewAssertions.matches @@ -60,6 +61,7 @@ import java.io.ByteArrayOutputStream import java.io.InputStream import java.net.HttpURLConnection import java.util.Properties +import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.TimeUnit /** @@ -67,7 +69,8 @@ import java.util.concurrent.TimeUnit */ abstract class BaseComposeGmailFlow(accountEntity: AccountEntity = BASE_ACCOUNT_ENTITY) : BaseGmailApiTest(accountEntity) { - protected val sentCache = mutableListOf() + //it's filled by the mock web server thread and read by the test thread + protected val sentCache = CopyOnWriteArrayList() @get:Rule val outgoingMessageConfigurationRule = OutgoingMessageConfigurationRule() @@ -186,6 +189,25 @@ abstract class BaseComposeGmailFlow(accountEntity: AccountEntity = BASE_ACCOUNT_ ) } + /** + * Attach the sender's own public key. [com.flowcrypt.email.ui.activity.fragment.dialog.ChoosePublicKeyDialogFragment] + * loads keys asynchronously and closes itself when there is a single key. + * Until then the dialog has the window focus, so we wait until the compose screen + * is in focus again (its Send action can be found). + */ + protected fun includeOwnPublicKey() { + openActionBarOverflowOrOptionsMenu(getTargetContext()) + onView(ViewMatchers.withText(R.string.include_public_key)) + .check(matches(isDisplayed())) + .perform(click()) + + waitUntil(TimeUnit.SECONDS.toMillis(10)) { + runCatching { + onView(withId(R.id.menuActionSend)).check(matches(isDisplayed())) + }.isSuccess + } + } + protected fun extractKeyId(pgpKeyRingDetails: PgpKeyRingDetails): Long { return PgpKey.parseKeys(pgpKeyRingDetails.publicKey) .pgpKeyRingCollection @@ -281,7 +303,9 @@ abstract class BaseComposeGmailFlow(accountEntity: AccountEntity = BASE_ACCOUNT_ val countOfOutgoingMessages = runBlocking { roomDatabase.msgDao().getOutboxMsgsSuspend(addAccountToDatabaseRule.account.email).size } - if (countOfOutgoingMessages == 0) { + //right after clicking 'Send' the message may not be added to the outbox yet, + //so an empty outbox alone doesn't mean the message was sent + if (countOfOutgoingMessages == 0 && sentCache.isNotEmpty()) { Thread.sleep(TimeUnit.SECONDS.toMillis(1)) break } else { @@ -299,21 +323,23 @@ abstract class BaseComposeGmailFlow(accountEntity: AccountEntity = BASE_ACCOUNT_ //check that we have one message in the server cache and outbox label is not displayed assertEquals(1, sentCache.size) - onView(withId(R.id.toolbar)) - .check( - matches( - not( - hasDescendant( - withText( - getQuantityString( - R.plurals.outbox_msgs_count, - 1 - ) - ) + val toolbarWithoutOutboxLabel = matches( + not( + hasDescendant( + withText( + getQuantityString( + R.plurals.outbox_msgs_count, + 1 ) ) ) ) + ) + //the toolbar is updated a bit later than the outbox in the database + waitUntil(TimeUnit.SECONDS.toMillis(10)) { + runCatching { onView(withId(R.id.toolbar)).check(toolbarWithoutOutboxLabel) }.isSuccess + } + onView(withId(R.id.toolbar)).check(toolbarWithoutOutboxLabel) //check sent MIME message val rawMime = requireNotNull(sentCache.first().raw) diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/EncryptedWithAttachmentsAndOwnPublicKeyComposeGmailApiFlow.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/EncryptedWithAttachmentsAndOwnPublicKeyComposeGmailApiFlow.kt index 5fdd0ece5..45f36a727 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/EncryptedWithAttachmentsAndOwnPublicKeyComposeGmailApiFlow.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/EncryptedWithAttachmentsAndOwnPublicKeyComposeGmailApiFlow.kt @@ -9,12 +9,10 @@ package com.flowcrypt.email.ui.gmailapi * @author Denys Bondarenko */ import androidx.test.espresso.Espresso.onView -import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.withId -import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.FlakyTest import androidx.test.filters.MediumTest @@ -82,10 +80,7 @@ class EncryptedWithAttachmentsAndOwnPublicKeyComposeGmailApiFlow : BaseComposeGm } //attach a public key - openActionBarOverflowOrOptionsMenu(getTargetContext()) - onView(withText(R.string.include_public_key)) - .check(matches(isDisplayed())) - .perform(click()) + includeOwnPublicKey() //enqueue outgoing message onView(withId(R.id.menuActionSend)) diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/PasswordProtectedEncryptedComposeGmailApiFlow.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/PasswordProtectedEncryptedComposeGmailApiFlow.kt index 62d52b0a3..41d3695c4 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/PasswordProtectedEncryptedComposeGmailApiFlow.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/PasswordProtectedEncryptedComposeGmailApiFlow.kt @@ -6,13 +6,11 @@ package com.flowcrypt.email.ui.gmailapi import androidx.test.espresso.Espresso.onView -import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.action.ViewActions.replaceText import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.withId -import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.FlakyTest import androidx.test.filters.LargeTest @@ -168,10 +166,7 @@ class PasswordProtectedEncryptedComposeGmailApiFlow : BaseComposeGmailFlow() { } //attach a public key - openActionBarOverflowOrOptionsMenu(getTargetContext()) - onView(withText(R.string.include_public_key)) - .check(matches(isDisplayed())) - .perform(click()) + includeOwnPublicKey() //add password-protected logic onView(withId(R.id.btnSetWebPortalPassword)) diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/StandardWithPublicKeyComposeGmailApiFlow.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/StandardWithPublicKeyComposeGmailApiFlow.kt index dc477b801..f104f3f99 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/StandardWithPublicKeyComposeGmailApiFlow.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/StandardWithPublicKeyComposeGmailApiFlow.kt @@ -81,10 +81,7 @@ class StandardWithPublicKeyComposeGmailApiFlow : BaseComposeGmailFlow() { .perform(click()) //attach a public key - openActionBarOverflowOrOptionsMenu(getTargetContext()) - onView(withText(R.string.include_public_key)) - .check(matches(isDisplayed())) - .perform(click()) + includeOwnPublicKey() //enqueue outgoing message onView(withId(R.id.menuActionSend)) diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/passwordprotected/BaseComposeScreenPasswordProtectedDisallowedTermsTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/passwordprotected/BaseComposeScreenPasswordProtectedDisallowedTermsTest.kt index d532e4191..3a289429c 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/passwordprotected/BaseComposeScreenPasswordProtectedDisallowedTermsTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/passwordprotected/BaseComposeScreenPasswordProtectedDisallowedTermsTest.kt @@ -22,6 +22,7 @@ import com.flowcrypt.email.database.entity.AccountEntity import com.flowcrypt.email.matchers.CustomMatchers.Companion.withTextViewDrawable import com.flowcrypt.email.matchers.TextViewDrawableMatcher import com.flowcrypt.email.rules.FlowCryptMockWebServerRule +import com.flowcrypt.email.ui.adapter.RecipientChipRecyclerViewAdapter import com.flowcrypt.email.ui.base.BaseComposeGmailFlow import okhttp3.mockwebserver.Dispatcher import okhttp3.mockwebserver.MockResponse @@ -70,6 +71,13 @@ open class BaseComposeScreenPasswordProtectedDisallowedTermsTest( onView(withId(R.id.btSetPassword)) .perform(click()) + + //returning to the compose screen starts a new lookup for the recipient. + //Sending is blocked while it is in progress + waitUntilRecipientChipIsSettled( + email = TestConstants.RECIPIENT_WITHOUT_PUBLIC_KEY_ON_ATTESTER, + colorResId = RecipientChipRecyclerViewAdapter.CHIP_COLOR_RES_ID_NO_PUB_KEY + ) } companion object { diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/passwordprotected/ComposeScreenPasswordProtectedDisallowedTermsReFetchConfigurationFlowTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/passwordprotected/ComposeScreenPasswordProtectedDisallowedTermsReFetchConfigurationFlowTest.kt index df6d76464..8f3191a55 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/passwordprotected/ComposeScreenPasswordProtectedDisallowedTermsReFetchConfigurationFlowTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/passwordprotected/ComposeScreenPasswordProtectedDisallowedTermsReFetchConfigurationFlowTest.kt @@ -40,12 +40,12 @@ import okhttp3.mockwebserver.Dispatcher import okhttp3.mockwebserver.MockResponse import okhttp3.mockwebserver.RecordedRequest import org.hamcrest.Matchers.allOf -import org.junit.Ignore import org.junit.Rule import org.junit.Test import org.junit.rules.RuleChain import org.junit.rules.TestRule import org.junit.runner.RunWith +import org.junit.runners.model.Statement import java.net.HttpURLConnection import java.util.concurrent.TimeUnit @@ -64,20 +64,25 @@ import java.util.concurrent.TimeUnit subject = "", isNew = true ) -@Ignore("temporary disabled") class ComposeScreenPasswordProtectedDisallowedTermsReFetchConfigurationFlowTest : BaseComposeScreenPasswordProtectedDisallowedTermsTest( ACCOUNT_ENTITY_WITH_EXISTING_OPTIONAL_PARAMETERS ) { - private var attemptsToUseDefaultBehavior = 2 + /** + * The app fetches the client configuration a few times before the test triggers the re-fetch + * (activity start, setting a web portal password). The exact count depends on timing, + * so the updated configuration is returned only after the test explicitly asks for it. + */ + @Volatile + private var isUpdatedClientConfigurationEnabled = false override val mockWebServerRule = FlowCryptMockWebServerRule(TestConstants.MOCK_WEB_SERVER_PORT, object : Dispatcher() { override fun dispatch(request: RecordedRequest): MockResponse { return when { request.path.equals("/api/v1/client-configuration?domain=flowcrypt.test") -> { - if (attemptsToUseDefaultBehavior == 0) { + if (isUpdatedClientConfigurationEnabled) { MockResponse() .setResponseCode(HttpURLConnection.HTTP_OK) .setBody( @@ -91,7 +96,6 @@ class ComposeScreenPasswordProtectedDisallowedTermsReFetchConfigurationFlowTest ) ) } else { - attemptsToUseDefaultBehavior-- handleCommonAPICalls(request) } } @@ -104,6 +108,15 @@ class ComposeScreenPasswordProtectedDisallowedTermsReFetchConfigurationFlowTest @get:Rule var ruleChain: TestRule = RuleChain.outerRule(RetryRule.DEFAULT) + //RetryRule reuses this instance, so every attempt must start with the default configuration + .around(TestRule { base, _ -> + object : Statement() { + override fun evaluate() { + isUpdatedClientConfigurationEnabled = false + base.evaluate() + } + } + }) .around(ClearAppSettingsRule()) .around(GrantPermissionRuleChooser.grant(Manifest.permission.POST_NOTIFICATIONS)) .around(mockWebServerRule) @@ -151,12 +164,18 @@ class ComposeScreenPasswordProtectedDisallowedTermsReFetchConfigurationFlowTest .perform(click()) } + isUpdatedClientConfigurationEnabled = true + //go to ProvidePasswordToProtectMsgFragment and go back to trigger updating onView(withId(R.id.btnSetWebPortalPassword)) .perform(click()) Espresso.pressBack() - //need to wait while threads will be synced - Thread.sleep(2000) + + //wait until RefreshClientConfigurationWorker saves the updated client configuration + waitUntil(TimeUnit.SECONDS.toMillis(30)) { + roomDatabase.accountDao().getActiveAccount() + ?.clientConfiguration?.disallowPasswordMessagesErrorText == UPDATED_ERROR_TEXT + } //check that client configuration was updated MATCHING_SUBJECTS.first().let { subject -> diff --git a/script/ci-wait-for-emulator.sh b/script/ci-wait-for-emulator.sh index 2cf0c8594..3c3b51f19 100755 --- a/script/ci-wait-for-emulator.sh +++ b/script/ci-wait-for-emulator.sh @@ -162,6 +162,11 @@ adb shell settings put global window_animation_scale 0 adb shell settings put global transition_animation_scale 0 adb shell settings put global animator_duration_scale 0 +# CI emulators are slow. When injecting a tap takes longer than long_press_timeout (400 ms by +# default), Espresso logs "Overslept and turned a tap into a long press" and the view gets +# a long click instead of a click (e.g. a toolbar menu item shows its tooltip). +adb shell settings put secure long_press_timeout 1500 + ################################################################################################### # To test WKD we need to route all traffic for localhost:443 to localhost:1212 # as we can't use 443 directly for a mock web server.