SHA256
feat(android): align native preview with measured PWA design
This commit is contained in:
1 parent
bd0e4cc4fb
commit
7ac9882307
30 files changed
+2793
-750
No files matched your search
+27
-11
@@ -20,25 +20,41 @@ import urllib.request
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
REVISION = "10bfef7686ed7303b4c74c7fcc55a5eb16356c9d"
|
||||
SCREENSHOTS = ("native-dashboard.png",) + tuple(
|
||||
f"{page}-{theme}.png" for page in ("login", "dashboard", "tasks", "notes", "shopping") for theme in ("light", "dark"))
|
||||
VISUAL_OUTPUTS = SCREENSHOTS + ("viewport.json",)
|
||||
|
||||
|
||||
def prepare_android_screenshots(app_output):
|
||||
additional = app_output / "connected_android_test_additional_output/integrationAndroidTest"
|
||||
screenshots = app_output / "native-screenshots"
|
||||
# Never accept a previous run's screenshot as current evidence.
|
||||
for stale in additional.rglob("native-dashboard.png"):
|
||||
stale.unlink()
|
||||
(screenshots / "native-dashboard.png").unlink(missing_ok=True)
|
||||
for name in VISUAL_OUTPUTS:
|
||||
for stale in additional.rglob(name):
|
||||
stale.unlink()
|
||||
(screenshots / name).unlink(missing_ok=True)
|
||||
return additional, screenshots
|
||||
|
||||
|
||||
def collect_native_screenshot(additional, screenshots):
|
||||
captures = list(additional.rglob("native-dashboard.png"))
|
||||
assert len(captures) == 1, "Missing or ambiguous native fixture screenshot"
|
||||
capture = captures[0].read_bytes()
|
||||
assert capture.startswith(b"\x89PNG\r\n\x1a\n"), "Invalid native fixture screenshot"
|
||||
def collect_native_screenshot(additional, screenshots, gallery=False):
|
||||
names = VISUAL_OUTPUTS if gallery else ("native-dashboard.png",)
|
||||
validated = {}
|
||||
parents = set()
|
||||
for name in names:
|
||||
captures = list(additional.rglob(name))
|
||||
assert len(captures) == 1, f"Missing or ambiguous native fixture screenshot: {name}"
|
||||
capture = captures[0].read_bytes()
|
||||
if name.endswith(".png"):
|
||||
assert capture.startswith(b"\x89PNG\r\n\x1a\n"), "Invalid native fixture screenshot"
|
||||
else:
|
||||
viewport = json.loads(capture)
|
||||
assert viewport["widthPx"] > 0 and viewport["heightPx"] > 0 and viewport["density"] > 0
|
||||
parents.add(captures[0].parent)
|
||||
validated[name] = capture
|
||||
assert len(parents) == 1, "Mixed-device native gallery evidence"
|
||||
screenshots.mkdir(parents=True, exist_ok=True)
|
||||
(screenshots / "native-dashboard.png").write_bytes(capture)
|
||||
for name, capture in validated.items():
|
||||
(screenshots / name).write_bytes(capture)
|
||||
|
||||
|
||||
def run(upstream, android, cookie_without_secure=False):
|
||||
@@ -152,8 +168,8 @@ def run(upstream, android, cookie_without_secure=False):
|
||||
raise RuntimeError("Android integration tests failed. Inspect the Gradle test report.")
|
||||
reports = app_output / "androidTest-results/connected/integration"
|
||||
subprocess.run(["python3", str(ROOT / "scripts/verify-test-results.py"),
|
||||
str(reports), "--minimum", "7"], check=True)
|
||||
collect_native_screenshot(additional, screenshots)
|
||||
str(reports), "--minimum", "10"], check=True)
|
||||
collect_native_screenshot(additional, screenshots, gallery=True)
|
||||
finally:
|
||||
subprocess.run([str(adb), "reverse", "--remove", f"tcp:{port}"], check=False)
|
||||
subprocess.run([str(adb), "reverse", "--remove", f"tcp:{ready['idpPort']}"], check=False)
|
||||
|
||||
Reference in new issue
Block a user