package atspi import ( "context" "errors" "fmt" "runtime" "testing" "time" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/bnema/neferwl/internal/ports" ) const ( stActive = 1 << stateActive stShowing = 1 << stateShowing ) // tree answers calls like an app: registry with one app (:1.5, pid 77) with // one showing frame whose links sit at window-relative extents. func answerTree(frameExt [4]int32, matches []ref, ext map[string][4]int32, roles map[string]uint32, noCollection bool) func(time.Time, time.Duration, []call) []reply { return func(_ time.Time, _ time.Duration, calls []call) []reply { out := make([]reply, len(calls)) for i, c := range calls { switch { case c.op == opChildren && c.name == registryName: out[i].refs = []ref{{":1.5", "/root"}, {":1.9", "/root"}} case c.op == opPID: out[i].u = map[string]uint32{":1.5": 77, ":1.9": 99}[c.name] case c.op == opChildren && c.path == "/root": out[i].refs = []ref{{":1.5", "/frame"}} case c.op == opRole && c.path == "/frame": out[i].u = roleFrame case c.op == opState && c.path == "/frame": out[i].state = stShowing | stActive case c.op == opExtents && c.path == "/frame": out[i].rect = frameExt case c.op == opMatches: if noCollection { out[i].err = &busError{name: "org.freedesktop.DBus.Error.UnknownMethod"} } else { out[i].refs = matches } case c.op == opChildren && c.path == "/frame": out[i].refs = matches case c.op == opChildren: case c.op == opRole: out[i].u = roles[c.path] case c.op == opState: out[i].state = stShowing | 1<