summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Josh Tsuji <tsuji@google.com> 2021-02-12 17:40:28 -0500
committer Josh Tsuji <tsuji@google.com> 2021-02-16 15:51:25 +0000
commit9a951b420a11de21327d239d5862df984ef00a4a (patch)
treebcec2cbf42ced33587d4a6281dda7b5b3eb58091
parent5a2b56975f3a791d6a2fc7605711995b2d33f3c9 (diff)
Add additional tests for AOD/unlocked animations.
Bug: 169693662 Test: atest SystemUITests Change-Id: I8216a45ddb8649ea55abed5a5d6a398cb1e0256f
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/doze/DozeUiTest.java26
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java23
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeParametersTest.java35
3 files changed, 84 insertions, 0 deletions
diff --git a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeUiTest.java b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeUiTest.java
index 069699c271f7..6d8c372a061b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeUiTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeUiTest.java
@@ -173,4 +173,30 @@ public class DozeUiTest extends SysuiTestCase {
mDozeUi.transitionTo(UNINITIALIZED, DOZE);
verify(mHost).setAnimateWakeup(eq(false));
}
+
+ @Test
+ public void controlScreenOffTrueWhenKeyguardNotShowingAndControlUnlockedScreenOff() {
+ when(mDozeParameters.getAlwaysOn()).thenReturn(true);
+ when(mDozeParameters.shouldControlUnlockedScreenOff()).thenReturn(true);
+
+ // Tell doze that keyguard is not visible.
+ mDozeUi.getKeyguardCallback().onKeyguardVisibilityChanged(false /* showing */);
+
+ // Since we're controlling the unlocked screen off animation, verify that we've asked to
+ // control the screen off animation despite being unlocked.
+ verify(mDozeParameters).setControlScreenOffAnimation(true);
+ }
+
+ @Test
+ public void controlScreenOffFalseWhenKeyguardNotShowingAndControlUnlockedScreenOffFalse() {
+ when(mDozeParameters.getAlwaysOn()).thenReturn(true);
+ when(mDozeParameters.shouldControlUnlockedScreenOff()).thenReturn(false);
+
+ // Tell doze that keyguard is not visible.
+ mDozeUi.getKeyguardCallback().onKeyguardVisibilityChanged(false /* showing */);
+
+ // Since we're not controlling the unlocked screen off animation, verify that we haven't
+ // asked to control the screen off animation since we're unlocked.
+ verify(mDozeParameters).setControlScreenOffAnimation(false);
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java
index 00943bc53bfd..b8c37fde2ce3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java
@@ -18,6 +18,8 @@ package com.android.systemui.keyguard;
import static android.view.WindowManagerPolicyConstants.OFF_BECAUSE_OF_USER;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -27,13 +29,17 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.app.admin.DevicePolicyManager;
import android.app.trust.TrustManager;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
+import android.view.View;
+import com.android.systemui.R;
import androidx.test.filters.SmallTest;
import com.android.internal.widget.LockPatternUtils;
@@ -45,6 +51,7 @@ import com.android.systemui.classifier.FalsingCollectorFake;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.navigationbar.NavigationModeController;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
+import com.android.systemui.statusbar.LightRevealScrim;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.util.DeviceConfigProxy;
@@ -117,4 +124,20 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
mViewMediator.mViewMediatorCallback.keyguardGone();
verify(mStatusBarKeyguardViewManager).setKeyguardGoingAwayState(eq(false));
}
+
+ @Test
+ public void testIsAnimatingScreenOff() {
+ when(mDozeParameters.shouldControlUnlockedScreenOff()).thenReturn(true);
+
+ mViewMediator.onFinishedGoingToSleep(OFF_BECAUSE_OF_USER, false);
+ mViewMediator.setDozing(true);
+
+ // Mid-doze, we should be animating the screen off animation.
+ mViewMediator.onDozeAmountChanged(0.5f, 0.5f);
+ assertTrue(mViewMediator.isAnimatingScreenOff());
+
+ // Once we're 100% dozed, the screen off animation should be completed.
+ mViewMediator.onDozeAmountChanged(1f, 1f);
+ assertFalse(mViewMediator.isAnimatingScreenOff());
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeParametersTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeParametersTest.java
index b9fd75ef5fda..421c6f4aab0b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeParametersTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeParametersTest.java
@@ -18,6 +18,8 @@ package com.android.systemui.statusbar.phone;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.reset;
@@ -114,4 +116,37 @@ public class DozeParametersTest extends SysuiTestCase {
assertThat(mDozeParameters.getAlwaysOn()).isFalse();
}
+
+ @Test
+ public void testControlUnlockedScreenOffAnimation_dozeAfterScreenOff_false() {
+ when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
+ mDozeParameters.onTuningChanged(Settings.Secure.DOZE_ALWAYS_ON, "1");
+ when(mFeatureFlags.useNewLockscreenAnimations()).thenReturn(true);
+
+ assertTrue(mDozeParameters.shouldControlUnlockedScreenOff());
+
+ // Trigger the setter for the current value.
+ mDozeParameters.setControlScreenOffAnimation(mDozeParameters.shouldControlScreenOff());
+
+ // We should have asked power manager not to doze after screen off no matter what, since
+ // we're animating and controlling screen off.
+ verify(mPowerManager).setDozeAfterScreenOff(eq(false));
+ }
+
+ @Test
+ public void testControlUnlockedScreenOffAnimationDisabled_dozeAfterScreenOff() {
+ when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
+ mDozeParameters.onTuningChanged(Settings.Secure.DOZE_ALWAYS_ON, "1");
+ when(mFeatureFlags.useNewLockscreenAnimations()).thenReturn(false);
+
+ assertFalse(mDozeParameters.shouldControlUnlockedScreenOff());
+
+ // Trigger the setter for the current value.
+ mDozeParameters.setControlScreenOffAnimation(mDozeParameters.shouldControlScreenOff());
+
+ // We should have asked power manager to doze only if we're not controlling screen off
+ // normally.
+ verify(mPowerManager).setDozeAfterScreenOff(
+ eq(!mDozeParameters.shouldControlScreenOff()));
+ }
}