#!/bin/bash

echo "=== Cremote Accessibility Tree Test Suite ==="
echo

# Check if cremotedaemon is running
echo "Checking if cremotedaemon is running..."
if ! pgrep -f cremotedaemon > /dev/null; then
    echo "ERROR: cremotedaemon is not running"
    echo "Please start it first: cremotedaemon"
    exit 1
fi
echo "✓ cremotedaemon is running"

# Build the test
echo "Building accessibility test..."
cd tests
go build -o test_accessibility test_accessibility.go
if [ $? -ne 0 ]; then
    echo "ERROR: Failed to build test"
    exit 1
fi
echo "✓ Test built successfully"

# Run the test
echo
echo "Running accessibility tree tests..."
echo "=================================="
./test_accessibility

# Cleanup
echo
echo "Cleaning up..."
rm -f test_accessibility
cd ..
echo "✓ Cleanup completed"

echo
echo "=== Test Suite Completed ==="
