Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/src/androidTest/java/fr/free/nrw/commons/MainActivityTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class MainActivityTest {

@Test
fun testNearby() {
// Wait for the main activity to fully initialize
UITestHelper.sleep(1000)
Espresso
.onView(
Matchers.allOf(
Expand Down Expand Up @@ -104,6 +106,8 @@ class MainActivityTest {

@Test
fun testExplore() {
// Wait for the main activity to fully initialize
UITestHelper.sleep(1000)
Espresso
.onView(
Matchers.allOf(
Expand All @@ -125,6 +129,8 @@ class MainActivityTest {

@Test
fun testContributions() {
// Wait for the main activity to fully initialize
UITestHelper.sleep(1000)
Espresso
.onView(
Matchers.allOf(
Expand Down Expand Up @@ -175,6 +181,8 @@ class MainActivityTest {

@Test
fun testBookmarks() {
// Wait for the main activity to fully initialize
UITestHelper.sleep(1000)
Espresso
.onView(
Matchers.allOf(
Expand All @@ -193,6 +201,8 @@ class MainActivityTest {

@Test
fun testNotifications() {
// Wait for the main activity to fully initialize
UITestHelper.sleep(1000)
Espresso
.onView(
Matchers.allOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class UploadCancelledTest {
var mGrantPermissionRule: GrantPermissionRule =
GrantPermissionRule.grant(
"android.permission.WRITE_EXTERNAL_STORAGE",
"android.permission.ACCESS_FINE_LOCATION",
)

private val device: UiDevice =
Expand Down Expand Up @@ -104,6 +105,9 @@ class UploadCancelledTest {
)
actionMenuItemView.perform(click())

// Wait for the nearby list to load
UITestHelper.sleep(2000)

val recyclerView =
onView(
allOf(
Expand All @@ -117,6 +121,9 @@ class UploadCancelledTest {
),
)

// Wait for the button layout to expand
UITestHelper.sleep(1000)

val linearLayout3 =
onView(
allOf(
Expand All @@ -132,6 +139,24 @@ class UploadCancelledTest {
)
linearLayout3.perform(click())

// Wait for the upload screen to load and handle any permission dialogs
UITestHelper.sleep(2000)

// Try to handle permission dialog if it appears (for location or camera)
try {
val allowButton = device.findObject(
androidx.test.uiautomator.UiSelector()
.textMatches("(?i)(allow|permit|ok)")
.className("android.widget.Button")
)
if (allowButton.exists()) {
allowButton.click()
UITestHelper.sleep(1000)
}
} catch (e: Exception) {
// No permission dialog, continue
}

val pasteSensitiveTextInputEditText =
onView(
allOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class WelcomeActivityTest {
if (ConfigUtils.isBetaFlavour) {
onView(withId(R.id.button_ok))
.perform(ViewActions.click())
// Wait for the tutorial pager to load
UITestHelper.sleep(1000)
onView(withId(R.id.finishTutorialButton))
.check(matches(isDisplayed()))
}
Expand All @@ -49,6 +51,8 @@ class WelcomeActivityTest {
if (!ConfigUtils.isBetaFlavour) {
onView(withId(R.id.button_ok))
.perform(ViewActions.click())
// Wait for the tutorial pager to load
UITestHelper.sleep(1000)
onView(withId(R.id.finishTutorialButton))
.check(matches(not(isDisplayed())))
}
Expand All @@ -59,6 +63,8 @@ class WelcomeActivityTest {
if (ConfigUtils.isBetaFlavour) {
onView(withId(R.id.button_ok))
.perform(ViewActions.click())
// Wait for the tutorial pager to load
UITestHelper.sleep(1000)
onView(withId(R.id.finishTutorialButton))
.perform(ViewActions.click())
assertThat(activityRule.activity.isDestroyed, equalTo(true))
Expand Down Expand Up @@ -119,6 +125,8 @@ class WelcomeActivityTest {
if (viewPager.currentItem == 3) {
onView(withId(R.id.button_ok))
.perform(ViewActions.click())
// Wait for the tutorial pager to load
UITestHelper.sleep(1000)
onView(withId(R.id.finishTutorialButton))
.perform(ViewActions.click())
assertThat(activityRule.activity.isDestroyed, equalTo(true))
Expand Down
Loading