1 /* 2 * Copyright (C) 2015 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 package android.car.apitest; 17 18 import android.car.content.pm.AppBlockingPackageInfo; 19 import android.car.content.pm.CarAppBlockingPolicy; 20 import android.os.Parcel; 21 import android.test.AndroidTestCase; 22 import android.test.suitebuilder.annotation.SmallTest; 23 import android.util.Log; 24 25 @SmallTest 26 public class CarAppBlockingPolicyTest extends AndroidTestCase { 27 private static final String TAG = AppBlockingPackageInfoTest.class.getSimpleName(); 28 29 public void testParcelling() throws Exception { 30 AppBlockingPackageInfo carServiceInfo = 31 AppBlockingPackageInfoTest.createInfoCarService(getContext()); 32 AppBlockingPackageInfo selfInfo = 33 AppBlockingPackageInfoTest.createInfoSelf(getContext()); 34 // this is only for testing parcelling. contents has nothing to do with actual app blocking. 35 AppBlockingPackageInfo[] whitelists = new AppBlockingPackageInfo[] { carServiceInfo, 36 selfInfo }; 37 AppBlockingPackageInfo[] blacklists = new AppBlockingPackageInfo[] { selfInfo }; 38 CarAppBlockingPolicy policyExpected = new CarAppBlockingPolicy(whitelists, blacklists); 39 Parcel dest = Parcel.obtain(); 40 policyExpected.writeToParcel(dest, 0); 41 dest.setDataPosition(0); 42 CarAppBlockingPolicy policyRead = new CarAppBlockingPolicy(dest); 43 Log.i(TAG, "expected:" + policyExpected + ",read:" + policyRead); 44 assertEquals(policyExpected, policyRead); 45 } 46 } 47