diff --git a/.buildkite/commands/connected-tests.sh b/.buildkite/commands/connected-tests.sh old mode 100644 new mode 100755 index 2fc465dbf..38d8308c1 --- a/.buildkite/commands/connected-tests.sh +++ b/.buildkite/commands/connected-tests.sh @@ -17,5 +17,5 @@ gcloud firebase test android run \ --type instrumentation \ --app app/build/outputs/apk/debug/app-debug.apk \ --test app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk \ - --device model=Nexus5X,version=26,locale=en,orientation=portrait \ + --device model=redfin,version=30 \ --verbosity info diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index 405a2b306..5e1413088 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -7,4 +7,4 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: gradle/wrapper-validation-action@v1 + - uses: gradle/actions/wrapper-validation@v3 diff --git a/app/src/androidTest/kotlin/org/wordpress/aztec/demo/BaseTest.kt b/app/src/androidTest/kotlin/org/wordpress/aztec/demo/BaseTest.kt index df840aac5..0c45dc468 100644 --- a/app/src/androidTest/kotlin/org/wordpress/aztec/demo/BaseTest.kt +++ b/app/src/androidTest/kotlin/org/wordpress/aztec/demo/BaseTest.kt @@ -2,18 +2,23 @@ package org.wordpress.aztec.demo +import android.Manifest.permission.CAMERA import android.util.Log -import androidx.test.rule.GrantPermissionRule +import androidx.test.platform.app.InstrumentationRegistry import androidx.test.runner.AndroidJUnit4 -import org.junit.Rule +import org.junit.Before import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) abstract class BaseTest { - @Rule - @JvmField - val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(android.Manifest.permission.CAMERA, - android.Manifest.permission.WRITE_EXTERNAL_STORAGE) + + @Before + fun grantPermissions() { + val (uiAutomation, packageName) = with(InstrumentationRegistry.getInstrumentation()) { + Pair(uiAutomation, targetContext.packageName) + } + uiAutomation.grantRuntimePermission(packageName, CAMERA) + } companion object { fun label(label: String) { diff --git a/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditLinkPage.kt b/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditLinkPage.kt index c1f22a764..e7a93726c 100644 --- a/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditLinkPage.kt +++ b/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditLinkPage.kt @@ -33,7 +33,17 @@ class EditLinkPage : BasePage() { } fun updateURL(url: String): EditLinkPage { - urlField.perform(replaceText(url), ViewActions.closeSoftKeyboard()) + threadSleep(2000L) // Wait for the page to load + try { + urlField.perform(click()) + urlField.perform(replaceText(url), ViewActions.closeSoftKeyboard()) + } catch (e: RuntimeException) { + // If the URL field is not visible, it might be because the keyboard is open. + // Close the keyboard and try again. + urlField.perform(ViewActions.closeSoftKeyboard()) + urlField.perform(replaceText(url), ViewActions.closeSoftKeyboard()) + e.printStackTrace() + } label("Entered url") return this @@ -80,4 +90,9 @@ class EditLinkPage : BasePage() { cancelButton.perform(click()) label("Canceled") } + + fun threadSleep(millis: Long): EditLinkPage { + Thread.sleep(millis) + return this + } } diff --git a/app/src/androidTest/kotlin/org/wordpress/aztec/demo/tests/LinkHistoryTests.kt b/app/src/androidTest/kotlin/org/wordpress/aztec/demo/tests/LinkHistoryTests.kt index 83d75e0fb..11c945a6e 100644 --- a/app/src/androidTest/kotlin/org/wordpress/aztec/demo/tests/LinkHistoryTests.kt +++ b/app/src/androidTest/kotlin/org/wordpress/aztec/demo/tests/LinkHistoryTests.kt @@ -204,11 +204,14 @@ class LinkHistoryTests : BaseHistoryTest() { */ private fun addLinkAndVerify(editorPage: EditorPage, link: String, expected: String, name: String? = null) { editorPage.makeLink() - EditLinkPage().updateURL(link) + editorPage.threadSleep(throttleTime) + + val editLinkPage = EditLinkPage() + editLinkPage.updateURL(link) name?.let { - EditLinkPage().updateName(it) + editLinkPage.updateName(it) } - EditLinkPage().ok() + editLinkPage.ok() editorPage .toggleHtml() @@ -216,4 +219,4 @@ class LinkHistoryTests : BaseHistoryTest() { .toggleHtml() .threadSleep(throttleTime) } -} \ No newline at end of file +} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index fedc7ca55..b1da08d29 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -30,7 +30,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="top|start" - android:hint="@string/edit_hint" android:inputType="textCapSentences|textMultiLine" android:paddingEnd="16dp" android:paddingLeft="16dp" @@ -46,7 +45,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="top|start" - android:hint="@string/source_hint" android:inputType="textNoSuggestions|textMultiLine" android:paddingEnd="16dp" android:paddingLeft="16dp"