|
...
|
...
|
@@ -123,6 +123,50 @@ void main() { |
|
|
|
|
|
|
|
expect(notifications, isEmpty);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('resets realtime stress window after workout point', () {
|
|
|
|
final base = _seconds(DateTime(2026, 1, 1, 9));
|
|
|
|
final notifications = builder.build(
|
|
|
|
result: HealthRawStressCalculationResult(
|
|
|
|
userId: 1,
|
|
|
|
hrvStressPoints: const [],
|
|
|
|
realtimeStressPoints: [_realtimePoint(base + 12 * 300, 70)],
|
|
|
|
dailyStressPoints: const [],
|
|
|
|
),
|
|
|
|
hasExistingHrv: false,
|
|
|
|
realtimeWindow: [
|
|
|
|
for (var i = 0; i < 3; i++) _realtimePoint(base + i * 300, 70),
|
|
|
|
_realtimePoint(base + 3 * 300, 70, isWorkout: true),
|
|
|
|
for (var i = 4; i < 13; i++) _realtimePoint(base + i * 300, 70),
|
|
|
|
],
|
|
|
|
record: const HealthRawLocalNotificationRecord(),
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(notifications, isEmpty);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('builds realtime stress notification after workout reset window refills',
|
|
|
|
() {
|
|
|
|
final base = _seconds(DateTime(2026, 1, 1, 9));
|
|
|
|
final notifications = builder.build(
|
|
|
|
result: HealthRawStressCalculationResult(
|
|
|
|
userId: 1,
|
|
|
|
hrvStressPoints: const [],
|
|
|
|
realtimeStressPoints: [_realtimePoint(base + 13 * 300, 70)],
|
|
|
|
dailyStressPoints: const [],
|
|
|
|
),
|
|
|
|
hasExistingHrv: false,
|
|
|
|
realtimeWindow: [
|
|
|
|
for (var i = 0; i < 3; i++) _realtimePoint(base + i * 300, 30),
|
|
|
|
_realtimePoint(base + 3 * 300, 30, isWorkoutRecovery: true),
|
|
|
|
for (var i = 4; i < 14; i++) _realtimePoint(base + i * 300, 70),
|
|
|
|
],
|
|
|
|
record: const HealthRawLocalNotificationRecord(),
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(notifications, hasLength(1));
|
|
|
|
expect(notifications.single.title, '注意压力 · 09:05-10:05');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
int _seconds(DateTime time) => time.millisecondsSinceEpoch ~/ 1000;
|
|
...
|
...
|
@@ -147,6 +191,8 @@ HealthRawRealtimeStressPoint _realtimePoint( |
|
|
|
int rawEndTime,
|
|
|
|
double result, {
|
|
|
|
bool isSleepLikely = false,
|
|
|
|
bool isWorkout = false,
|
|
|
|
bool isWorkoutRecovery = false,
|
|
|
|
}) {
|
|
|
|
return HealthRawRealtimeStressPoint(
|
|
|
|
userId: 1,
|
|
...
|
...
|
@@ -157,8 +203,8 @@ HealthRawRealtimeStressPoint _realtimePoint( |
|
|
|
sourceEndTime: rawEndTime,
|
|
|
|
flags: HealthRawPointFlags(
|
|
|
|
isSleepLikely: isSleepLikely,
|
|
|
|
isWorkout: false,
|
|
|
|
isWorkoutRecovery: false,
|
|
|
|
isWorkout: isWorkout,
|
|
|
|
isWorkoutRecovery: isWorkoutRecovery,
|
|
|
|
isSuspectedActivity: false,
|
|
|
|
),
|
|
|
|
);
|
...
|
...
|
|