Documentation
¶
Overview ¶
Package tasks provides built-in task implementations for common Android testing operations.
Package tasks provides plugin foundation for YAML-based task definitions. This enables extensibility beyond the built-in tasks.
Package tasks provides a task registry with built-in tasks and plugin foundation for VIS (Visual Intelligent System) Android testing.
Index ¶
Constants ¶
const ExamplePluginYAML = `` /* 537-byte string literal not displayed */
ExamplePluginYAML shows the expected format for plugin task definitions. This is for documentation purposes.
Variables ¶
var ErrTaskNotFound = errors.New("task not found")
ErrTaskNotFound is returned when attempting to execute an unregistered task.
Functions ¶
func RegisterPlugin ¶
func RegisterPlugin(registry PluginRegistry, plugin PluginTaskDefinition) error
RegisterPlugin registers a plugin task definition in the registry. The plugin's steps are validated against existing tasks in the registry. Returns an error if any step references an unknown task.
Types ¶
type ParamSpec ¶
type ParamSpec struct {
Name string `json:"name"`
Required bool `json:"required"`
Default string `json:"default,omitempty"`
Description string `json:"description"`
}
ParamSpec defines a task parameter specification.
type PluginRegistry ¶
type PluginRegistry interface {
Register(task TaskDefinition)
Get(name string) (TaskDefinition, bool)
}
PluginRegistry provides an interface for the plugin to register tasks. This allows plugins to register themselves without directly accessing the TaskRegistry.
type PluginStep ¶
PluginStep represents a step in a plugin task. Each step references a built-in task by name.
type PluginTaskDefinition ¶
type PluginTaskDefinition struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Parameters []ParamSpec `yaml:"parameters,omitempty"`
Steps []PluginStep `yaml:"steps"`
}
PluginTaskDefinition is the YAML format for plugin tasks. It allows users to define custom tasks as sequences of built-in tasks.
func LoadPluginFile ¶
func LoadPluginFile(path string) (PluginTaskDefinition, error)
LoadPluginFile parses a YAML file containing a plugin task definition. Returns the plugin definition or an error if parsing fails.
func LoadPluginYAML ¶
func LoadPluginYAML(data []byte) (PluginTaskDefinition, error)
LoadPluginYAML parses YAML bytes containing a plugin task definition. This is useful when plugins are loaded from sources other than files.
type TaskDefinition ¶
type TaskDefinition struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters []ParamSpec `json:"parameters,omitempty"`
Execute TaskFunc `json:"-"`
}
TaskDefinition describes a built-in or plugin task. It includes metadata about the task and the execution function.
func BuiltinTasks ¶
func BuiltinTasks() []TaskDefinition
BuiltinTasks returns all built-in task definitions. These tasks are automatically registered in NewTaskRegistry.
type TaskFunc ¶
TaskFunc is the signature for task execution functions. It receives a context for cancellation, a deviceID for ADB operations, and args for task-specific parameters.
type TaskRegistry ¶
type TaskRegistry struct {
// contains filtered or unexported fields
}
TaskRegistry manages registered tasks with thread-safe operations. It supports both built-in tasks and dynamically loaded plugin tasks.
func NewTaskRegistry ¶
func NewTaskRegistry() *TaskRegistry
NewTaskRegistry creates a new registry with built-in tasks registered. Built-in tasks are registered automatically at initialization.
func (*TaskRegistry) Execute ¶
func (r *TaskRegistry) Execute(ctx context.Context, name string, ctrl *adb.Controller, args []string) error
Execute runs a task by name with the given context, device, and arguments. Returns ErrTaskNotFound if the task is not registered, or the task's error if execution fails.
func (*TaskRegistry) Get ¶
func (r *TaskRegistry) Get(name string) (TaskDefinition, bool)
Get retrieves a task definition by name. Returns the task definition and true if found, or empty definition and false if not found.
func (*TaskRegistry) List ¶
func (r *TaskRegistry) List() []string
List returns all registered task names. The returned slice is a copy and can be safely modified.
func (*TaskRegistry) Register ¶
func (r *TaskRegistry) Register(task TaskDefinition)
Register adds a task definition to the registry. If a task with the same name already exists, it will be overwritten.