|
...
|
...
|
@@ -119,7 +119,7 @@ void main() { |
|
|
|
expect(statistics.avgSleepEvaluate, 2);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('compares weekly bedtime extremes by sleep-day clock time', () {
|
|
|
|
test('compares result bedtime extremes by sleep-end-day start offset', () {
|
|
|
|
final july27 = DateTime(2026, 7, 27);
|
|
|
|
final july28 = DateTime(2026, 7, 28);
|
|
|
|
final july29 = DateTime(2026, 7, 29);
|
|
...
|
...
|
@@ -155,12 +155,12 @@ void main() { |
|
|
|
statistics.earliestSleepInfo?.asleepTime,
|
|
|
|
LocalHealthDataConvert.unixSeconds(earliestBedtime),
|
|
|
|
);
|
|
|
|
expect(statistics.earliestSleepInfo?.timeKey, 20260728);
|
|
|
|
expect(statistics.earliestSleepInfo?.timeKey, 20260729);
|
|
|
|
expect(
|
|
|
|
statistics.latestSleepInfo?.asleepTime,
|
|
|
|
LocalHealthDataConvert.unixSeconds(latestBedtime),
|
|
|
|
);
|
|
|
|
expect(statistics.latestSleepInfo?.timeKey, 20260727);
|
|
|
|
expect(statistics.latestSleepInfo?.timeKey, 20260728);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('uses the first and last records within a sleep day', () {
|
|
...
|
...
|
@@ -201,11 +201,11 @@ void main() { |
|
|
|
statistics.latestSleepInfo?.asleepTime,
|
|
|
|
LocalHealthDataConvert.unixSeconds(continuedSleep),
|
|
|
|
);
|
|
|
|
expect(statistics.earliestSleepInfo?.timeKey, 20260728);
|
|
|
|
expect(statistics.latestSleepInfo?.timeKey, 20260728);
|
|
|
|
expect(statistics.earliestSleepInfo?.timeKey, 20260729);
|
|
|
|
expect(statistics.latestSleepInfo?.timeKey, 20260729);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('uses noon as the sleep day cutoff', () {
|
|
|
|
test('keeps negative sleep start offset from sleep end day', () {
|
|
|
|
final july28 = DateTime(2026, 7, 28);
|
|
|
|
final july29 = DateTime(2026, 7, 29);
|
|
|
|
final july30 = DateTime(2026, 7, 30);
|
|
...
|
...
|
@@ -242,15 +242,15 @@ void main() { |
|
|
|
statistics.earliestSleepInfo?.asleepTime,
|
|
|
|
LocalHealthDataConvert.unixSeconds(atNoon),
|
|
|
|
);
|
|
|
|
expect(statistics.earliestSleepInfo?.timeKey, 20260729);
|
|
|
|
expect(statistics.earliestSleepInfo?.timeKey, 20260730);
|
|
|
|
expect(
|
|
|
|
statistics.latestSleepInfo?.asleepTime,
|
|
|
|
LocalHealthDataConvert.unixSeconds(beforeNoon),
|
|
|
|
);
|
|
|
|
expect(statistics.latestSleepInfo?.timeKey, 20260728);
|
|
|
|
expect(statistics.latestSleepInfo?.timeKey, 20260729);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('excludes records outside the report sleep-day range', () {
|
|
|
|
test('keeps records when sleep end day is inside the report range', () {
|
|
|
|
final july29 = DateTime(2026, 7, 29);
|
|
|
|
final overnightStart = DateTime(2026, 7, 29, 3);
|
|
|
|
final result = HealthRawSleepResult(
|
|
...
|
...
|
@@ -274,8 +274,10 @@ void main() { |
|
|
|
heartRate: const [],
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(statistics.earliestSleepInfo, isNull);
|
|
|
|
expect(statistics.latestSleepInfo, isNull);
|
|
|
|
expect(statistics.earliestSleepInfo?.asleepTime, result.startDate);
|
|
|
|
expect(statistics.latestSleepInfo?.asleepTime, result.startDate);
|
|
|
|
expect(statistics.earliestSleepInfo?.timeKey, 20260729);
|
|
|
|
expect(statistics.latestSleepInfo?.timeKey, 20260729);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('sleep duration excludes awake intervals inside sleep range', () {
|
...
|
...
|
|