"""货主安卓端 fixture — Appium + 登录态复用。"""

import pytest
from tests.app._shared import create_driver, make_ensure_logged_in, save_failure_screenshot

from tests.app._shared import pytest_runtest_makereport  # noqa: F401


@pytest.fixture
def driver(shipper_android_config, request):
    """货主安卓端 driver。"""
    cfg = shipper_android_config
    d = None
    try:
        d = create_driver(cfg, platform="android")
        yield d
        save_failure_screenshot(d, cfg, "android", request)
    finally:
        if d is not None:
            d.quit()


@pytest.fixture
def ensure_logged_in(shipper_android_config, config):
    """确保已登录态（货主角色）。"""
    fn = make_ensure_logged_in(shipper_android_config, config, account_role="shipper")
    return lambda d: fn(d)
