Skip to content

Commit 30f7195

Browse files
Add location permission and dialog handling for UploadCancelledTest
Co-authored-by: RitikaPahwa4444 <83745993+RitikaPahwa4444@users.noreply.github.com>
1 parent 482340a commit 30f7195

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

app/src/androidTest/java/fr/free/nrw/commons/UploadCancelledTest.kt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class UploadCancelledTest {
4040
var mGrantPermissionRule: GrantPermissionRule =
4141
GrantPermissionRule.grant(
4242
"android.permission.WRITE_EXTERNAL_STORAGE",
43+
"android.permission.ACCESS_FINE_LOCATION",
4344
)
4445

4546
private val device: UiDevice =
@@ -138,8 +139,23 @@ class UploadCancelledTest {
138139
)
139140
linearLayout3.perform(click())
140141

141-
// Wait for the upload screen to load
142-
UITestHelper.sleep(3000)
142+
// Wait for the upload screen to load and handle any permission dialogs
143+
UITestHelper.sleep(2000)
144+
145+
// Try to handle permission dialog if it appears (for location or camera)
146+
try {
147+
val allowButton = device.findObject(
148+
androidx.test.uiautomator.UiSelector()
149+
.textMatches("(?i)(allow|permit|ok)")
150+
.className("android.widget.Button")
151+
)
152+
if (allowButton.exists()) {
153+
allowButton.click()
154+
UITestHelper.sleep(1000)
155+
}
156+
} catch (e: Exception) {
157+
// No permission dialog, continue
158+
}
143159

144160
val pasteSensitiveTextInputEditText =
145161
onView(

0 commit comments

Comments
 (0)