|
| 1 | +# LibrePods Android Testing & F-Droid Setup |
| 2 | + |
| 3 | +This directory contains comprehensive testing infrastructure and F-Droid deployment configuration for the LibrePods Android app. |
| 4 | + |
| 5 | +## Testing Infrastructure |
| 6 | + |
| 7 | +### Overview |
| 8 | +The testing setup includes: |
| 9 | +- **Unit Tests**: Test core functionality with mock data |
| 10 | +- **Instrumented Tests**: UI tests that bypass root setup |
| 11 | +- **Screenshot Tests**: Automated screenshot generation for F-Droid |
| 12 | +- **Mock Data Providers**: Simulate various AirPods states without hardware |
| 13 | + |
| 14 | +### Root Setup Bypass |
| 15 | +The key innovation in this testing setup is bypassing the root requirement for testing: |
| 16 | + |
| 17 | +1. **Mock RadareOffsetFinder**: Tests mock `isHookOffsetAvailable()` to return `true` |
| 18 | +2. **Skip Onboarding**: Navigation starts at "settings" instead of "onboarding" |
| 19 | +3. **Mock AirPods State**: Use `MockData` class to simulate various device states |
| 20 | + |
| 21 | +### Running Tests |
| 22 | + |
| 23 | +#### Unit Tests |
| 24 | +```bash |
| 25 | +cd android |
| 26 | +./gradlew test |
| 27 | +``` |
| 28 | + |
| 29 | +#### Instrumented Tests |
| 30 | +```bash |
| 31 | +cd android |
| 32 | +./gradlew connectedAndroidTest |
| 33 | +``` |
| 34 | + |
| 35 | +#### Screenshot Generation |
| 36 | +```bash |
| 37 | +cd android |
| 38 | +fastlane screenshots |
| 39 | +``` |
| 40 | + |
| 41 | +### Test Structure |
| 42 | + |
| 43 | +``` |
| 44 | +app/src/ |
| 45 | +├── test/java/me/kavishdevar/librepods/ |
| 46 | +│ ├── MockData.kt # Mock data providers |
| 47 | +│ ├── MainActivityTest.kt # Activity unit tests |
| 48 | +│ └── RootBypassTest.kt # Root bypass validation |
| 49 | +├── androidTest/java/me/kavishdevar/librepods/ |
| 50 | +│ ├── LibrePodsUITest.kt # UI component tests |
| 51 | +│ ├── NavigationTest.kt # Navigation flow tests |
| 52 | +│ └── screenshots/ |
| 53 | +│ └── ScreenshotTest.kt # Automated screenshot generation |
| 54 | +``` |
| 55 | + |
| 56 | +### Mock Data |
| 57 | + |
| 58 | +The `MockData` object provides various AirPods states for testing: |
| 59 | + |
| 60 | +- `defaultMockState`: Normal connected state with good battery |
| 61 | +- `lowBatteryMockState`: Low battery warning scenario |
| 62 | +- `disconnectedMockState`: Disconnected AirPods |
| 63 | +- `oneEarbudOutMockState`: One earbud removed |
| 64 | + |
| 65 | +## F-Droid Setup |
| 66 | + |
| 67 | +### Fastlane Configuration |
| 68 | + |
| 69 | +The app includes Fastlane configuration optimized for F-Droid: |
| 70 | + |
| 71 | +#### Available Lanes |
| 72 | +- `fastlane test`: Run all tests |
| 73 | +- `fastlane debug`: Build debug APK |
| 74 | +- `fastlane fdroid_release`: Build F-Droid optimized release APK |
| 75 | +- `fastlane screenshots`: Generate automated screenshots |
| 76 | +- `fastlane prepare_fdroid`: Complete F-Droid preparation pipeline |
| 77 | + |
| 78 | +#### F-Droid Specific Features |
| 79 | +- Unsigned APK generation for F-Droid signing |
| 80 | +- Screenshot automation for app store listings |
| 81 | +- Metadata generation in F-Droid format |
| 82 | +- APK validation and size checking |
| 83 | + |
| 84 | +### Metadata Structure |
| 85 | + |
| 86 | +``` |
| 87 | +fastlane/metadata/android/en-US/ |
| 88 | +├── title.txt # App title |
| 89 | +├── short_description.txt # Brief description |
| 90 | +├── full_description.txt # Detailed description |
| 91 | +├── changelogs/ |
| 92 | +│ └── 7.txt # Version 7 changelog |
| 93 | +└── images/ # Generated screenshots |
| 94 | + ├── phoneScreenshots/ |
| 95 | + └── tenInchScreenshots/ |
| 96 | +``` |
| 97 | + |
| 98 | +### CI/CD Integration |
| 99 | + |
| 100 | +GitHub Actions workflow includes: |
| 101 | +- Automated testing on push/PR |
| 102 | +- F-Droid APK builds on main branch |
| 103 | +- Screenshot generation with Android emulator |
| 104 | +- Artifact uploads for releases |
| 105 | + |
| 106 | +### Build Variants |
| 107 | + |
| 108 | +The build configuration supports: |
| 109 | +- **Debug**: Development builds with debugging enabled |
| 110 | +- **Release**: F-Droid optimized builds (unsigned) |
| 111 | + |
| 112 | +### Dependencies |
| 113 | + |
| 114 | +Testing dependencies added: |
| 115 | +- JUnit 4 for unit testing |
| 116 | +- Espresso for UI testing |
| 117 | +- MockK for mocking |
| 118 | +- Robolectric for Android unit tests |
| 119 | +- Screengrab for automated screenshots |
| 120 | +- Compose UI testing framework |
| 121 | + |
| 122 | +## Usage for F-Droid Submission |
| 123 | + |
| 124 | +1. **Run full pipeline**: |
| 125 | + ```bash |
| 126 | + cd android |
| 127 | + fastlane prepare_fdroid |
| 128 | + ``` |
| 129 | + |
| 130 | +2. **Review generated files**: |
| 131 | + - APK: `fastlane/outputs/app-release-unsigned.apk` |
| 132 | + - Screenshots: `fastlane/metadata/android/en-US/images/` |
| 133 | + - Metadata: `fastlane/metadata/android/en-US/` |
| 134 | + |
| 135 | +3. **Submit to F-Droid**: |
| 136 | + - Use the generated metadata and APK |
| 137 | + - Screenshots are automatically optimized for F-Droid format |
| 138 | + |
| 139 | +## Development Notes |
| 140 | + |
| 141 | +### Testing Without Root |
| 142 | +- Tests use mocked `RadareOffsetFinder` to bypass root checks |
| 143 | +- UI tests can access all app screens without actual root access |
| 144 | +- Mock data simulates real AirPods behavior patterns |
| 145 | + |
| 146 | +### Screenshot Automation |
| 147 | +- Screenshots are generated using real UI components |
| 148 | +- Mock data ensures consistent visual state |
| 149 | +- Multiple device orientations and screen sizes supported |
| 150 | +- Automatic localization support (currently en-US) |
| 151 | + |
| 152 | +### F-Droid Compliance |
| 153 | +- No proprietary dependencies |
| 154 | +- Reproducible builds |
| 155 | +- Proper AGPL v3 licensing |
| 156 | +- No tracking or telemetry in F-Droid builds |
| 157 | + |
| 158 | +## Troubleshooting |
| 159 | + |
| 160 | +### Common Issues |
| 161 | + |
| 162 | +1. **Gradle sync fails**: Check Android SDK and JDK versions |
| 163 | +2. **Screenshot tests fail**: Ensure emulator has sufficient resources |
| 164 | +3. **Mock data not working**: Verify MockK setup in test dependencies |
| 165 | + |
| 166 | +### Debug Commands |
| 167 | + |
| 168 | +```bash |
| 169 | +# Check test configuration |
| 170 | +./gradlew tasks --all | grep test |
| 171 | + |
| 172 | +# Verbose test output |
| 173 | +./gradlew test --info |
| 174 | + |
| 175 | +# Clean build |
| 176 | +./gradlew clean build |
| 177 | + |
| 178 | +# Check APK details |
| 179 | +aapt dump badging app/build/outputs/apk/release/app-release-unsigned.apk |
| 180 | +``` |
0 commit comments