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