Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Health 12/1066 duplicate android local to origin #1101

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=17.0.13-amzn
7 changes: 4 additions & 3 deletions packages/health/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,10 @@ class _HealthAppState extends State<HealthApp> {

if (stepsPermission) {
try {
steps = await Health().getTotalStepsInInterval(midnight, now,
includeManualEntry:
!recordingMethodsToFilter.contains(RecordingMethod.manual));
steps = await Health().getTotalStepsInInterval(midnight, now, includeManualEntry: false);
// steps = await Health().getTotalStepsInInterval(midnight, now,
// includeManualEntry:
// !recordingMethodsToFilter.contains(RecordingMethod.manual));
} catch (error) {
debugPrint("Exception in getTotalStepsInInterval: $error");
}
Expand Down
3 changes: 2 additions & 1 deletion packages/health/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ dependencies:
flutter:
sdk: flutter
intl: '>=0.18.0 <0.20.0'
device_info_plus: '>=9.0.0 <11.0.0'
# device_info_plus: '>=9.0.0 <11.0.0'
device_info_plus: '^11.1.1'
json_annotation: ^4.8.0
carp_serializable: ^2.0.0 # polymorphic json serialization

Expand Down
51 changes: 51 additions & 0 deletions packages/health/test/health_test.dart
Original file line number Diff line number Diff line change
@@ -1 +1,52 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:health/health.dart';
import 'package:flutter/widgets.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();
group('Health Plugin Tests', () {
late Health health;

setUp(() {
health = Health();
});

test('getHealthDataFromTypes returns results within the correct date range', () async {
final startTime = DateTime(2023, 1, 1);
final endTime = DateTime(2024, 1, 1);
final types = [HealthDataType.WORKOUT];

final healthData = await health.getHealthDataFromTypes(
types: types,
startTime: startTime,
endTime: endTime,
);

for (var dataPoint in healthData) {

// print the values time
print('dateFrom: ${dataPoint.dateFrom} - required: $startTime');
print('dateTo: ${dataPoint.dateTo} - required: $endTime');
expect(dataPoint.dateFrom.isAfter(startTime) || dataPoint.dateFrom.isAtSameMomentAs(startTime), isTrue);
expect(dataPoint.dateTo.isBefore(endTime) || dataPoint.dateTo.isAtSameMomentAs(endTime), isTrue);
}
});

test('getHealthDataFromTypes returns no results outside the specified date range', () async {
final startTime = DateTime(2023, 1, 1);
final endTime = DateTime(2024, 1, 1);
final types = [HealthDataType.WORKOUT];

final healthData = await health.getHealthDataFromTypes(
types: types,
startTime: startTime,
endTime: endTime,
);

for (var dataPoint in healthData) {
expect(dataPoint.dateFrom.isBefore(startTime), isFalse);
expect(dataPoint.dateTo.isAfter(endTime), isFalse);
}
});
});
}
Loading