appium: Add skip verification and large image tests

This commit is contained in:
Davide Depau committed 2025-04-01 22:45:52 +02:00
1 parent 056fdf9eb1
commit f3ebe52bf7
2 files changed
+50 -4

No files matched your search

+24 -1
View File
@@ -3,7 +3,8 @@ from selenium.common import (
TimeoutException,
)
from etchdroid.utils import wait_for_element, find_element
from etchdroid import package_name
from etchdroid.utils import wait_for_element, find_element, run_adb_command
def tap_write_image(driver: Remote):
@@ -70,3 +71,25 @@ def wait_for_write_progress(driver: Remote, timeout: int = 60):
def get_skip_verify_button(driver: Remote, timeout: int = 60):
return wait_for_element(driver, '//*[@resource-id="skip_verification_button"]', timeout=timeout)
def open_file(driver: Remote, file_name: str):
"""
Open a file in the EtchDroid app. Unfortunately, since EtchDroid does not request storage permissions, the file
won't be readable. It can still read the size and file name.
:param driver: The Appium driver instance.
:param file_name: The full path to the file to open.
"""
run_adb_command(
driver,
"am",
"start-activity",
"-a",
"android.intent.action.VIEW",
f"-n{package_name}/.ui.MainActivity",
"-d",
f"file://{file_name}",
"--grant-persistable-uri-permission",
"--grant-read-uri-permission",
)
+26 -3
View File
@@ -18,9 +18,32 @@ def test_regular_flow(driver: appium.webdriver.Remote):
app.wait_for_success(driver)
def test_windows_image_warning(driver: appium.webdriver.Remote):
with device_temp_sparse_file(driver, "etchdroid_test_image_windows_", ".iso", "1800M"):
def test_skip_verification(driver: appium.webdriver.Remote):
with device_temp_sparse_file(driver, "etchdroid_test_image_", ".iso", "1000M"):
app.tap_write_image(driver)
app.find_and_open_file(driver, "etchdroid_test_image_windows_", ".iso")
app.find_and_open_file(driver, "etchdroid_test_image_", ".iso")
app.select_first_usb_device_if_multiple(driver)
app.grant_usb_permission(driver)
app.confirm_write_image(driver)
app.skip_lay_flat_sheet(driver)
skip_btn = app.get_skip_verify_button(driver)
skip_btn.click()
app.wait_for_success(driver)
def test_windows_image_warning(driver: appium.webdriver.Remote):
with device_temp_sparse_file(driver, "etchdroid_test_image_windows_", ".iso", "1M") as image:
app.open_file(driver, image)
wait_for_element(driver, '//android.view.View[@resource-id="confirmWindowsAlert"]')
def test_image_too_large(driver: appium.webdriver.Remote):
with device_temp_sparse_file(driver, "etchdroid_test_image_too_large_", ".iso", "100G") as image:
app.open_file(driver, image)
app.select_first_usb_device_if_multiple(driver)
app.grant_usb_permission(driver)
app.confirm_write_image(driver)
app.skip_lay_flat_sheet(driver)
app.wait_for_fatal_error(driver)