1 /* 2 * Copyright (C) 2024 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.systemui.keyguard.shared.model 18 19 import androidx.test.ext.junit.runners.AndroidJUnit4 20 import androidx.test.filters.SmallTest 21 import com.android.systemui.SysuiTestCase 22 import com.android.systemui.flags.EnableSceneContainer 23 import com.google.common.truth.Truth.assertThat 24 import org.junit.Test 25 import org.junit.runner.RunWith 26 27 @SmallTest 28 @RunWith(AndroidJUnit4::class) 29 class KeyguardStateTest : SysuiTestCase() { 30 31 /** 32 * This test makes sure that the result of [deviceIsAwakeInState] are equal for all the states 33 * that are obsolete with scene container enabled and UNDEFINED. This means for example that if 34 * GONE is transformed to UNDEFINED it makes sure that GONE and UNDEFINED need to have the same 35 * value. This assumption is important as with scene container flag enabled call sites will only 36 * check the result passing in UNDEFINED. 37 * 38 * This is true today, but as more states may become obsolete this assumption may not be true 39 * anymore and therefore [deviceIsAwakeInState] would need to be rewritten to factor in the 40 * scene state. 41 */ 42 @Test 43 @EnableSceneContainer assertUndefinedResultMatchesObsoleteStateResultsnull44 fun assertUndefinedResultMatchesObsoleteStateResults() { 45 for (state in KeyguardState.entries) { 46 val isAwakeInSceneContainer = 47 KeyguardState.deviceIsAwakeInState(state.mapToSceneContainerState()) 48 val isAwake = KeyguardState.deviceIsAwakeInState(state) 49 assertThat(isAwakeInSceneContainer).isEqualTo(isAwake) 50 } 51 } 52 } 53