• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package {
2    default_team: "trendy_team_android_health",
3}
4
5// A group of files known not to work with deviceless (aka bivalent aka robolectric) tests
6// Please avoid adding new tests to the filegroup, we are trying to reduce it to empty.
7filegroup {
8    name: "robo-tests-sources-exclude",
9    srcs: [
10        // Not sure, it is getting an index out of bounds for shared memory
11        "unittests/src/android/health/connect/MigrationEntityParcelTest.java",
12        // This test could be made to work by mocking out the package manager.
13        // However, at the moment it is working more as an integration test on the real platform.
14        // It is safer leaving the test as is.
15        "unittests/src/android/health/connect/HealthPermissionsTest.java",
16        // Needs parcel native code
17        "unittests/src/android/healthconnect/internal/datatypes/SleepStageInternalTest.java",
18        "unittests/src/android/healthconnect/internal/datatypes/SleepSessionInternalTest.java",
19        // Still uses ExtendedMockito
20        "unittests/src/com/android/server/healthconnect/HealthConnectManagerServiceTest.java",
21        // Uses ExtendedMockito
22        "unittests/src/com/android/server/healthconnect/backuprestore/BackupRestoreTest.java",
23        // Uses CTS TestUtils
24        "unittests/src/com/android/server/healthconnect/backuprestore/BackupRestoreWithoutMocksTest.java",
25        // These fail because the Robolectric mocks for package manager return null rather
26        // than application icon or throw exception for getApplicationIcon() when not set.
27        "unittests/src/com/android/server/healthconnect/backuprestore/CloudBackupRestoreTest.java",
28        "unittests/src/com/android/server/healthconnect/backuprestore/CloudBackupSettingsHelperTest.java",
29        "unittests/src/com/android/server/healthconnect/backuprestore/CloudRestoreManagerTest.java",
30        // Uses ExtendedMockito
31        "unittests/src/com/android/server/healthconnect/exportimport/ExportManagerTest.java",
32        // Doesn't work because tries to read resources from the Health Connect APK.
33        // Possibly this can be fixed by changing "Instrumentation for" or something like that
34        "unittests/src/com/android/server/healthconnect/exportimport/ExportImportNotificationFactoryTest.java",
35        // Requires TestUtils for waitForAllTasksToCOmplete()
36        "unittests/src/com/android/server/healthconnect/exportimport/ImportManagerTest.java",
37        // Not passing because the SQLite library we have doesn't support dbstat
38        "unittests/src/com/android/server/healthconnect/logging/DatabaseStatsCollectorTest.java",
39        // Uses ExtendedMockito
40        "unittests/src/com/android/server/healthconnect/migration/MigrationStateManagerTest.java",
41        // Fails due to resources not included
42        "unittests/src/com/android/server/healthconnect/migration/notification/MigrationNotificationFactoryTest.java",
43        // Doesn't work because does complicated things with Health Connect permissions on previous
44        // SDK versions for some tests.
45        // These are not represented well by Robolectric
46        "unittests/src/com/android/server/healthconnect/permission/HealthConnectPermissionHelperTest.java",
47        // ExtendedMockito cannot be used in Robolectric tests so these fixtures aren't used.
48        "unittests/src/com/android/server/healthconnect/testing/fixtures/EnvironmentFixture.java",
49        "unittests/src/com/android/server/healthconnect/testing/fixtures/SQLiteDatabaseFixture.java",
50    ],
51    path: "unittests/src",
52}
53
54// Robolectric test target for testing health connect library
55// Ideally this would be in the unittests module, but this generates an AndroidTest.xml
56// which conflicts with the existing AndroidText.xml used for mainline tests in that module.
57// So following advice from the android testing team I have moved it up one level.
58android_robolectric_test {
59    name: "HealthFitnessRoboUnitTests",
60    // This line absolutely has to be here.
61    // If it is not set, then for some classes (eg RecordTypeIdentifier) the system version is
62    // used rather than our framework code. The system version has the parent class
63    // RecordTypeIdentifier, but the @hide has taken effect on RecordType, and you get a symbol
64    // not found.
65    sdk_version: "module_current",
66    srcs: [
67        "unittests/src/**/*.java",
68        // At the moment depending directly on some CTS targets gives dexcache==null errors when
69        // mocking, so I am depending on a limited subset.
70        "cts/phr/src/android/healthconnect/cts/phr/utils/FhirResourceBuilder.java",
71        "cts/phr/src/android/healthconnect/cts/phr/utils/AllergyBuilder.java",
72        "cts/phr/src/android/healthconnect/cts/phr/utils/ConditionBuilder.java",
73        "cts/phr/src/android/healthconnect/cts/phr/utils/EncountersBuilder.java",
74        "cts/phr/src/android/healthconnect/cts/phr/utils/ImmunizationBuilder.java",
75        "cts/phr/src/android/healthconnect/cts/phr/utils/MedicationsBuilder.java",
76        "cts/phr/src/android/healthconnect/cts/phr/utils/ObservationBuilder.java",
77        "cts/phr/src/android/healthconnect/cts/phr/utils/PatientBuilder.java",
78        "cts/phr/src/android/healthconnect/cts/phr/utils/PractitionerBuilder.java",
79        "cts/phr/src/android/healthconnect/cts/phr/utils/ProcedureBuilder.java",
80        "cts/phr/src/android/healthconnect/cts/phr/utils/PhrDataFactory.java",
81        "cts/utils/HealthConnectTestUtils/src/android/healthconnect/cts/utils/AssumptionCheckerRule.java",
82        "cts/utils/HealthConnectTestUtils/src/android/healthconnect/cts/utils/DataFactory.java",
83        "cts/utils/HealthConnectTestUtils/src/android/healthconnect/cts/utils/DeviceSupportUtils.java",
84        "cts/utils/HealthConnectTestUtils/src/android/healthconnect/cts/utils/HealthConnectReceiver.java",
85        "cts/utils/HealthConnectTestUtils/src/android/healthconnect/cts/utils/TestOutcomeReceiver.java",
86    ],
87    exclude_srcs: [
88        "unittests/src/com/android/server/healthconnect/storage/datatypehelpers/AppOpLogsHelperTest.java",
89        ":robo-tests-sources-exclude",
90    ],
91    static_libs: [
92        // This is required to get mocking of final classes
93        "inline-mockito-robolectric-prebuilt",
94        "//packages/modules/HealthFitness/framework:framework-healthfitness.impl",
95        "service-healthfitness.impl",
96        "androidx.test.core",
97        "androidx.test.ext.junit",
98        "TestParameterInjector",
99        // Beware of adding cts-healthconnect-utils or cts-healthconnect-phr-lib here.
100        // These can add issues with mocking, a strange to diagnose dexcache==null issue.
101        "flag-junit",
102        "framework-annotations-lib",
103        "healthfitness-aconfig-flags-lib",
104        // This is needed give us AppOpsManagerLocal
105        "services.core",
106        "platform-parametric-runner-lib",
107    ],
108    java_resources: [
109        ":generate-fhir-spec-r4-binarypb",
110    ],
111    java_resource_dirs: ["config"],
112    libs: [
113    ],
114    instrumentation_for: "HealthConnectFakeTestApp",
115}
116
117// This is a test that runs on device with exactly the same tests as the robolectric test.
118// It is useful for a fair speed comparison
119android_test {
120    name: "HealthFitnessOnDeviceUnitTests",
121    min_sdk_version: "34",
122    sdk_version: "module_current",
123    manifest: "unittests/AndroidManifest.xml",
124    test_config: "AndroidTest_testOnDevice.xml",
125    srcs: [
126        "unittests/src/**/*.java",
127    ],
128    exclude_srcs: [
129        "unittests/src/com/android/server/healthconnect/storage/datatypehelpers/AppOpLogsHelperTest.java",
130        ":robo-tests-sources-exclude",
131    ],
132    defaults: [
133        "mts-target-sdk-version-current",
134        "modules-utils-testable-device-config-defaults",
135    ],
136    // This needs to be added to the unit tests as this build change is guarded by a build system
137    // flag (soong_config_bool_variable "phr_fhir_validation"), which is part of the PHR FHIR
138    // structural validation feature.
139    java_resources: [
140        ":generate-fhir-spec-r4-binarypb",
141    ],
142    static_libs: [
143        "TestParameterInjector",
144        "service-healthfitness.impl",
145        "framework-healthfitness.impl",
146        "healthfitness-aconfig-flags-lib",
147        "healthfitness-aconfig-flags-helper",
148        "flag-junit",
149        "androidx.test.runner",
150        "mockito-target-extended-minus-junit4",
151        "truth",
152        "services.core",
153        "androidx.test.ext.truth",
154        "cts-healthconnect-utils",
155        "cts-healthconnect-phr-lib",
156        "platform-parametric-runner-lib",
157        "framework-annotations-lib",
158    ],
159    jni_libs: [
160        // Required for ExtendedMockito
161        "libdexmakerjvmtiagent",
162        "libstaticjvmtiagent",
163    ],
164    libs: [
165        "android.test.base.stubs.system",
166        "android.test.mock.stubs.system",
167        "android.test.runner.stubs.system",
168        "framework-sdkextensions.stubs.module_lib",
169        "framework-configinfrastructure.stubs.module_lib",
170    ],
171    // Test coverage system runs on different devices. Need to
172    // compile for all architecture.
173    compile_multilib: "both",
174}
175