1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5  * except in compliance with the License. You may obtain a copy of the License at
6  *
7  *      http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software distributed under the
10  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11  * KIND, either express or implied. See the License for the specific language governing
12  * permissions and limitations under the License.
13  */
14 
15 package com.android.systemui.animation
16 
17 import com.android.internal.jank.InteractionJankMonitor
18 import com.android.systemui.dagger.qualifiers.Main
19 import java.util.concurrent.Executor
20 
21 /** A [DialogTransitionAnimator] to be used in tests. */
22 @JvmOverloads
fakeDialogTransitionAnimatornull23 fun fakeDialogTransitionAnimator(
24     @Main mainExecutor: Executor,
25     isUnlocked: Boolean = true,
26     isShowingAlternateAuthOnUnlock: Boolean = false,
27     isPredictiveBackQsDialogAnim: Boolean = false,
28     interactionJankMonitor: InteractionJankMonitor,
29 ): DialogTransitionAnimator {
30     return DialogTransitionAnimator(
31         mainExecutor = mainExecutor,
32         callback =
33             FakeCallback(
34                 isUnlocked = isUnlocked,
35                 isShowingAlternateAuthOnUnlock = isShowingAlternateAuthOnUnlock,
36             ),
37         interactionJankMonitor = interactionJankMonitor,
38         featureFlags =
39             object : AnimationFeatureFlags {
40                 override val isPredictiveBackQsDialogAnim = isPredictiveBackQsDialogAnim
41             },
42         transitionAnimator = fakeTransitionAnimator(mainExecutor),
43         isForTesting = true,
44     )
45 }
46 
47 private class FakeCallback(
48     private val isDreaming: Boolean = false,
49     private val isUnlocked: Boolean = true,
50     private val isShowingAlternateAuthOnUnlock: Boolean = false,
51 ) : DialogTransitionAnimator.Callback {
isDreamingnull52     override fun isDreaming(): Boolean = isDreaming
53     override fun isUnlocked(): Boolean = isUnlocked
54     override fun isShowingAlternateAuthOnUnlock() = isShowingAlternateAuthOnUnlock
55 }
56