Skip to content

Commit bbaec9c

Browse files
committed
fix: device_smoke.py checks can't pass on a screen that hadn't loaded
From review of 3893913. The no-offer check on the number's screen now reads down to Report before it trusts an empty result, and the Report step checks Unblock is there before Undo and Block after it, so a slow or wrong screen fails instead of passing. Adds the More row step, which asks dumpsys for the top activity because mCurrentFocus is per display and the S22 lists a null one first. 10 of 10 passed on the S22.
1 parent 95e66c8 commit bbaec9c

3 files changed

Lines changed: 38 additions & 10 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ All notable changes to CallShield will be documented in this file.
2121
It used to open the GitHub form, which files a public issue instead.
2222
- New `scripts/device_smoke.py` runs the release's phone checks over adb
2323
and prints PASS or FAIL for each: sync, What's new, the recommended
24-
lists, both area code offers with Undo, a number with no offer, and Not
25-
spam's Undo. `--report` adds Report's block and Undo, and it sends a
26-
real report.
24+
lists, both area code offers with Undo, a number with no offer, Not
25+
spam's Undo and More's Report spam number. `--report` adds Report's block
26+
and Undo, and it sends a real report.
2727

2828
## v1.12.0 (2026-10-09)
2929

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ After `gh release create` has published the tag, write and sign the release noti
542542
python scripts/write_app_release.py
543543
```
544544

545-
With the new APK installed on a phone, run the device pass. It prints PASS or FAIL for each step (sync, What's new, the recommended lists, the area code offers and their Undo, Not spam's Undo) and exits 1 if any failed:
545+
With the new APK installed on a phone, run the device pass. It prints PASS or FAIL for each step (sync, What's new, the recommended lists, the area code offers and their Undo, Not spam's Undo, More's Report spam number) and exits 1 if any failed:
546546

547547
```powershell
548548
python scripts/device_smoke.py --serial <adb serial>

‎scripts/device_smoke.py‎

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,19 @@ def step_no_area_code(phone: Phone) -> None:
247247
if phone.find("Block all", contains=True, swipes=2):
248248
raise StepFailed(f"Lookup offered an area code for {NO_AREA_NUMBER}")
249249
phone.tap_label("Open full detail", swipes=2)
250-
found = phone.find("Block all", contains=True, swipes=2)
250+
# Read down to Report, so a screen that hadn't loaded can't pass as "no offer".
251+
labels: list[str] = []
252+
for _ in range(5):
253+
time.sleep(0.5)
254+
labels += [n.label for n in phone.nodes()]
255+
if "Report" in labels:
256+
break
257+
phone.scroll()
258+
labels += [n.label for n in phone.nodes()]
251259
phone.back()
252-
if found:
260+
if "Report" not in labels:
261+
raise StepFailed(f"the number's screen for {NO_AREA_NUMBER} never showed Report")
262+
if any("Block all" in label for label in labels):
253263
raise StepFailed(f"the number's screen offered an area code for {NO_AREA_NUMBER}")
254264

255265

@@ -262,6 +272,20 @@ def step_detail_area_code(phone: Phone) -> None:
262272
wildcards_empty(phone)
263273

264274

275+
def step_more_report_opens_lookup(phone: Phone) -> None:
276+
phone.tab("More")
277+
phone.to_top()
278+
phone.tap_label("Report spam number", swipes=10)
279+
time.sleep(1)
280+
# mCurrentFocus is per display and the first one listed can be null, so
281+
# ask which activity is on top instead.
282+
top = re.search(r"topResumedActivity=.*", phone.shell("dumpsys", "activity", "activities"))
283+
if top is None or PACKAGE not in top.group(0):
284+
raise StepFailed("Report spam number left the app")
285+
if phone.find("Phone number") is None or phone.find("Check number") is None:
286+
raise StepFailed("Report spam number didn't open Lookup")
287+
288+
265289
def my_reports(phone: Phone) -> list[str]:
266290
phone.tab("More")
267291
phone.to_top()
@@ -288,14 +312,17 @@ def step_report_blocks(phone: Phone, number: str) -> None:
288312
phone.tap_label("Open full detail", swipes=3)
289313
phone.tap_label("Report", swipes=3)
290314
time.sleep(2)
291-
message = phone.find("Blocked on this phone.", contains=True)
292-
if message is None:
315+
labels = [n.label for n in phone.nodes()]
316+
if not any("Blocked on this phone." in label for label in labels):
293317
raise StepFailed("Report's message doesn't say it blocked the number")
318+
# Block sits just above Report and turns into Unblock while blocked.
319+
if "Unblock" not in labels:
320+
raise StepFailed("Report didn't block the number")
294321
undo_snackbar(phone, "Report's block")
295322
time.sleep(1)
296-
blocked = phone.find("Unblock", swipes=3, down=False)
323+
labels = [n.label for n in phone.nodes()]
297324
phone.back()
298-
if blocked:
325+
if "Unblock" in labels or "Block" not in labels:
299326
raise StepFailed("the number is still blocked after Undo")
300327

301328

@@ -322,6 +349,7 @@ def main() -> int:
322349
("no area code offer for +81 42", lambda: step_no_area_code(phone)),
323350
("number's screen offers +33 1, and Undo removes it", lambda: step_detail_area_code(phone)),
324351
("Not spam then Undo sends nothing", lambda: step_not_spam_undo(phone, args.database_number)),
352+
("More's Report spam number opens Lookup", lambda: step_more_report_opens_lookup(phone)),
325353
]
326354
if args.report:
327355
steps.append(("Report blocks the number, and Undo unblocks it", lambda: step_report_blocks(phone, args.report)))

0 commit comments

Comments
 (0)