mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-11-30 01:34:57 +01:00
more work on screenshots
This commit is contained in:
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@@ -168,8 +168,8 @@ jobs:
|
||||
- name: Generate screenshots for App Stores
|
||||
if: inputs.build_github
|
||||
run: |
|
||||
flutter --no-color test --machine --start-paused --plain-name Requirements -d macos integration_test/screenshot_test.dart
|
||||
zip -r SwiftControl.storeassets.zip ~/Library/Containers/de.jonasbark.swiftcontrol.darwin/Data/screenshots
|
||||
flutter test test/screenshot_test.dart
|
||||
zip -r SwiftControl.storeassets.zip screenshots
|
||||
echo "Screenshots generated successfully"
|
||||
|
||||
- name: 🚀 Shorebird Release iOS
|
||||
@@ -259,7 +259,7 @@ jobs:
|
||||
overwrite: true
|
||||
name: Releases
|
||||
path: |
|
||||
~/Library/Containers/de.jonasbark.swiftcontrol.darwin/Data/screenshots/screenshot.png
|
||||
screenshots/screenshot.png
|
||||
build/SwiftControl.storeassets.zip
|
||||
|
||||
#10 Extract Version
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
# Screenshot Generation
|
||||
|
||||
This directory contains integration tests for generating app store screenshots during the build pipeline.
|
||||
|
||||
## Overview
|
||||
|
||||
The screenshot generation system automatically creates promotional screenshots for:
|
||||
- **Phone screens**: 1140x2616 (mob1.png, mob2.png)
|
||||
- **Tablet screens**: 2248x2480 (tab1.png, tab2.png)
|
||||
- **macOS screens**: 1280x800 (mac_screenshot_1.png, mac_screenshot_2.png)
|
||||
|
||||
## How It Works
|
||||
|
||||
1. **Integration Test**: `screenshot_test.dart` defines test cases for each screen size
|
||||
2. **Test Driver**: `../test_driver/integration_test.dart` handles saving screenshots to disk
|
||||
3. **CI/CD Integration**: The build workflow runs these tests and packages screenshots
|
||||
|
||||
## Running Locally
|
||||
|
||||
To generate screenshots locally:
|
||||
|
||||
```bash
|
||||
# From the project root
|
||||
flutter test integration_test/screenshot_test.dart --driver=test_driver/integration_test.dart
|
||||
```
|
||||
|
||||
Screenshots will be saved to `build/screenshots/`.
|
||||
|
||||
## CI/CD Process
|
||||
|
||||
During the GitHub Actions build workflow:
|
||||
1. Flutter environment is set up
|
||||
2. Dependencies are installed with `flutter pub get`
|
||||
3. Integration tests run and generate screenshots
|
||||
4. Screenshots are zipped into `SwiftControl.screenshots.zip`
|
||||
5. The zip file is uploaded as a workflow artifact
|
||||
6. The zip file is attached to the GitHub release
|
||||
|
||||
## Modifying Screenshots
|
||||
|
||||
To modify the screenshots:
|
||||
1. Edit `screenshot_test.dart` to change the UI or add new screens
|
||||
2. Adjust screen sizes by modifying `physicalSizeTestValue`
|
||||
3. Test locally to verify the output
|
||||
4. Commit changes - CI will automatically generate new screenshots
|
||||
|
||||
## Screenshot Content
|
||||
|
||||
The generated screenshots show:
|
||||
- Main app screen with branding and connect button
|
||||
- Device list showing various supported devices (Zwift Click, Play, Elite Sterzo, etc.)
|
||||
- Dark theme matching the app's design
|
||||
- Consistent branding with the app's color scheme
|
||||
@@ -36,7 +36,7 @@ class ZwiftEmulator {
|
||||
bool get isAdvertising => _isAdvertising;
|
||||
bool get isLoading => _isLoading;
|
||||
|
||||
final peripheralManager = PeripheralManager();
|
||||
late final _peripheralManager = PeripheralManager();
|
||||
bool _isAdvertising = false;
|
||||
bool _isLoading = false;
|
||||
bool _isServiceAdded = false;
|
||||
@@ -45,8 +45,8 @@ class ZwiftEmulator {
|
||||
GATTCharacteristic? _asyncCharacteristic;
|
||||
|
||||
Future<void> reconnect() async {
|
||||
await peripheralManager.stopAdvertising();
|
||||
await peripheralManager.removeAllServices();
|
||||
await _peripheralManager.stopAdvertising();
|
||||
await _peripheralManager.removeAllServices();
|
||||
_isServiceAdded = false;
|
||||
_isAdvertising = false;
|
||||
startAdvertising(() {});
|
||||
@@ -56,13 +56,13 @@ class ZwiftEmulator {
|
||||
_isLoading = true;
|
||||
onUpdate();
|
||||
|
||||
peripheralManager.stateChanged.forEach((state) {
|
||||
_peripheralManager.stateChanged.forEach((state) {
|
||||
print('Peripheral manager state: ${state.state}');
|
||||
});
|
||||
|
||||
if (!kIsWeb && Platform.isAndroid) {
|
||||
if (Platform.isAndroid) {
|
||||
peripheralManager.connectionStateChanged.forEach((state) {
|
||||
_peripheralManager.connectionStateChanged.forEach((state) {
|
||||
print('Peripheral connection state: ${state.state} of ${state.central.uuid}');
|
||||
if (state.state == ConnectionState.connected) {
|
||||
} else if (state.state == ConnectionState.disconnected) {
|
||||
@@ -82,7 +82,7 @@ class ZwiftEmulator {
|
||||
}
|
||||
}
|
||||
|
||||
while (peripheralManager.state != BluetoothLowEnergyState.poweredOn) {
|
||||
while (_peripheralManager.state != BluetoothLowEnergyState.poweredOn) {
|
||||
print('Waiting for peripheral manager to be powered on...');
|
||||
if (settings.getLastTarget() == Target.thisDevice) {
|
||||
return;
|
||||
@@ -116,7 +116,7 @@ class ZwiftEmulator {
|
||||
|
||||
if (!_isSubscribedToEvents) {
|
||||
_isSubscribedToEvents = true;
|
||||
peripheralManager.characteristicReadRequested.forEach((eventArgs) async {
|
||||
_peripheralManager.characteristicReadRequested.forEach((eventArgs) async {
|
||||
print('Read request for characteristic: ${eventArgs.characteristic.uuid}');
|
||||
|
||||
switch (eventArgs.characteristic.uuid.toString().toUpperCase()) {
|
||||
@@ -124,7 +124,7 @@ class ZwiftEmulator {
|
||||
print('Handling read request for SYNC TX characteristic');
|
||||
break;
|
||||
case BleUuid.DEVICE_INFORMATION_CHARACTERISTIC_BATTERY_LEVEL:
|
||||
await peripheralManager.respondReadRequestWithValue(
|
||||
await _peripheralManager.respondReadRequestWithValue(
|
||||
eventArgs.request,
|
||||
value: Uint8List.fromList([100]),
|
||||
);
|
||||
@@ -135,19 +135,19 @@ class ZwiftEmulator {
|
||||
|
||||
final request = eventArgs.request;
|
||||
final trimmedValue = Uint8List.fromList([]);
|
||||
await peripheralManager.respondReadRequestWithValue(
|
||||
await _peripheralManager.respondReadRequestWithValue(
|
||||
request,
|
||||
value: trimmedValue,
|
||||
);
|
||||
// You can respond to read requests here if needed
|
||||
});
|
||||
|
||||
peripheralManager.characteristicNotifyStateChanged.forEach((char) {
|
||||
_peripheralManager.characteristicNotifyStateChanged.forEach((char) {
|
||||
print(
|
||||
'Notify state changed for characteristic: ${char.characteristic.uuid}: ${char.state}',
|
||||
);
|
||||
});
|
||||
peripheralManager.characteristicWriteRequested.forEach((eventArgs) async {
|
||||
_peripheralManager.characteristicWriteRequested.forEach((eventArgs) async {
|
||||
_central = eventArgs.central;
|
||||
isConnected.value = true;
|
||||
|
||||
@@ -169,7 +169,7 @@ class ZwiftEmulator {
|
||||
|
||||
if (value.contentEquals(handshake) || value.contentEquals(handshakeAlternative)) {
|
||||
print('Sending handshake');
|
||||
await peripheralManager.notifyCharacteristic(
|
||||
await _peripheralManager.notifyCharacteristic(
|
||||
_central!,
|
||||
syncTxCharacteristic,
|
||||
value: ZwiftConstants.RIDE_ON,
|
||||
@@ -181,12 +181,12 @@ class ZwiftEmulator {
|
||||
print('Unhandled write request for characteristic: ${eventArgs.characteristic.uuid}');
|
||||
}
|
||||
|
||||
await peripheralManager.respondWriteRequest(request);
|
||||
await _peripheralManager.respondWriteRequest(request);
|
||||
});
|
||||
}
|
||||
|
||||
// Device Information
|
||||
await peripheralManager.addService(
|
||||
await _peripheralManager.addService(
|
||||
GATTService(
|
||||
uuid: UUID.fromString('180A'),
|
||||
isPrimary: true,
|
||||
@@ -217,7 +217,7 @@ class ZwiftEmulator {
|
||||
);
|
||||
|
||||
// Battery Service
|
||||
await peripheralManager.addService(
|
||||
await _peripheralManager.addService(
|
||||
GATTService(
|
||||
uuid: UUID.fromString('180F'),
|
||||
isPrimary: true,
|
||||
@@ -239,7 +239,7 @@ class ZwiftEmulator {
|
||||
);
|
||||
|
||||
// Unknown Service
|
||||
await peripheralManager.addService(
|
||||
await _peripheralManager.addService(
|
||||
GATTService(
|
||||
uuid: UUID.fromString(ZwiftConstants.ZWIFT_RIDE_CUSTOM_SERVICE_UUID_SHORT),
|
||||
isPrimary: true,
|
||||
@@ -298,14 +298,14 @@ class ZwiftEmulator {
|
||||
);
|
||||
print('Starting advertising with Zwift service...');
|
||||
|
||||
await peripheralManager.startAdvertising(advertisement);
|
||||
await _peripheralManager.startAdvertising(advertisement);
|
||||
_isAdvertising = true;
|
||||
_isLoading = false;
|
||||
onUpdate();
|
||||
}
|
||||
|
||||
Future<void> stopAdvertising() async {
|
||||
await peripheralManager.stopAdvertising();
|
||||
await _peripheralManager.stopAdvertising();
|
||||
_isAdvertising = false;
|
||||
_isLoading = false;
|
||||
}
|
||||
@@ -340,10 +340,10 @@ class ZwiftEmulator {
|
||||
...bytes,
|
||||
]);
|
||||
|
||||
peripheralManager.notifyCharacteristic(_central!, _asyncCharacteristic!, value: commandProto);
|
||||
_peripheralManager.notifyCharacteristic(_central!, _asyncCharacteristic!, value: commandProto);
|
||||
|
||||
final zero = Uint8List.fromList([0x23, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F]);
|
||||
peripheralManager.notifyCharacteristic(_central!, _asyncCharacteristic!, value: zero);
|
||||
_peripheralManager.notifyCharacteristic(_central!, _asyncCharacteristic!, value: zero);
|
||||
return 'Sent action: ${inGameAction.name}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,9 @@ class _DevicePageState extends State<DevicePage> with WidgetsBindingObserver {
|
||||
super.initState();
|
||||
|
||||
// keep screen on - this is required for iOS to keep the bluetooth connection alive
|
||||
WakelockPlus.enable();
|
||||
if (!screenshotMode) {
|
||||
WakelockPlus.enable();
|
||||
}
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
|
||||
@@ -454,7 +454,7 @@ class _KeyWidget extends StatelessWidget {
|
||||
child: Text(
|
||||
label.splitByUpperCase(),
|
||||
style: TextStyle(
|
||||
fontFamily: 'monospace',
|
||||
fontFamily: screenshotMode ? null : 'monospace',
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
),
|
||||
|
||||
@@ -66,7 +66,9 @@ class BluetoothTurnedOn extends PlatformRequirement {
|
||||
|
||||
@override
|
||||
Future<void> getStatus() async {
|
||||
final currentState = await UniversalBle.getBluetoothAvailabilityState();
|
||||
final currentState = screenshotMode
|
||||
? AvailabilityState.poweredOn
|
||||
: await UniversalBle.getBluetoothAvailabilityState();
|
||||
status = currentState == AvailabilityState.poweredOn || screenshotMode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:swift_control/main.dart';
|
||||
import 'package:swift_control/utils/keymap/buttons.dart';
|
||||
import 'package:swift_control/widgets/keymap_explanation.dart';
|
||||
|
||||
@@ -32,7 +33,7 @@ class ButtonWidget extends StatelessWidget {
|
||||
: Text(
|
||||
button.name.splitByUpperCase(),
|
||||
style: TextStyle(
|
||||
fontFamily: 'monospace',
|
||||
fontFamily: screenshotMode ? null : 'monospace',
|
||||
fontSize: big && button.color != null ? 20 : 12,
|
||||
fontWeight: button.color != null ? FontWeight.bold : null,
|
||||
color: button.color != null ? Colors.white : Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
|
||||
@@ -148,7 +148,9 @@ class _AppTitleState extends State<AppTitle> {
|
||||
if (packageInfoValue != null)
|
||||
Text(
|
||||
'v${packageInfoValue!.version}${shorebirdPatch != null ? '+${shorebirdPatch!.number}' : ''}${kIsWeb || (Platform.isAndroid && isFromPlayStore == false) ? ' (sideloaded)' : ''}',
|
||||
style: TextStyle(fontFamily: "monospace", fontFamilyFallback: <String>["Courier"], fontSize: 12),
|
||||
style: screenshotMode
|
||||
? TextStyle(fontSize: 12)
|
||||
: TextStyle(fontFamily: "monospace", fontFamilyFallback: <String>["Courier"], fontSize: 12),
|
||||
)
|
||||
else
|
||||
SmallProgressIndicator(),
|
||||
|
||||
@@ -3,6 +3,8 @@ import 'package:file/local.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:swift_control/bluetooth/devices/zwift/zwift_ride.dart';
|
||||
import 'package:swift_control/main.dart';
|
||||
import 'package:swift_control/pages/device.dart';
|
||||
@@ -13,13 +15,22 @@ import 'package:test_screenshot/test_screenshot.dart';
|
||||
import 'package:universal_ble/universal_ble.dart';
|
||||
|
||||
void main() {
|
||||
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
PackageInfo.setMockInitialValues(
|
||||
appName: 'SwiftControl',
|
||||
packageName: 'de.jonasbark.swiftcontrol',
|
||||
version: '3.5.0',
|
||||
buildNumber: '1',
|
||||
buildSignature: '',
|
||||
);
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
|
||||
group('Screenshot Tests', () {
|
||||
testWidgets('Requirements', (WidgetTester tester) async {
|
||||
await tester.loadFonts();
|
||||
// Set phone screen size (typical Android phone - 1140x2616 to match existing)
|
||||
binding.window.physicalSizeTestValue = const Size(1280, 800);
|
||||
binding.window.devicePixelRatioTestValue = 1.0;
|
||||
tester.view.physicalSize = const Size(1280, 800);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
|
||||
await settings.init();
|
||||
await settings.reset();
|
||||
@@ -29,24 +40,17 @@ void main() {
|
||||
child: SwiftPlayApp(),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
const wait = 3;
|
||||
|
||||
try {
|
||||
await tester.pumpAndSettle(Duration(seconds: wait), EnginePhase.sendSemanticsUpdate, Duration(seconds: wait));
|
||||
} catch (e) {
|
||||
// Ignore timeout errors
|
||||
}
|
||||
await _takeScreenshot(tester, 'screenshot.png');
|
||||
|
||||
// Reset
|
||||
binding.window.clearPhysicalSizeTestValue();
|
||||
binding.window.clearDevicePixelRatioTestValue();
|
||||
});
|
||||
testWidgets('Device', (WidgetTester tester) async {
|
||||
await tester.loadFonts();
|
||||
// Set phone screen size (typical Android phone - 1140x2616 to match existing)
|
||||
binding.window.physicalSizeTestValue = const Size(1280, 800);
|
||||
binding.window.devicePixelRatioTestValue = 1.0;
|
||||
tester.view.physicalSize = const Size(1280, 800);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
|
||||
screenshotMode = true;
|
||||
|
||||
@@ -82,7 +86,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
const wait = 3;
|
||||
const wait = 1;
|
||||
|
||||
try {
|
||||
await tester.pumpAndSettle(Duration(seconds: wait), EnginePhase.sendSemanticsUpdate, Duration(seconds: wait));
|
||||
@@ -92,8 +96,6 @@ void main() {
|
||||
|
||||
await _takeScreenshot(tester, 'device.png');
|
||||
// Reset
|
||||
binding.window.clearPhysicalSizeTestValue();
|
||||
binding.window.clearDevicePixelRatioTestValue();
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user