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