1.开始录制、结束录制增加

2. 增加电量检测、内存检查,是否低于 10%
This commit is contained in:
2026-06-04 18:25:58 +08:00
parent 124b4c1882
commit f49d208042
9 changed files with 267 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:recording_tool/core/platform/device_health_checker.dart';
import 'package:recording_tool/core/platform/device_health_snapshot.dart';
void main() {
group('DeviceHealthChecker.warningLines', () {
test('returns empty when battery and storage are healthy', () {
const snapshot = DeviceHealthSnapshot(
batteryLevelPercent: 50,
storageAvailablePercent: 50,
);
expect(DeviceHealthChecker.warningLines(snapshot), isEmpty);
});
test('returns low battery message only', () {
const snapshot = DeviceHealthSnapshot(
batteryLevelPercent: 9,
storageAvailablePercent: 50,
);
expect(
DeviceHealthChecker.warningLines(snapshot),
[DeviceHealthChecker.lowBatteryMessage],
);
});
test('returns low storage message only', () {
const snapshot = DeviceHealthSnapshot(
batteryLevelPercent: 50,
storageAvailablePercent: 9.9,
);
expect(
DeviceHealthChecker.warningLines(snapshot),
[DeviceHealthChecker.lowStorageMessage],
);
});
test('returns both messages when battery and storage are low', () {
const snapshot = DeviceHealthSnapshot(
batteryLevelPercent: 5,
storageAvailablePercent: 5,
);
expect(
DeviceHealthChecker.warningLines(snapshot),
[
DeviceHealthChecker.lowBatteryMessage,
DeviceHealthChecker.lowStorageMessage,
],
);
});
test('does not warn at exactly threshold percent', () {
const snapshot = DeviceHealthSnapshot(
batteryLevelPercent: 10,
storageAvailablePercent: 10,
);
expect(DeviceHealthChecker.warningLines(snapshot), isEmpty);
});
test('skips battery warning when level is unknown', () {
const snapshot = DeviceHealthSnapshot(
batteryLevelPercent: null,
storageAvailablePercent: 5,
);
expect(
DeviceHealthChecker.warningLines(snapshot),
[DeviceHealthChecker.lowStorageMessage],
);
});
});
group('DeviceHealthSnapshot.fromMap', () {
test('parses native map fields', () {
final snapshot = DeviceHealthSnapshot.fromMap({
'batteryLevelPercent': 42,
'storageAvailablePercent': 12.5,
});
expect(snapshot.batteryLevelPercent, 42);
expect(snapshot.storageAvailablePercent, 12.5);
});
});
}