1 /* 2 * Copyright (C) 2016 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 com.android.settings; 18 19 import static com.android.settings.UserCredentialsSettings.Credential; 20 21 import android.os.Parcel; 22 import android.os.Process; 23 import android.test.InstrumentationTestCase; 24 25 import androidx.test.filters.SmallTest; 26 27 /** 28 * User credentials settings fragment tests 29 * 30 * To run the test, use command: 31 * adb shell am instrument -e class com.android.settings.UserCredentialsTest 32 * -w com.android.settings.tests.unit/androidx.test.runner.AndroidJUnitRunner 33 * 34 */ 35 public class UserCredentialsTest extends InstrumentationTestCase { 36 private static final String TAG = "UserCredentialsTests"; 37 38 @SmallTest testCredentialIsParcelable()39 public void testCredentialIsParcelable() { 40 final String alias = "credential-test-alias"; 41 Credential c = new Credential(alias, Process.SYSTEM_UID); 42 43 c.storedTypes.add(Credential.Type.CA_CERTIFICATE); 44 c.storedTypes.add(Credential.Type.USER_KEY); 45 46 Parcel p = Parcel.obtain(); 47 c.writeToParcel(p, /* flags */ 0); 48 p.setDataPosition(0); 49 50 Credential r = Credential.CREATOR.createFromParcel(p); 51 assertEquals(c.alias, r.alias); 52 assertEquals(c.uid, r.uid); 53 assertEquals(c.storedTypes, r.storedTypes); 54 } 55 } 56