<lambda>null1 package com.android.systemui.shade.transition
2
3 import android.testing.AndroidTestingRunner
4 import androidx.test.filters.SmallTest
5 import com.android.systemui.res.R
6 import com.android.systemui.SysuiTestCase
7 import com.android.systemui.statusbar.policy.FakeConfigurationController
8 import com.android.systemui.statusbar.policy.ResourcesSplitShadeStateController
9 import com.google.common.truth.Expect
10 import org.junit.Rule
11 import org.junit.Test
12 import org.junit.runner.RunWith
13
14 @SmallTest
15 @RunWith(AndroidTestingRunner::class)
16 class LargeScreenShadeInterpolatorImplTest : SysuiTestCase() {
17 @get:Rule val expect: Expect = Expect.create()
18
19 private val portraitShadeInterpolator = LargeScreenPortraitShadeInterpolator()
20 private val splitShadeInterpolator = SplitShadeInterpolator()
21 private val configurationController = FakeConfigurationController()
22 private val impl =
23 LargeScreenShadeInterpolatorImpl(
24 configurationController,
25 context,
26 splitShadeInterpolator,
27 portraitShadeInterpolator,
28 ResourcesSplitShadeStateController()
29 )
30
31 @Test
32 fun getBehindScrimAlpha_inSplitShade_usesSplitShadeValue() {
33 setSplitShadeEnabled(true)
34
35 assertInterpolation(
36 actual = { fraction -> impl.getBehindScrimAlpha(fraction) },
37 expected = { fraction -> splitShadeInterpolator.getBehindScrimAlpha(fraction) }
38 )
39 }
40
41 @Test
42 fun getBehindScrimAlpha_inPortraitShade_usesPortraitShadeValue() {
43 setSplitShadeEnabled(false)
44
45 assertInterpolation(
46 actual = { fraction -> impl.getBehindScrimAlpha(fraction) },
47 expected = { fraction -> portraitShadeInterpolator.getBehindScrimAlpha(fraction) }
48 )
49 }
50
51 @Test
52 fun getNotificationScrimAlpha_inSplitShade_usesSplitShadeValue() {
53 setSplitShadeEnabled(true)
54
55 assertInterpolation(
56 actual = { fraction -> impl.getNotificationScrimAlpha(fraction) },
57 expected = { fraction -> splitShadeInterpolator.getNotificationScrimAlpha(fraction) }
58 )
59 }
60 @Test
61 fun getNotificationScrimAlpha_inPortraitShade_usesPortraitShadeValue() {
62 setSplitShadeEnabled(false)
63
64 assertInterpolation(
65 actual = { fraction -> impl.getNotificationScrimAlpha(fraction) },
66 expected = { fraction -> portraitShadeInterpolator.getNotificationScrimAlpha(fraction) }
67 )
68 }
69
70 @Test
71 fun getNotificationContentAlpha_inSplitShade_usesSplitShadeValue() {
72 setSplitShadeEnabled(true)
73
74 assertInterpolation(
75 actual = { fraction -> impl.getNotificationContentAlpha(fraction) },
76 expected = { fraction -> splitShadeInterpolator.getNotificationContentAlpha(fraction) }
77 )
78 }
79
80 @Test
81 fun getNotificationContentAlpha_inPortraitShade_usesPortraitShadeValue() {
82 setSplitShadeEnabled(false)
83
84 assertInterpolation(
85 actual = { fraction -> impl.getNotificationContentAlpha(fraction) },
86 expected = { fraction ->
87 portraitShadeInterpolator.getNotificationContentAlpha(fraction)
88 }
89 )
90 }
91
92 @Test
93 fun getNotificationFooterAlpha_inSplitShade_usesSplitShadeValue() {
94 setSplitShadeEnabled(true)
95
96 assertInterpolation(
97 actual = { fraction -> impl.getNotificationFooterAlpha(fraction) },
98 expected = { fraction -> splitShadeInterpolator.getNotificationFooterAlpha(fraction) }
99 )
100 }
101 @Test
102 fun getNotificationFooterAlpha_inPortraitShade_usesPortraitShadeValue() {
103 setSplitShadeEnabled(false)
104
105 assertInterpolation(
106 actual = { fraction -> impl.getNotificationFooterAlpha(fraction) },
107 expected = { fraction ->
108 portraitShadeInterpolator.getNotificationFooterAlpha(fraction)
109 }
110 )
111 }
112
113 @Test
114 fun getQsAlpha_inSplitShade_usesSplitShadeValue() {
115 setSplitShadeEnabled(true)
116
117 assertInterpolation(
118 actual = { fraction -> impl.getQsAlpha(fraction) },
119 expected = { fraction -> splitShadeInterpolator.getQsAlpha(fraction) }
120 )
121 }
122 @Test
123 fun getQsAlpha_inPortraitShade_usesPortraitShadeValue() {
124 setSplitShadeEnabled(false)
125
126 assertInterpolation(
127 actual = { fraction -> impl.getQsAlpha(fraction) },
128 expected = { fraction -> portraitShadeInterpolator.getQsAlpha(fraction) }
129 )
130 }
131
132 private fun setSplitShadeEnabled(enabled: Boolean) {
133 overrideResource(R.bool.config_use_split_notification_shade, enabled)
134 configurationController.notifyConfigurationChanged()
135 }
136
137 private fun assertInterpolation(
138 actual: (fraction: Float) -> Float,
139 expected: (fraction: Float) -> Float
140 ) {
141 for (i in 0..10) {
142 val fraction = i / 10f
143 expect.that(actual(fraction)).isEqualTo(expected(fraction))
144 }
145 }
146 }
147