mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 20:17:09 +00:00
refactor(mock): record DoubleTap and DoubleTapSelector actions
This commit is contained in:
1 parent
198c9364fa
commit
ffa84af591
1 file changed
+45
-27
@@ -11,37 +11,39 @@ import (
|
|||||||
type ActionKind string
|
type ActionKind string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ActionLaunch ActionKind = "launch"
|
ActionLaunch ActionKind = "launch"
|
||||||
ActionTerminate ActionKind = "terminate"
|
ActionTerminate ActionKind = "terminate"
|
||||||
ActionTap ActionKind = "tap"
|
ActionTap ActionKind = "tap"
|
||||||
ActionTapSelector ActionKind = "tap_selector"
|
ActionTapSelector ActionKind = "tap_selector"
|
||||||
ActionInputText ActionKind = "input_text"
|
ActionDoubleTap ActionKind = "double_tap"
|
||||||
ActionSwipe ActionKind = "swipe"
|
ActionDoubleTapSelector ActionKind = "double_tap_selector"
|
||||||
ActionPressKey ActionKind = "press_key"
|
ActionInputText ActionKind = "input_text"
|
||||||
ActionLongPress ActionKind = "long_press"
|
ActionSwipe ActionKind = "swipe"
|
||||||
ActionHierarchy ActionKind = "hierarchy"
|
ActionPressKey ActionKind = "press_key"
|
||||||
ActionScreenshot ActionKind = "screenshot"
|
ActionLongPress ActionKind = "long_press"
|
||||||
ActionSnapshot ActionKind = "snapshot"
|
ActionHierarchy ActionKind = "hierarchy"
|
||||||
ActionRecentLogs ActionKind = "recent_logs"
|
ActionScreenshot ActionKind = "screenshot"
|
||||||
ActionWaitForIdle ActionKind = "wait_for_idle"
|
ActionSnapshot ActionKind = "snapshot"
|
||||||
ActionHealth ActionKind = "health"
|
ActionRecentLogs ActionKind = "recent_logs"
|
||||||
ActionMetrics ActionKind = "metrics"
|
ActionWaitForIdle ActionKind = "wait_for_idle"
|
||||||
|
ActionHealth ActionKind = "health"
|
||||||
|
ActionMetrics ActionKind = "metrics"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Action struct {
|
type Action struct {
|
||||||
Kind ActionKind
|
Kind ActionKind
|
||||||
BundleID string
|
BundleID string
|
||||||
ClearState bool
|
ClearState bool
|
||||||
X, Y int
|
X, Y int
|
||||||
FromX, FromY int
|
FromX, FromY int
|
||||||
ToX, ToY int
|
ToX, ToY int
|
||||||
Duration time.Duration
|
Duration time.Duration
|
||||||
Selector string
|
Selector string
|
||||||
Text string
|
Text string
|
||||||
Key string
|
Key string
|
||||||
LogLevel string
|
LogLevel string
|
||||||
LogSince time.Time
|
LogSince time.Time
|
||||||
Idle time.Duration
|
Idle time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// Driver is an in-memory Driver implementation for unit tests.
|
// Driver is an in-memory Driver implementation for unit tests.
|
||||||
@@ -183,6 +185,22 @@ func (d *Driver) TapSelector(ctx context.Context, selector string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Driver) DoubleTap(ctx context.Context, x, y int) error {
|
||||||
|
if err := d.failure(ActionDoubleTap); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
d.record(Action{Kind: ActionDoubleTap, X: x, Y: y})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Driver) DoubleTapSelector(ctx context.Context, selector string) error {
|
||||||
|
if err := d.failure(ActionDoubleTapSelector); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
d.record(Action{Kind: ActionDoubleTapSelector, Selector: selector})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (d *Driver) InputText(ctx context.Context, text string) error {
|
func (d *Driver) InputText(ctx context.Context, text string) error {
|
||||||
if err := d.failure(ActionInputText); err != nil {
|
if err := d.failure(ActionInputText); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in new issue
Block a user