summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Matt Casey <mrcasey@google.com> 2021-03-19 13:15:56 -0400
committer Matt Casey <mrcasey@google.com> 2021-03-19 13:24:07 -0400
commit8cc0ab9cfae52ff06c745ed3cc8eb06f45184b46 (patch)
treea4a32b16cb7f11c65648f0a526b20a7fd2ba0f09
parent177d8e36f546cfed613960aadccd93298d63be49 (diff)
Make ScrollCaptureControllerTest stricter
- Ensure requested rect overlaps with total rect. - Ensure sequential tiles are adjacent Test: atest ScrolCaptureControllerTest Change-Id: Ib722b7b65a81df30930467cd5758d8e37bb71f4d
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/screenshot/ScrollCaptureControllerTest.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScrollCaptureControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScrollCaptureControllerTest.java
index 410d9de9e0ac..7fe178c81ea8 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScrollCaptureControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScrollCaptureControllerTest.java
@@ -17,6 +17,7 @@
package com.android.systemui.screenshot;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -57,13 +58,17 @@ public class ScrollCaptureControllerTest extends SysuiTestCase {
public int availableBottom = Integer.MAX_VALUE;
// If true, return an empty rect any time a partial result would have been returned.
public boolean emptyInsteadOfPartial = false;
+ private int mPreviousTopRequested = 0;
@Override
public ListenableFuture<ScrollCaptureClient.CaptureResult> requestTile(int top) {
+ // Ensure we don't request a tile more than a tile away.
+ assertTrue(Math.abs(top - mPreviousTopRequested) <= getTileHeight());
+ mPreviousTopRequested = top;
Rect requested = new Rect(0, top, getPageWidth(), top + getTileHeight());
Rect fullContent = new Rect(0, availableTop, getPageWidth(), availableBottom);
Rect captured = new Rect(requested);
- captured.intersect(fullContent);
+ assertTrue(captured.intersect(fullContent));
if (emptyInsteadOfPartial && captured.height() != getTileHeight()) {
captured = new Rect();
}