mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
test(runner): cover apply-time foreground skip and appIsForeground table
Adds a Run-level test asserting no tap reaches the driver while a system overlay holds focus (guards against the skip branch being dead-coded), plus a decision-table test for appIsForeground. Adds ForegroundErr/FocusedWindowErr to the mock driver so the guard's transient-read paths are exercised.
This commit is contained in:
1 parent
663f9e7180
commit
d45f5d4869
2 files changed
+84
No files matched your search
@@ -73,6 +73,11 @@ type Driver struct {
|
||||
ForegroundResults []string
|
||||
foregroundIndex int
|
||||
|
||||
// ForegroundErr and FocusedWindowErr, when set, make the respective check
|
||||
// return that error so tests can cover the guard's transient-read paths.
|
||||
ForegroundErr error
|
||||
FocusedWindowErr error
|
||||
|
||||
// FocusedWindowResults is consumed one entry per FocusedWindowApp call
|
||||
// (the last entry repeats). When empty, FocusedWindowApp mirrors the
|
||||
// last ForegroundApp result, so the startup gate treats the window as
|
||||
@@ -125,6 +130,9 @@ func (d *Driver) Launch(_ context.Context, bundleID string, clearState bool, _ m
|
||||
func (d *Driver) ForegroundApp(_ context.Context) (string, error) {
|
||||
d.mutex.Lock()
|
||||
defer d.mutex.Unlock()
|
||||
if d.ForegroundErr != nil {
|
||||
return "", d.ForegroundErr
|
||||
}
|
||||
if len(d.ForegroundResults) == 0 {
|
||||
d.lastForeground = ""
|
||||
return "", nil
|
||||
@@ -142,6 +150,9 @@ func (d *Driver) FocusedWindowApp(_ context.Context) (string, error) {
|
||||
d.mutex.Lock()
|
||||
defer d.mutex.Unlock()
|
||||
d.focusedWindowCalls++
|
||||
if d.FocusedWindowErr != nil {
|
||||
return "", d.FocusedWindowErr
|
||||
}
|
||||
if len(d.FocusedWindowResults) == 0 {
|
||||
return d.lastForeground, nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user