Add test for stack scroller padding.
Adding tests before changing the KeyguardClockPositionAlgorithm to deal with positioning the stack scroller when a full screen custom clock is present. The tests should help reduce the risk of regressions. Bug: 120037316 Test: KeyguardClockPositionAlgorithmTest passes locally Change-Id: I505d9402fd73697f4222138bd753bdfe32f87337
This commit is contained in:
@@ -37,7 +37,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
private static final int EMPTY_MARGIN = 0;
|
||||
private static final int EMPTY_HEIGHT = 0;
|
||||
private static final boolean SECURE_LOCKED = false;
|
||||
private static final boolean PULSING_NO = false;
|
||||
private static final float ZERO_DRAG = 0.f;
|
||||
private static final float OPAQUE = 1.f;
|
||||
private static final float TRANSPARENT = 0.f;
|
||||
@@ -48,6 +47,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
private float mPanelExpansion;
|
||||
private int mKeyguardStatusHeight;
|
||||
private float mDark;
|
||||
private boolean mPulsing;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -171,6 +171,156 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
assertThat(mClockPosition.clockAlpha).isEqualTo(TRANSPARENT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifPositionMiddleOfScreenOnAOD() {
|
||||
// GIVEN on AOD and both stack scroll and clock have 0 height
|
||||
givenAOD();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = EMPTY_HEIGHT;
|
||||
// WHEN the position algorithm is run
|
||||
positionClock();
|
||||
// THEN the notif padding is half of the screen (SCREEN_HEIGHT / 2).
|
||||
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifPositionIndependentOfKeyguardStatusHeightOnAOD() {
|
||||
// GIVEN on AOD and clock has a nonzero height
|
||||
givenAOD();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = 100;
|
||||
// WHEN the position algorithm is run
|
||||
positionClock();
|
||||
// THEN the notif padding is half of the screen (SCREEN_HEIGHT / 2).
|
||||
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifPositionWithLargeClockOnAOD() {
|
||||
// GIVEN on AOD and clock has a nonzero height
|
||||
givenAOD();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = SCREEN_HEIGHT;
|
||||
// WHEN the position algorithm is run
|
||||
positionClock();
|
||||
// THEN the notif padding is, unfortunately, the entire screen.
|
||||
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(SCREEN_HEIGHT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifPositionWhilePulsingOnAOD() {
|
||||
// GIVEN on AOD and pulsing
|
||||
givenAOD();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = EMPTY_HEIGHT;
|
||||
mPulsing = true;
|
||||
mClockPositionAlgorithm.setPulsingPadding(200);
|
||||
// WHEN the clock position algorithm is run
|
||||
positionClock();
|
||||
// THEN the notif padding doesn't adjust for pulsing.
|
||||
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifPositionMiddleOfScreenOnLockScreen() {
|
||||
// GIVEN on lock screen and both stack scroll and clock have 0 height
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = EMPTY_HEIGHT;
|
||||
// WHEN the position algorithm is run
|
||||
positionClock();
|
||||
// THEN the notif padding is half of the screen (SCREEN_HEIGHT / 2).
|
||||
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifPositionAdjustsForStackHeightOnLockScreen() {
|
||||
// GIVEN on lock screen and stack scroller has a nonzero height
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = 500;
|
||||
mKeyguardStatusHeight = EMPTY_HEIGHT;
|
||||
// WHEN the position algorithm is run
|
||||
positionClock();
|
||||
// THEN the notif padding adjusts for the expanded notif stack.
|
||||
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(750);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifPositionAdjustsForClockHeightOnLockScreen() {
|
||||
// GIVEN on lock screen and stack scroller has a nonzero height
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = 200;
|
||||
// WHEN the position algorithm is run
|
||||
positionClock();
|
||||
// THEN the notif padding adjusts for both clock and notif stack.
|
||||
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifPositionAdjustsForStackHeightAndClockHeightOnLockScreen() {
|
||||
// GIVEN on lock screen and stack scroller has a nonzero height
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = 500;
|
||||
mKeyguardStatusHeight = 200;
|
||||
// WHEN the position algorithm is run
|
||||
positionClock();
|
||||
// THEN the notif padding adjusts for both clock and notif stack.
|
||||
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(810);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifPositionWithLargeClockOnLockScreen() {
|
||||
// GIVEN on lock screen and clock has a nonzero height
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = SCREEN_HEIGHT;
|
||||
// WHEN the position algorithm is run
|
||||
positionClock();
|
||||
// THEN the notif padding is half of the screen (SCREEN_HEIGHT / 2).
|
||||
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifPositionWithFullDragOnLockScreen() {
|
||||
// GIVEN the lock screen is dragged up
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = EMPTY_HEIGHT;
|
||||
mPanelExpansion = 0.f;
|
||||
// WHEN the clock position algorithm is run
|
||||
positionClock();
|
||||
// THEN the notif padding is zero.
|
||||
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifPositionWithLargeClockFullDragOnLockScreen() {
|
||||
// GIVEN the lock screen is dragged up and a full screen clock
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = SCREEN_HEIGHT;
|
||||
mPanelExpansion = 0.f;
|
||||
// WHEN the clock position algorithm is run
|
||||
positionClock();
|
||||
// THEN the notif padding is zero.
|
||||
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifPositionWhilePulsingOnLockScreen() {
|
||||
// GIVEN on lock screen and pulsing
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = EMPTY_HEIGHT;
|
||||
mPulsing = true;
|
||||
mClockPositionAlgorithm.setPulsingPadding(200);
|
||||
// WHEN the clock position algorithm is run
|
||||
positionClock();
|
||||
// THEN the notif padding adjusts for pulsing.
|
||||
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1200);
|
||||
}
|
||||
|
||||
private void givenAOD() {
|
||||
mPanelExpansion = 1.f;
|
||||
mDark = 1.f;
|
||||
@@ -184,7 +334,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
private void positionClock() {
|
||||
mClockPositionAlgorithm.setup(EMPTY_MARGIN, SCREEN_HEIGHT, mNotificationStackHeight,
|
||||
mPanelExpansion, SCREEN_HEIGHT, mKeyguardStatusHeight, mDark, SECURE_LOCKED,
|
||||
PULSING_NO, ZERO_DRAG);
|
||||
mPulsing, ZERO_DRAG);
|
||||
mClockPositionAlgorithm.run(mClockPosition);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user