8000 Add Stream command for HID event sequences by codegen-sh[bot] · Pull Request #2 · cameroncooke/AXe · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add Stream command for HID event sequences #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

codegen-sh[bot]
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": "user@example.com"},
      "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 workAbout 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
47CD
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants
0