A tap that lands while a dialog is still animating in is dropped, and the click call succeeds either way, so the test walked on believing the dialog was dismissed. It was not: the recording shows the notification permission dialog still covering a success screen the test then spent two minutes failing to find, because a system dialog on top is the only window in the accessibility tree. Click these until the dialog is actually gone.
101 lines
4.0 KiB
Python
101 lines
4.0 KiB
Python
from time import sleep
|
|
|
|
import appium.webdriver
|
|
|
|
from etchdroid import actions as app
|
|
from etchdroid.config import Config
|
|
from etchdroid.fixtures import appium_service, driver
|
|
from etchdroid.utils import device_temp_sparse_file, scaled_image_mb, used, wait_for_element
|
|
|
|
used(appium_service)
|
|
|
|
|
|
def test_regular_flow(driver: appium.webdriver.Remote, usb_write_speed_mbps: float):
|
|
size = f"{scaled_image_mb(usb_write_speed_mbps)}M"
|
|
with device_temp_sparse_file(driver, "etchdroid_test_regular_flow_", ".iso", size) as image:
|
|
app.basic_flow(driver, image.filename)
|
|
app.wait_for_success(driver)
|
|
|
|
|
|
def test_skip_verification(driver: appium.webdriver.Remote, usb_write_speed_mbps: float):
|
|
size = f"{scaled_image_mb(usb_write_speed_mbps)}M"
|
|
with device_temp_sparse_file(driver, "etchdroid_test_skip_verification_", ".iso", size) as image:
|
|
app.basic_flow(driver, image.filename)
|
|
app.skip_lay_flat_sheet(driver)
|
|
|
|
skip_btn = app.get_skip_verify_button(driver)
|
|
skip_btn.click()
|
|
|
|
app.wait_for_success(driver)
|
|
|
|
|
|
def test_accept_notifications(driver: appium.webdriver.Remote, usb_write_speed_mbps: float):
|
|
# The banner only exists while the job runs, and the system permission dialog is slow,
|
|
# so give the job room to outlast the detour.
|
|
size = f"{scaled_image_mb(usb_write_speed_mbps, seconds=2 * Config.TARGET_WRITE_SECONDS)}M"
|
|
with device_temp_sparse_file(driver, "etchdroid_test_accept_notifications_", ".iso", size) as image:
|
|
app.basic_flow(driver, image.filename)
|
|
sure_btn = wait_for_element(
|
|
driver,
|
|
'//*[@resource-id="notifications_enable_button"]',
|
|
timeout=5,
|
|
)
|
|
sure_btn.click()
|
|
app.click_dialog_button(
|
|
driver,
|
|
'//android.widget.Button[@resource-id="com.android.permissioncontroller:id/permission_allow_button"]',
|
|
)
|
|
|
|
app.wait_for_success(driver)
|
|
|
|
|
|
def test_accept_then_deny_notifications(driver: appium.webdriver.Remote, usb_write_speed_mbps: float):
|
|
# Longer still: this flow detours through the system notification settings.
|
|
size = f"{scaled_image_mb(usb_write_speed_mbps, seconds=3 * Config.TARGET_WRITE_SECONDS)}M"
|
|
with device_temp_sparse_file(driver, "etchdroid_test_accept_then_deny_notifications_", ".iso", size) as image:
|
|
app.basic_flow(driver, image.filename)
|
|
sure_btn = wait_for_element(
|
|
driver,
|
|
'//*[@resource-id="notifications_enable_button"]',
|
|
timeout=5,
|
|
)
|
|
sure_btn.click()
|
|
app.click_dialog_button(
|
|
driver,
|
|
'//android.widget.Button[@resource-id="com.android.permissioncontroller:id/permission_deny_button"]',
|
|
)
|
|
sleep(0.5)
|
|
# Re-find rather than reusing sure_btn: returning from the permission dialog
|
|
# recomposes the banner, which makes the old reference stale.
|
|
wait_for_element(
|
|
driver,
|
|
'//*[@resource-id="notifications_enable_button"]',
|
|
timeout=5,
|
|
).click()
|
|
|
|
enable_switch = wait_for_element(
|
|
driver,
|
|
'//android.widget.TextView[@text="All EtchDroid notifications"]',
|
|
timeout=5,
|
|
)
|
|
enable_switch.click()
|
|
driver.back()
|
|
|
|
app.wait_for_success(driver)
|
|
|
|
|
|
def test_windows_image_warning(driver: appium.webdriver.Remote):
|
|
with device_temp_sparse_file(driver, "etchdroid_test_windows_image_warning_", ".iso", "1M") as image:
|
|
app.open_file(driver, image.path)
|
|
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.path)
|
|
app.select_first_usb_device_if_multiple(driver, timeout=5)
|
|
app.grant_usb_permission(driver)
|
|
app.confirm_write_image(driver)
|
|
app.skip_lay_flat_sheet(driver)
|
|
app.wait_for_fatal_error(driver)
|