1 /* 2 * Copyright (C) 2018 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.telephony.embms.cts; 18 19 import android.net.Uri; 20 import android.telephony.cts.embmstestapp.CtsDownloadService; 21 import android.telephony.mbms.DownloadRequest; 22 import android.test.InstrumentationTestCase; 23 24 import java.io.File; 25 26 public class DownloadRequestTest extends InstrumentationTestCase { 27 public void testGetMaxAppIntentSize() { 28 // Test that the max intent size is positive 29 assertTrue(DownloadRequest.getMaxAppIntentSize() > 0); 30 } 31 32 public void testGetMaxDestinationUriSize() { 33 // Test that the max intent size is positive 34 assertTrue(DownloadRequest.getMaxDestinationUriSize() > 0); 35 } 36 37 public void testBuilderConstruction() { 38 File destinationDirectory = new File(getInstrumentation().getContext().getFilesDir(), 39 "downloads"); 40 Uri destinationDirectoryUri = Uri.fromFile(destinationDirectory); 41 DownloadRequest.Builder builder = new DownloadRequest.Builder( 42 CtsDownloadService.SOURCE_URI_1, destinationDirectoryUri) 43 .setSubscriptionId(-1) 44 .setServiceInfo(CtsDownloadService.FILE_SERVICE_INFO); 45 DownloadRequest request = builder.build(); 46 assertEquals(request, DownloadRequest.Builder.fromDownloadRequest(request).build()); 47 } 48 49 public void testServiceIdEquivalency() { 50 File destinationDirectory = new File(getInstrumentation().getContext().getFilesDir(), 51 "downloads"); 52 Uri destinationDirectoryUri = Uri.fromFile(destinationDirectory); 53 DownloadRequest request1 = new DownloadRequest.Builder( 54 CtsDownloadService.SOURCE_URI_1, destinationDirectoryUri) 55 .setSubscriptionId(-1) 56 .setServiceInfo(CtsDownloadService.FILE_SERVICE_INFO) 57 .build(); 58 59 DownloadRequest request2 = new DownloadRequest.Builder( 60 CtsDownloadService.SOURCE_URI_1, destinationDirectoryUri) 61 .setSubscriptionId(-1) 62 .setServiceId(CtsDownloadService.FILE_SERVICE_INFO.getServiceId()) 63 .build(); 64 65 assertEquals(request1, request2); 66 } 67 } 68