proofmode 0.9.0

Capture, share, and preserve verifiable photos and videos
Documentation
# Android ProofMode Testing Guide

This guide explains how to run tests for the Android ProofMode integration.

## Test Structure

The Android example includes two types of tests:

### 1. Unit Tests (`src/test/`)
- **ProofModeUnitTest.kt**: Tests data classes and utility functions
- Run locally on JVM without device/emulator
- Fast execution, good for CI/CD

### 2. Integration Tests (`src/androidTest/`)
- **ProofModeIntegrationTest.kt**: Tests actual native library calls
- Requires Android device or emulator
- Tests the full integration with the Rust library

## Running Tests

### Using the Test Script
```bash
cd android-example
./run_tests.sh
```

### Manual Test Execution

#### Unit Tests Only
```bash
./gradlew test
```

#### Integration Tests Only (requires device/emulator)
```bash
./gradlew connectedAndroidTest
```

#### All Tests
```bash
./gradlew test connectedAndroidTest
```

## Test Coverage

### Integration Tests Cover:
1. **Version Check**: Verifies library version matches expected
2. **Hash Calculation**: Tests SHA-256 hash generation
3. **Proof Generation**: Tests full proof generation workflow
4. **File Verification**: Tests check functionality
5. **Callback Integration**: Verifies all callbacks work correctly
6. **Error Handling**: Tests graceful error handling

### Unit Tests Cover:
1. **Data Classes**: DeviceInfo, LocationInfo, NetworkInfo
2. **Hash Validation**: SHA-256 format validation
3. **Metadata Handling**: Map creation and manipulation
4. **File Naming**: Proof file naming conventions

## Prerequisites

### For Unit Tests:
- Android SDK
- Gradle

### For Integration Tests:
- Android SDK
- Gradle
- Connected Android device with USB debugging OR
- Running Android emulator

## Setting Up Test Environment

### 1. Enable USB Debugging (Physical Device)
1. Go to Settings > About Phone
2. Tap "Build Number" 7 times
3. Go to Settings > Developer Options
4. Enable "USB Debugging"

### 2. Start Emulator (Alternative)
```bash
# List available emulators
emulator -list-avds

# Start an emulator
emulator -avd <emulator_name>
```

## Viewing Test Results

### Unit Test Results
- HTML Report: `app/build/reports/tests/testDebugUnitTest/index.html`
- XML Results: `app/build/test-results/testDebugUnitTest/`

### Integration Test Results
- HTML Report: `app/build/reports/androidTests/connected/index.html`
- XML Results: `app/build/outputs/androidTest-results/connected/`

## Continuous Integration

For CI/CD pipelines:

```yaml
# Example GitHub Actions configuration
- name: Run Unit Tests
  run: ./gradlew test

- name: Run Integration Tests
  uses: reactivecircus/android-emulator-runner@v2
  with:
    api-level: 29
    script: ./gradlew connectedAndroidTest
```

## Troubleshooting

### "No connected devices" Error
- Ensure device is connected: `adb devices`
- Check USB debugging is enabled
- Try `adb kill-server && adb start-server`

### Test Failures
1. Check logcat for native library errors: `adb logcat | grep -i proofmode`
2. Ensure AAR is properly included in `app/libs/`
3. Verify native libraries are present in AAR

### OutOfMemoryError
Add to `gradle.properties`:
```
org.gradle.jvmargs=-Xmx2048m
```

## Adding New Tests

### Unit Test Template
```kotlin
@Test
fun testNewFeature() {
    // Arrange
    val input = createTestInput()
    
    // Act
    val result = performOperation(input)
    
    // Assert
    assertEquals(expected, result)
}
```

### Integration Test Template
```kotlin
@Test
fun testNativeLibraryFeature() = runBlocking {
    // Arrange
    val testData = prepareTestData()
    
    // Act
    val result = nativeLibraryCall(testData, testCallbacks)
    
    // Assert
    assertNotNull(result)
    verifyCallbacksInvoked()
}
```