Documentation
¶
Overview ¶
Package enginetest provides deterministic host-side test doubles for the execution engine and other callers of the frozen device contract.
Index ¶
- Variables
- func PNGFixture(marker string) []byte
- type Action
- type DriverScript
- type FakeClock
- type FakeDriver
- func (f *FakeDriver) Actions() []Action
- func (f *FakeDriver) AddMedia(ctx context.Context, request device.AddMediaRequest) error
- func (f *FakeDriver) BackPress(ctx context.Context) error
- func (f *FakeDriver) Capabilities() device.Capabilities
- func (f *FakeDriver) ClearAppState(ctx context.Context, request device.AppRequest) error
- func (f *FakeDriver) ClearKeychain(ctx context.Context) error
- func (f *FakeDriver) Close(ctx context.Context) error
- func (f *FakeDriver) CollectCrashArtifacts(ctx context.Context, request device.ArtifactRequest) ([]device.Artifact, error)
- func (f *FakeDriver) ContentDescriptor(ctx context.Context, request device.ContentDescriptorRequest) (device.TreeNode, error)
- func (f *FakeDriver) DeviceInfo(ctx context.Context) (device.DeviceInfo, error)
- func (f *FakeDriver) Enqueue(script DriverScript)
- func (f *FakeDriver) EraseText(ctx context.Context, request device.EraseTextRequest) error
- func (f *FakeDriver) HideKeyboard(ctx context.Context) error
- func (f *FakeDriver) InputText(ctx context.Context, request device.InputTextRequest) error
- func (f *FakeDriver) IsAirplaneModeEnabled(ctx context.Context) (bool, error)
- func (f *FakeDriver) IsKeyboardVisible(ctx context.Context, request device.KeyboardRequest) (bool, error)
- func (f *FakeDriver) IsShutdown(ctx context.Context) (bool, error)
- func (f *FakeDriver) KillApp(ctx context.Context, request device.AppRequest) error
- func (f *FakeDriver) LaunchApp(ctx context.Context, request device.LaunchAppRequest) error
- func (f *FakeDriver) LongPress(ctx context.Context, request device.LongPressRequest) error
- func (f *FakeDriver) Name() string
- func (f *FakeDriver) Open(ctx context.Context) error
- func (f *FakeDriver) OpenLink(ctx context.Context, request device.OpenLinkRequest) error
- func (f *FakeDriver) PressKey(ctx context.Context, request device.PressKeyRequest) error
- func (f *FakeDriver) QueryOnDeviceElements(ctx context.Context, request device.QueryRequest) ([]device.TreeNode, error)
- func (f *FakeDriver) ResetProxy(ctx context.Context) error
- func (f *FakeDriver) ScrollVertical(ctx context.Context, request device.ScrollVerticalRequest) error
- func (f *FakeDriver) SetAirplaneMode(ctx context.Context, request device.AirplaneModeRequest) error
- func (f *FakeDriver) SetAndroidChromeDevToolsEnabled(ctx context.Context, request device.ChromeDevToolsRequest) error
- func (f *FakeDriver) SetLocation(ctx context.Context, request device.Location) error
- func (f *FakeDriver) SetOrientation(ctx context.Context, request device.Orientation) error
- func (f *FakeDriver) SetPermissions(ctx context.Context, request device.PermissionsRequest) error
- func (f *FakeDriver) SetProxy(ctx context.Context, request device.Proxy) error
- func (f *FakeDriver) StartDeviceLogCapture(ctx context.Context, request device.DeviceLogRequest) (device.CaptureID, error)
- func (f *FakeDriver) StartScreenRecording(ctx context.Context, request device.ScreenRecordingRequest) (device.CaptureID, error)
- func (f *FakeDriver) StopApp(ctx context.Context, request device.AppRequest) error
- func (f *FakeDriver) StopDeviceLogCapture(ctx context.Context, request device.CaptureID) ([]device.Artifact, error)
- func (f *FakeDriver) Swipe(ctx context.Context, request device.SwipeRequest) error
- func (f *FakeDriver) TakeScreenshot(ctx context.Context, request device.ScreenshotRequest) ([]byte, error)
- func (f *FakeDriver) Tap(ctx context.Context, request device.TapRequest) error
- func (f *FakeDriver) WaitForAppToSettle(ctx context.Context, request device.SettleRequest) (*device.ViewHierarchy, error)
- func (f *FakeDriver) WaitUntilScreenIsStatic(ctx context.Context, request device.ScreenStaticRequest) (bool, error)
- type FakeTimer
- type Method
- type Result
Constants ¶
This section is empty.
Variables ¶
var ErrFakeTimerStopped = errors.New("fake timer stopped")
ErrFakeTimerStopped is returned when waiting on an explicitly stopped timer.
Functions ¶
func PNGFixture ¶
PNGFixture is a REAL PNG signature followed by a marker that keeps two fixtures distinguishable.
A real PNG signature lets tests catch extension and content-type mistakes while the marker keeps fixtures distinguishable.
Types ¶
type DriverScript ¶
type DriverScript struct {
Name []string
Open []Result[struct{}]
Close []Result[struct{}]
DeviceInfo []Result[device.DeviceInfo]
LaunchApp []Result[struct{}]
StopApp []Result[struct{}]
KillApp []Result[struct{}]
ClearAppState []Result[struct{}]
ClearKeychain []Result[struct{}]
Tap []Result[struct{}]
LongPress []Result[struct{}]
PressKey []Result[struct{}]
ContentDescriptor []Result[device.TreeNode]
ScrollVertical []Result[struct{}]
IsKeyboardVisible []Result[bool]
Swipe []Result[struct{}]
BackPress []Result[struct{}]
InputText []Result[struct{}]
OpenLink []Result[struct{}]
HideKeyboard []Result[struct{}]
TakeScreenshot []Result[[]byte]
StartScreenRecording []Result[device.CaptureID]
SetLocation []Result[struct{}]
SetOrientation []Result[struct{}]
EraseText []Result[struct{}]
SetProxy []Result[struct{}]
ResetProxy []Result[struct{}]
IsShutdown []Result[bool]
WaitUntilScreenIsStatic []Result[bool]
WaitForAppToSettle []Result[*device.ViewHierarchy]
Capabilities []device.Capabilities
SetPermissions []Result[struct{}]
AddMedia []Result[struct{}]
IsAirplaneModeEnabled []Result[bool]
SetAirplaneMode []Result[struct{}]
SetAndroidChromeDevToolsEnabled []Result[struct{}]
QueryOnDeviceElements []Result[[]device.TreeNode]
StartDeviceLogCapture []Result[device.CaptureID]
StopDeviceLogCapture []Result[[]device.Artifact]
CollectCrashArtifacts []Result[[]device.Artifact]
}
DriverScript appends typed FIFO results to a FakeDriver. Empty queues make their operation return its zero value and a nil error.
type FakeClock ¶
type FakeClock struct {
// contains filtered or unexported fields
}
FakeClock is a manually advanced, concurrency-safe clock for deterministic engine tests.
func NewFakeClock ¶
NewFakeClock starts a clock at the supplied instant.
func (*FakeClock) Advance ¶
Advance moves time forward and fires every timer at or before the new time.
func (*FakeClock) PendingTimers ¶
PendingTimers returns the number of registered deadlines that have not fired.
type FakeDriver ¶
type FakeDriver struct {
// contains filtered or unexported fields
}
FakeDriver is a concurrency-safe, deterministic device test double.
func NewFakeDriver ¶
func NewFakeDriver() *FakeDriver
NewFakeDriver returns a driver with empty scripts and a sequence starting at one.
func (*FakeDriver) Actions ¶
func (f *FakeDriver) Actions() []Action
Actions returns an isolated snapshot of accepted calls.
func (*FakeDriver) AddMedia ¶
func (f *FakeDriver) AddMedia(ctx context.Context, request device.AddMediaRequest) error
func (*FakeDriver) Capabilities ¶
func (f *FakeDriver) Capabilities() device.Capabilities
func (*FakeDriver) ClearAppState ¶
func (f *FakeDriver) ClearAppState(ctx context.Context, request device.AppRequest) error
func (*FakeDriver) ClearKeychain ¶
func (f *FakeDriver) ClearKeychain(ctx context.Context) error
func (*FakeDriver) CollectCrashArtifacts ¶
func (f *FakeDriver) CollectCrashArtifacts(ctx context.Context, request device.ArtifactRequest) ([]device.Artifact, error)
func (*FakeDriver) ContentDescriptor ¶
func (f *FakeDriver) ContentDescriptor(ctx context.Context, request device.ContentDescriptorRequest) (device.TreeNode, error)
func (*FakeDriver) DeviceInfo ¶
func (f *FakeDriver) DeviceInfo(ctx context.Context) (device.DeviceInfo, error)
func (*FakeDriver) Enqueue ¶
func (f *FakeDriver) Enqueue(script DriverScript)
Enqueue atomically appends a typed batch of scripted results.
func (*FakeDriver) EraseText ¶
func (f *FakeDriver) EraseText(ctx context.Context, request device.EraseTextRequest) error
func (*FakeDriver) HideKeyboard ¶
func (f *FakeDriver) HideKeyboard(ctx context.Context) error
func (*FakeDriver) InputText ¶
func (f *FakeDriver) InputText(ctx context.Context, request device.InputTextRequest) error
func (*FakeDriver) IsAirplaneModeEnabled ¶
func (f *FakeDriver) IsAirplaneModeEnabled(ctx context.Context) (bool, error)
func (*FakeDriver) IsKeyboardVisible ¶
func (f *FakeDriver) IsKeyboardVisible(ctx context.Context, request device.KeyboardRequest) (bool, error)
func (*FakeDriver) IsShutdown ¶
func (f *FakeDriver) IsShutdown(ctx context.Context) (bool, error)
func (*FakeDriver) KillApp ¶
func (f *FakeDriver) KillApp(ctx context.Context, request device.AppRequest) error
func (*FakeDriver) LaunchApp ¶
func (f *FakeDriver) LaunchApp(ctx context.Context, request device.LaunchAppRequest) error
func (*FakeDriver) LongPress ¶
func (f *FakeDriver) LongPress(ctx context.Context, request device.LongPressRequest) error
func (*FakeDriver) Name ¶
func (f *FakeDriver) Name() string
func (*FakeDriver) OpenLink ¶
func (f *FakeDriver) OpenLink(ctx context.Context, request device.OpenLinkRequest) error
func (*FakeDriver) PressKey ¶
func (f *FakeDriver) PressKey(ctx context.Context, request device.PressKeyRequest) error
func (*FakeDriver) QueryOnDeviceElements ¶
func (f *FakeDriver) QueryOnDeviceElements(ctx context.Context, request device.QueryRequest) ([]device.TreeNode, error)
func (*FakeDriver) ResetProxy ¶
func (f *FakeDriver) ResetProxy(ctx context.Context) error
func (*FakeDriver) ScrollVertical ¶
func (f *FakeDriver) ScrollVertical(ctx context.Context, request device.ScrollVerticalRequest) error
func (*FakeDriver) SetAirplaneMode ¶
func (f *FakeDriver) SetAirplaneMode(ctx context.Context, request device.AirplaneModeRequest) error
func (*FakeDriver) SetAndroidChromeDevToolsEnabled ¶
func (f *FakeDriver) SetAndroidChromeDevToolsEnabled(ctx context.Context, request device.ChromeDevToolsRequest) error
func (*FakeDriver) SetLocation ¶
func (*FakeDriver) SetOrientation ¶
func (f *FakeDriver) SetOrientation(ctx context.Context, request device.Orientation) error
func (*FakeDriver) SetPermissions ¶
func (f *FakeDriver) SetPermissions(ctx context.Context, request device.PermissionsRequest) error
func (*FakeDriver) StartDeviceLogCapture ¶
func (f *FakeDriver) StartDeviceLogCapture(ctx context.Context, request device.DeviceLogRequest) (device.CaptureID, error)
func (*FakeDriver) StartScreenRecording ¶
func (f *FakeDriver) StartScreenRecording(ctx context.Context, request device.ScreenRecordingRequest) (device.CaptureID, error)
func (*FakeDriver) StopApp ¶
func (f *FakeDriver) StopApp(ctx context.Context, request device.AppRequest) error
func (*FakeDriver) StopDeviceLogCapture ¶
func (*FakeDriver) Swipe ¶
func (f *FakeDriver) Swipe(ctx context.Context, request device.SwipeRequest) error
func (*FakeDriver) TakeScreenshot ¶
func (f *FakeDriver) TakeScreenshot(ctx context.Context, request device.ScreenshotRequest) ([]byte, error)
func (*FakeDriver) Tap ¶
func (f *FakeDriver) Tap(ctx context.Context, request device.TapRequest) error
func (*FakeDriver) WaitForAppToSettle ¶
func (f *FakeDriver) WaitForAppToSettle(ctx context.Context, request device.SettleRequest) (*device.ViewHierarchy, error)
func (*FakeDriver) WaitUntilScreenIsStatic ¶
func (f *FakeDriver) WaitUntilScreenIsStatic(ctx context.Context, request device.ScreenStaticRequest) (bool, error)
type FakeTimer ¶
type FakeTimer struct {
// contains filtered or unexported fields
}
FakeTimer is one deadline registered with a FakeClock.
func (*FakeTimer) Done ¶
func (t *FakeTimer) Done() <-chan struct{}
Done closes when the fake clock reaches the timer deadline.
type Method ¶
type Method string
Method names one device.Driver operation in an action trace.
const ( MethodName Method = "Name" MethodOpen Method = "Open" MethodClose Method = "Close" MethodDeviceInfo Method = "DeviceInfo" MethodLaunchApp Method = "LaunchApp" MethodStopApp Method = "StopApp" MethodKillApp Method = "KillApp" MethodClearAppState Method = "ClearAppState" MethodClearKeychain Method = "ClearKeychain" MethodTap Method = "Tap" MethodLongPress Method = "LongPress" MethodPressKey Method = "PressKey" MethodContentDescriptor Method = "ContentDescriptor" MethodScrollVertical Method = "ScrollVertical" MethodIsKeyboardVisible Method = "IsKeyboardVisible" MethodSwipe Method = "Swipe" MethodBackPress Method = "BackPress" MethodInputText Method = "InputText" MethodOpenLink Method = "OpenLink" MethodHideKeyboard Method = "HideKeyboard" MethodTakeScreenshot Method = "TakeScreenshot" MethodStartScreenRecording Method = "StartScreenRecording" MethodSetLocation Method = "SetLocation" MethodSetOrientation Method = "SetOrientation" MethodEraseText Method = "EraseText" MethodSetProxy Method = "SetProxy" MethodResetProxy Method = "ResetProxy" MethodIsShutdown Method = "IsShutdown" MethodWaitUntilScreenIsStatic Method = "WaitUntilScreenIsStatic" MethodWaitForAppToSettle Method = "WaitForAppToSettle" MethodCapabilities Method = "Capabilities" MethodSetPermissions Method = "SetPermissions" MethodAddMedia Method = "AddMedia" MethodIsAirplaneModeEnabled Method = "IsAirplaneModeEnabled" MethodSetAirplaneMode Method = "SetAirplaneMode" MethodSetAndroidChromeDevToolsEnabled Method = "SetAndroidChromeDevToolsEnabled" MethodQueryOnDeviceElements Method = "QueryOnDeviceElements" MethodStartDeviceLogCapture Method = "StartDeviceLogCapture" MethodStopDeviceLogCapture Method = "StopDeviceLogCapture" MethodCollectCrashArtifacts Method = "CollectCrashArtifacts" )