# Sauna Driver Testing Framework

This directory contains the testing framework for the Sauna OpenVR driver. The framework includes unit tests, integration tests, performance tests, and validation tests to ensure the driver works correctly and reliably.

## Test Components

### 1. Unit Tests
Unit tests verify that each component of the driver works correctly in isolation:
- `test_imu_data_provider.cpp` - Tests for the IMU data provider
- `test_lighthouse_driver_wrapper.cpp` - Tests for the lighthouse driver wrapper
- `test_sauna_device_driver.cpp` - Tests for the custom device driver

### 2. Integration Tests
Integration tests verify that the complete driver works with SteamVR:
- `integration_test.cpp` - Tests that verify the driver can load, initialize, communicate with the lighthouse driver, register devices, and expose IMU data

### 3. Performance Tests
Performance tests measure the impact of the driver:
- `performance_test.cpp` - Tests that measure CPU usage, memory usage, latency impact, and IMU data throughput

### 4. Validation Tests
Validation tests verify IMU data is available when optical tracking is lost:
- `validation_test.cpp` - Tests that simulate optical tracking loss and verify IMU data continues to be available

### 5. Test Utilities
Utility functions and tools to support testing:
- `test_utils.h/cpp` - Common utility functions for testing

## Running the Tests

### Prerequisites
- Visual Studio with C++ development tools installed
- SteamVR installed (for integration and validation tests)
- VR headset connected (for integration and validation tests)

### Running Unit Tests
To run all unit tests:
```
run_unit_tests.bat
```

This will build and run all unit tests, which test each component in isolation.

### Running Integration Tests
To run integration tests:
```
run_integration_tests.bat
```

These tests require SteamVR to be installed but not running. The tests will guide you through the process step by step.

### Running Performance Tests
To run performance tests:
```
run_performance_tests.bat
```

These tests measure CPU usage, memory usage, latency impact, and IMU data throughput. Results will be saved to a performance report file.

### Running Validation Tests
To run validation tests:
```
run_validation_tests.bat
```

These tests require manual intervention to simulate tracking loss. You will be guided through the process of covering the headset sensors to block optical tracking and then uncovering them to restore tracking.

## Test Results

### Unit Tests
Unit tests will output pass/fail results for each test case. All tests should pass for a successful build.

### Integration Tests
Integration tests will guide you through the process and report success or failure at each step.

### Performance Tests
Performance tests will generate a report file with detailed measurements of CPU usage, memory usage, latency, and IMU data throughput.

### Validation Tests
Validation tests will report whether IMU data is available during optical tracking loss and whether the driver correctly detects when optical tracking is restored.

## Troubleshooting

If any tests fail, check the following:
1. Make sure SteamVR is installed but not running during the tests
2. Ensure your VR headset is properly connected
3. Check that the Sauna driver is properly built and installed
4. For validation tests, make sure you're properly covering the headset sensors to block optical tracking

If problems persist, check the error messages for more details on what went wrong.