1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.healthconnect; 18 19 import static android.healthconnect.cts.phr.utils.PhrDataFactory.DATA_SOURCE_DISPLAY_NAME; 20 import static android.healthconnect.cts.phr.utils.PhrDataFactory.DATA_SOURCE_FHIR_BASE_URI; 21 import static android.healthconnect.cts.phr.utils.PhrDataFactory.DATA_SOURCE_FHIR_VERSION; 22 23 import static com.google.common.truth.Truth.assertThat; 24 25 import android.health.connect.CreateMedicalDataSourceRequest; 26 import android.os.Parcel; 27 28 import androidx.test.ext.junit.runners.AndroidJUnit4; 29 30 import org.junit.Test; 31 import org.junit.runner.RunWith; 32 33 @RunWith(AndroidJUnit4.class) 34 public class CreateMedicalDataSourceRequestTest { 35 36 // This test tests the hidden getDataSize method. The rest of this class is tested in cts tests. 37 @Test testCreateMedicalDataSourceRequest_getDataSize()38 public void testCreateMedicalDataSourceRequest_getDataSize() { 39 CreateMedicalDataSourceRequest original = 40 new CreateMedicalDataSourceRequest.Builder( 41 DATA_SOURCE_FHIR_BASE_URI, 42 DATA_SOURCE_DISPLAY_NAME, 43 DATA_SOURCE_FHIR_VERSION) 44 .build(); 45 46 Parcel parcel = Parcel.obtain(); 47 original.writeToParcel(parcel, 0); 48 parcel.setDataPosition(0); 49 CreateMedicalDataSourceRequest restored = 50 CreateMedicalDataSourceRequest.CREATOR.createFromParcel(parcel); 51 52 assertThat(restored).isEqualTo(original); 53 assertThat(restored.getDataSize()).isGreaterThan(0L); 54 parcel.recycle(); 55 } 56 } 57