1 /* 2 * Copyright (C) 2017 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 com.android.tradefed.util; 17 18 import org.junit.Assert; 19 import org.junit.Test; 20 import org.junit.runner.RunWith; 21 import org.junit.runners.JUnit4; 22 23 import java.util.ArrayList; 24 import java.util.List; 25 26 /** Unit tests for {@link KeyguardControllerState} */ 27 @RunWith(JUnit4.class) 28 public class KeyguardControllerStateTest { 29 30 /** Test that {@link KeyguardControllerState#create(List)} returns null if input is invalid. */ 31 @Test 32 public void testCreate_invalidOutput() { 33 List<String> testOutput = new ArrayList<String>(); 34 testOutput.add("mSleepTimeout=false"); 35 testOutput.add(" mCurTaskIdForUser={0=2}"); 36 testOutput.add(" mUserStackInFront={}"); 37 KeyguardControllerState state = KeyguardControllerState.create(testOutput); 38 Assert.assertNull(state); 39 } 40 41 /** 42 * Test that {@link KeyguardControllerState#create(List)} returns proper values based on input. 43 */ 44 @Test 45 public void testCreate() { 46 List<String> testOutput = new ArrayList<String>(); 47 testOutput.add("KeyguardController:"); 48 testOutput.add(" mKeyguardShowing=true"); 49 testOutput.add(" mKeyguardGoingAway=false"); 50 testOutput.add(" mOccluded=false"); 51 KeyguardControllerState state = KeyguardControllerState.create(testOutput); 52 Assert.assertTrue(state.isKeyguardShowing()); 53 Assert.assertFalse(state.isKeyguardOccluded()); 54 } 55 } 56