1 /* 2 * Copyright (C) 2021 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.car.admin; 18 19 import static com.google.common.truth.Truth.assertThat; 20 21 import android.car.user.UserStopResult; 22 23 import org.junit.Test; 24 import org.junit.runner.RunWith; 25 import org.junit.runners.Parameterized; 26 27 import java.util.Arrays; 28 import java.util.Collection; 29 30 @RunWith(Parameterized.class) 31 public final class StopUserResultTest { 32 33 private final int mUserStopStatus; 34 private final int mStopUserStatus; 35 private final boolean mIsSuccess; 36 StopUserResultTest(int userStopStatus, int stopUserStatus, boolean isSuccess)37 public StopUserResultTest(int userStopStatus, int stopUserStatus, boolean isSuccess) { 38 mUserStopStatus = userStopStatus; 39 mStopUserStatus = stopUserStatus; 40 mIsSuccess = isSuccess; 41 } 42 43 @Parameterized.Parameters provideParams()44 public static Collection provideParams() { 45 return Arrays.asList( 46 new Object[][] { 47 {UserStopResult.STATUS_SUCCESSFUL, StopUserResult.STATUS_SUCCESS, true}, 48 {UserStopResult.STATUS_FAILURE_CURRENT_USER, 49 StopUserResult.STATUS_FAILURE_CURRENT_USER, false}, 50 {UserStopResult.STATUS_FAILURE_SYSTEM_USER, 51 StopUserResult.STATUS_FAILURE_SYSTEM_USER, false}, 52 {UserStopResult.STATUS_USER_DOES_NOT_EXIST, 53 StopUserResult.STATUS_FAILURE_USER_DOES_NOT_EXIST, false}, 54 {UserStopResult.STATUS_ANDROID_FAILURE, 55 StopUserResult.STATUS_FAILURE_GENERIC, false} 56 }); 57 } 58 59 @Test testStatus()60 public void testStatus() { 61 StopUserResult result = new StopUserResult(mUserStopStatus); 62 63 assertThat(result.getStatus()).isEqualTo(mStopUserStatus); 64 assertThat(result.isSuccess()).isEqualTo(mIsSuccess); 65 } 66 } 67