Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@codegen-sh
Copy link

@codegen-sh codegen-sh bot commented Jun 8, 2025

πŸš€ New Feature: Stream Command for HID Event Sequences

This PR adds a powerful new stream command to AXe that enables executing complex sequences of HID events from JSON input, supporting both batch and streaming execution modes.

✨ Key Features

  • πŸ“ JSON-based event sequences - Define complex automation workflows in JSON
  • 🎯 All HID event types supported - tap, swipe, type, key, button, touch, delay, gesture
  • ⚑ Dual execution modes - Batch (single composite) or Streaming (sequential)
  • ⏱️ Precise timing control - Pre/post delays, global defaults, event-specific durations
  • πŸ›‘οΈ Comprehensive validation - Input validation, dry-run mode, error handling
  • πŸ“Š Rich feedback - Summaries, verbose output, progress tracking
  • πŸ”§ Flexible input - Files, stdin, or inline JSON

πŸ—οΈ Architecture

The implementation follows AXe's existing patterns and leverages the IDB library's FBSimulatorHIDEvent composite event capabilities:

  • EventSequence.swift - Data models with full validation
  • EventSequenceParser.swift - JSON parsing with comprehensive error handling
  • HIDEventFactory.swift - Converts parsed events to FBSimulatorHIDEvent objects
  • Stream.swift - Main CLI command with batch/streaming execution

πŸ“š Usage Examples

Simple tap sequence

axe stream --json '{
  "events": [
    {"type": "tap", "parameters": {"x": 100, "y": 200}},
    {"type": "delay", "parameters": {"duration": 1.0}},
    {"type": "tap", "parameters": {"x": 300, "y": 400}}
  ]
}' --udid SIMULATOR_UDID

Complex automation from file

axe stream --file login-automation.json --mode streaming --udid SIMULATOR_UDID

Validation and testing

# Validate without executing
axe stream --file sequence.json --validate-only

# Dry run to see execution plan
axe stream --file sequence.json --dry-run --udid SIMULATOR_UDID

# Generate examples
axe stream --example > example.json

πŸ“ Files Added

  • Commands/Stream.swift - Main CLI command implementation
  • Models/EventSequence.swift - Data models and validation
  • Utilities/EventSequenceParser.swift - JSON parsing and validation
  • Utilities/HIDEventFactory.swift - HID event creation and execution planning
  • Tests/StreamTests.swift - Comprehensive test coverage
  • Examples/event-sequences/ - Example JSON files and documentation

🎯 Use Cases

  • UI Automation - Complex user interaction workflows
  • Testing - Repeatable test sequences with precise timing
  • Game Input - Multi-touch and complex input patterns
  • Accessibility Testing - Varied input pattern testing

πŸ” Example JSON Structure

{
  "metadata": {
    "name": "Login Automation",
    "description": "Automated login sequence"
  },
  "settings": {
    "default_delay": 0.3,
    "stop_on_error": true,
    "max_execution_time": 60.0
  },
  "events": [
    {
      "type": "tap",
      "parameters": {"x": 200, "y": 300},
      "pre_delay": 1.0,
      "id": "tap_username_field",
      "description": "Tap on username field"
    },
    {
      "type": "type", 
      "parameters": {"text": "[email protected]"},
      "post_delay": 0.5
    }
  ]
}

βœ… Testing

  • Full unit test coverage for all components
  • Validation testing for all event types
  • Error handling and edge case testing
  • Example file validation

πŸ“– Documentation

  • Comprehensive README with examples and best practices
  • JSON schema generation for validation
  • Inline help and examples in CLI
  • Example files covering common use cases

This implementation provides a solid foundation for complex HID event automation while maintaining AXe's existing architecture and patterns.


πŸ’» View my work β€’ About Codegen

codegen-sh bot added 3 commits June 8, 2025 11:10
- Add new 'stream' command to execute sequences of HID events from JSON
- Support for all existing HID event types (tap, swipe, type, key, etc.)
- JSON-based input format with comprehensive validation
- Batch and streaming execution modes
- Precise timing control with pre/post delays
- Comprehensive error handling and validation
- Example JSON files for common use cases
- Full test coverage and documentation

Features:
- Execute from JSON files, stdin, or inline JSON
- Dry-run and validation-only modes
- Event sequence summaries and verbose output
- Support for complex automation workflows
- Extensible architecture for future event types
- Rename 'batch' to 'composite' (single IPC call)
- Rename 'streaming' to 'sequential' (multiple IPC calls)
- Add true 'batch' mode with configurable batch sizes
- Update documentation to clarify execution modes
- Add --batch-size option for batch mode
- Fix execution mode mappings and implementations
- Created 8 example JSON files demonstrating different execution modes
- composite-navigation.json: Quick app navigation with composite mode
- composite-text-input.json: Fast text input workflow
- sequential-tap-test.json: Precise timing tap sequences
- sequential-swipe-patterns.json: Complex swipe choreography
- batch-multi-screen.json: Multi-screen testing with batched operations
- batch-stress-test.json: High-volume performance testing
- realtime-taps.json: Real-time tap visualization
- typing-animation.json: Character-by-character typing animation
- gesture-choreography.json: Complex multi-touch gesture patterns

Each example targets specific Playground app screens and demonstrates
the unique capabilities of composite, sequential, and batch modes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants