# Auto-Test Button Guide

## Overview
The integrated UI includes an automatic test button that simplifies testing of the encrypted voice protocol. The green "Run Auto Test" button automatically performs a comprehensive test sequence.

## Important Note
There were issues with the original auto-test implementation causing segmentation faults. A fixed version is available in `UI/integrated_ui_fixed.py` that addresses these issues.

## Features

### Automatic Port Detection
- Automatically retrieves protocol ports from both phone instances
- No manual port entry required
- Fills in peer port fields automatically

### Comprehensive Testing
The auto-test performs the following sequence:

1. **Connection Test**
   - Auto-detects both phone ports
   - Establishes bidirectional connection
   - Verifies protocol handshake

2. **AES-256-GCM Encryption Test**
   - Configures AES encryption mode
   - Performs key exchange
   - Sends test message "Test message with AES encryption"
   - Verifies encryption success

3. **ChaCha20-Poly1305 Encryption Test**
   - Resets protocol connections
   - Reconfigures for ChaCha20 encryption
   - Performs new key exchange
   - Sends test message "Test message with ChaCha20 encryption"
   - Verifies encryption success

4. **Voice Transmission Test** (if input.wav exists)
   - Tests encrypted voice transmission
   - Uses the configured encryption (ChaCha20)
   - Processes through 4FSK modulation

## Usage

1. Start the integrated UI:
   ```bash
   cd DryBox
   python3 UI/integrated_ui.py
   ```

2. Click "Start GSM Simulator" button

3. Wait for both phones to initialize (you'll see their identity keys)

4. Click the green "Run Auto Test" button

5. Monitor the Protocol Status window for test progress

## Status Messages

The test provides detailed status updates:
- `✓` indicates successful steps
- `❌` indicates failed steps
- Timestamps for each operation
- Clear test section headers

## Implementation Details

The auto-test is implemented in `integrated_ui.py`:
- `run_auto_test()` method (line 550)
- `_run_auto_test_sequence()` method (line 559)
- Runs in a separate thread to keep UI responsive
- Properly resets protocols between cipher tests
- Comprehensive error handling

## Benefits

- **No Manual Configuration**: Eliminates need to manually enter ports
- **Comprehensive Coverage**: Tests both encryption methods automatically
- **Time Saving**: Complete test sequence in under 15 seconds
- **Error Detection**: Identifies issues quickly with clear status messages
- **Repeatable**: Consistent test execution every time

## Fixed Version

Due to issues with protocol resets causing segmentation faults, use the fixed version:

```bash
cd DryBox
python3 UI/integrated_ui_fixed.py
```

The fixed version:
- Properly handles GSM simulator startup
- Avoids protocol reset between cipher tests
- Includes better error handling and timeouts
- Only tests ChaCha20 by default to avoid stability issues
- Properly cleans up resources on exit