1 /*
2 * Copyright (C) 2023 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.systemui.shade
17
18 import android.animation.Animator
19 import android.testing.AndroidTestingRunner
20 import android.transition.TransitionValues
21 import androidx.test.filters.SmallTest
22 import com.android.keyguard.KeyguardStatusViewController
23 import com.android.systemui.SysuiTestCase
24 import com.android.systemui.shade.NotificationPanelViewController.SplitShadeTransitionAdapter
25 import com.google.common.truth.Truth.assertThat
26 import org.junit.Before
27 import org.junit.Test
28 import org.junit.runner.RunWith
29 import org.mockito.Mock
30 import org.mockito.MockitoAnnotations
31
32 @SmallTest
33 @RunWith(AndroidTestingRunner::class)
34 class SplitShadeTransitionAdapterTest : SysuiTestCase() {
35
36 @Mock private lateinit var keyguardStatusViewController: KeyguardStatusViewController
37
38 private lateinit var adapter: SplitShadeTransitionAdapter
39
40 @Before
setUpnull41 fun setUp() {
42 MockitoAnnotations.initMocks(this)
43 adapter = SplitShadeTransitionAdapter(keyguardStatusViewController)
44 }
45
46 @Test
createAnimator_nullStartValues_returnsNullnull47 fun createAnimator_nullStartValues_returnsNull() {
48 val animator = adapter.createAnimator(startValues = null, endValues = TransitionValues())
49
50 assertThat(animator).isNull()
51 }
52
53 @Test
createAnimator_nullEndValues_returnsNullnull54 fun createAnimator_nullEndValues_returnsNull() {
55 val animator = adapter.createAnimator(startValues = TransitionValues(), endValues = null)
56
57 assertThat(animator).isNull()
58 }
59
60 @Test
createAnimator_nonNullStartAndEndValues_returnsAnimatornull61 fun createAnimator_nonNullStartAndEndValues_returnsAnimator() {
62 val animator =
63 adapter.createAnimator(startValues = TransitionValues(), endValues = TransitionValues())
64
65 assertThat(animator).isNotNull()
66 }
67 }
68
SplitShadeTransitionAdapternull69 private fun SplitShadeTransitionAdapter.createAnimator(
70 startValues: TransitionValues?,
71 endValues: TransitionValues?
72 ): Animator? {
73 return createAnimator(/* sceneRoot= */ null, startValues, endValues)
74 }
75