1 package com.android.keyguard 2 3 import androidx.test.filters.SmallTest 4 import android.testing.AndroidTestingRunner 5 import android.testing.TestableLooper.RunWithLooper 6 import android.view.LayoutInflater 7 import android.view.View 8 import android.view.ViewGroup 9 import com.android.systemui.res.R 10 import com.android.systemui.SysuiTestCase 11 import com.android.systemui.util.children 12 import com.google.common.truth.Truth.assertThat 13 import org.junit.Before 14 import org.junit.Test 15 import org.junit.runner.RunWith 16 17 @SmallTest 18 @RunWith(AndroidTestingRunner::class) 19 @RunWithLooper(setAsMainLooper = true) 20 class KeyguardStatusViewTest : SysuiTestCase() { 21 22 private lateinit var keyguardStatusView: KeyguardStatusView 23 private val mediaView: View 24 get() = keyguardStatusView.requireViewById(R.id.status_view_media_container) 25 private val statusViewContainer: ViewGroup 26 get() = keyguardStatusView.requireViewById(R.id.status_view_container) 27 private val childrenExcludingMedia <lambda>null28 get() = statusViewContainer.children.filter { it != mediaView } 29 30 @Before setUpnull31 fun setUp() { 32 keyguardStatusView = 33 LayoutInflater.from(context).inflate(R.layout.keyguard_status_view, /* root= */ null) 34 as KeyguardStatusView 35 } 36 37 @Test setChildrenTranslationYExcludingMediaView_mediaViewIsNotTranslatednull38 fun setChildrenTranslationYExcludingMediaView_mediaViewIsNotTranslated() { 39 val translationY = 1234f 40 41 keyguardStatusView.setChildrenTranslationY(translationY, /* excludeMedia= */ true) 42 43 assertThat(mediaView.translationY).isEqualTo(0) 44 45 childrenExcludingMedia.forEach { assertThat(it.translationY).isEqualTo(translationY) } 46 } 47 48 @Test setChildrenTranslationYIncludeMediaViewnull49 fun setChildrenTranslationYIncludeMediaView() { 50 val translationY = 1234f 51 52 keyguardStatusView.setChildrenTranslationY(translationY, /* excludeMedia= */ false) 53 54 statusViewContainer.children.forEach { assertThat(it.translationY).isEqualTo(translationY) } 55 } 56 } 57