feat: replace marketplace OCU with Cua Driver 0.36.0
This commit is contained in:
1 parent
fd92bafcb5
commit
c89588a80d
19 files changed
+2563
-40
No files matched your search
@@ -0,0 +1,61 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestUnknownAndRefusedAreNotConfirmed(t *testing.T) {
|
||||
cases := []struct{ effect, execution, side string }{{"confirmed", "completed", "confirmed"}, {"partial", "partial", "confirmed"}, {"unverifiable", "completed", "possible"}, {"suspected_noop", "completed", "possible"}, {"refused", "not_started", "none"}, {"", "unknown", "possible"}}
|
||||
for _, c := range cases {
|
||||
r := actionReceipt(obj{"structuredContent": obj{"effect": c.effect}}, true)
|
||||
if r["execution"] != c.execution || r["side_effect"] != c.side || r["retryable"] != false {
|
||||
t.Fatalf("%s: %v", c.effect, r)
|
||||
}
|
||||
}
|
||||
}
|
||||
func TestAttachmentCannotEscape(t *testing.T) {
|
||||
for _, s := range []string{"../out.png", "..\\out.png", "C:out.png", "a.png:stream", "", "a.png ", "a.jpg"} {
|
||||
if validFilename(s) {
|
||||
t.Fatal(s)
|
||||
}
|
||||
}
|
||||
if !validFilename("留档.png") {
|
||||
t.Fatal("plain Unicode PNG rejected")
|
||||
}
|
||||
}
|
||||
func TestUnexposedAndMissingTargetRejected(t *testing.T) {
|
||||
a := newAdapter(nil)
|
||||
for _, c := range []struct {
|
||||
name string
|
||||
args obj
|
||||
}{{"run_script", obj{}}, {"click", obj{"pid": 1, "window_id": 2, "scope": "desktop"}}, {"get_window_state", obj{"pid": 1}}, {"click", obj{"pid": 0, "window_id": 2}}} {
|
||||
if a.validate(c.name, c.args) == nil {
|
||||
t.Fatal(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
func TestSupportedArguments(t *testing.T) {
|
||||
a := newAdapter(nil)
|
||||
if err := a.validate("click", obj{"pid": 1, "window_id": 2, "element_token": "s00000001:0"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBackgroundPreflightVsActuatorUncertainty(t *testing.T) {
|
||||
r := obj{"isError": true, "structuredContent": obj{"code": "background_unavailable", "event_kind": "mouse_scroll"}}
|
||||
if actionReceipt(r, true)["execution"] != "not_started" {
|
||||
t.Fatal("preflight refusal must be explicit")
|
||||
}
|
||||
object(r["structuredContent"])["cause"] = "unknown actuator failure"
|
||||
if actionReceipt(r, true)["execution"] != "unknown" {
|
||||
t.Fatal("actuator uncertainty must not be hidden")
|
||||
}
|
||||
}
|
||||
|
||||
func TestClickModesAreDisjoint(t *testing.T) {
|
||||
a := newAdapter(nil)
|
||||
if a.validate("click", obj{"pid": 1, "window_id": 2, "element_token": "s1:0", "capture_id": "capture"}) == nil {
|
||||
t.Fatal("mixed click modes")
|
||||
}
|
||||
if a.validate("click_at", obj{"pid": 1, "window_id": 2, "x": 5, "y": 5}) == nil {
|
||||
t.Fatal("pixel action lacks capture")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user