mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 20:17:09 +00:00
refactor(runner,android): drop unused bringToForeground return; grep no-match yields empty
bringToForeground's bool return was read by no caller. FocusedWindowPackage's on-device grep exited 1 on no match, surfacing as an error instead of the documented ""; add || true.
This commit is contained in:
1 parent
c61114b2bb
commit
75281d8e16
2 files changed
+6
-7
No files matched your search
@@ -456,8 +456,9 @@ func FocusedWindowPackage(ctx context.Context, serial string) (string, error) {
|
|||||||
}
|
}
|
||||||
// Grep the focus line on-device: the full dumpsys window output is large and
|
// Grep the focus line on-device: the full dumpsys window output is large and
|
||||||
// this runs on the per-step scope guard, so transferring it whole would add
|
// this runs on the per-step scope guard, so transferring it whole would add
|
||||||
// latency to every step.
|
// latency to every step. `|| true` keeps a no-match (grep exit 1) from
|
||||||
output, err := exec.CommandContext(ctx, adb, adbArgs(serial, "shell", "dumpsys window | grep mCurrentFocus")...).Output()
|
// surfacing as an error so it yields "" per the contract.
|
||||||
|
output, err := exec.CommandContext(ctx, adb, adbArgs(serial, "shell", "dumpsys window | grep mCurrentFocus || true")...).Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -535,18 +535,16 @@ func awaitForeground(ctx context.Context, options Options, logger *slog.Logger,
|
|||||||
|
|
||||||
// bringToForeground returns the app under test to the foreground. It first
|
// bringToForeground returns the app under test to the foreground. It first
|
||||||
// presses BACK to dismiss any modal system dialog (a relaunch alone does not
|
// presses BACK to dismiss any modal system dialog (a relaunch alone does not
|
||||||
// close one), then relaunches and waits for the UI to settle. Returns true
|
// close one), then relaunches and waits for the UI to settle.
|
||||||
// when the relaunch itself succeeded.
|
func bringToForeground(ctx context.Context, options Options, logger *slog.Logger, stepIndex int) {
|
||||||
func bringToForeground(ctx context.Context, options Options, logger *slog.Logger, stepIndex int) bool {
|
|
||||||
if err := options.Driver.PressKey(ctx, "back"); err != nil {
|
if err := options.Driver.PressKey(ctx, "back"); err != nil {
|
||||||
logger.Warn("dismiss key before relaunch failed", "step", stepIndex, "err", err)
|
logger.Warn("dismiss key before relaunch failed", "step", stepIndex, "err", err)
|
||||||
}
|
}
|
||||||
if err := options.Driver.Launch(ctx, options.BundleID, false, nil); err != nil {
|
if err := options.Driver.Launch(ctx, options.BundleID, false, nil); err != nil {
|
||||||
logger.Warn("relaunch failed", "step", stepIndex, "err", err)
|
logger.Warn("relaunch failed", "step", stepIndex, "err", err)
|
||||||
return false
|
return
|
||||||
}
|
}
|
||||||
settleForForeground(ctx, options)
|
settleForForeground(ctx, options)
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// settleForForeground waits one idle window for the UI to settle, bounding the
|
// settleForForeground waits one idle window for the UI to settle, bounding the
|
||||||
|
|||||||
Reference in new issue
Block a user