Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9a3d5264 authored by Mark Renouf's avatar Mark Renouf Committed by Android (Google) Code Review
Browse files

Merge changes Iecf5ef2d,Id36765d6 into sc-dev

* changes:
  Improve logging in ScrollCaptureFrameworkSmokeTest
  Long screenshots: continue after partial tile result
parents befdba37 86912852
Loading
Loading
Loading
Loading
+16 −8
Original line number Diff line number Diff line
@@ -203,7 +203,7 @@ public class ScrollCaptureController {
                && result.captured.height() < result.requested.height();
        boolean finish = false;

        if (partialResult || emptyResult) {
        if (emptyResult) {
            // Potentially reached a vertical boundary. Extend in the other direction.
            if (mFinishOnBoundary) {
                Log.d(TAG, "Partial/empty: finished!");
@@ -217,12 +217,12 @@ public class ScrollCaptureController {
                Log.d(TAG, "Partial/empty: cleared, switch direction to finish");
            }
        } else {
            // Got the full requested result, but may have got enough bitmap data now
            // Got a non-empty result, but may already have enough bitmap data now
            int expectedTiles = mImageTileSet.size() + 1;
            if (expectedTiles >= mSession.getMaxTiles()) {
                Log.d(TAG, "Hit max tiles: finished");
                // If we ever hit the max tiles, we've got enough bitmap data to finish (even if we
                // weren't sure we'd finish on this pass).
                // If we ever hit the max tiles, we've got enough bitmap data to finish
                // (even if we weren't sure we'd finish on this pass).
                finish = true;
            } else {
                if (mScrollingUp && !mFinishOnBoundary) {
@@ -259,10 +259,18 @@ public class ScrollCaptureController {
            return;
        }

        // Partial or empty results caused the direction the flip, so we can reliably use the
        // requested edges to determine the next top.
        int nextTop = (mScrollingUp) ? result.requested.top - mSession.getTileHeight()
        int nextTop;
        if (emptyResult) {
            // An empty result caused the direction the flip,
            // so use the requested edges to determine the next top.
            nextTop = (mScrollingUp)
                    ? result.requested.top - mSession.getTileHeight()
                    : result.requested.bottom;
        } else {
            nextTop = (mScrollingUp)
                    ? result.captured.top - mSession.getTileHeight()
                    : result.captured.bottom;
        }
        requestNextTile(nextTop);
    }

+52 −0
Original line number Diff line number Diff line
@@ -76,6 +76,58 @@ public class ScrollCaptureControllerTest extends SysuiTestCase {
        }
    }

    @Test
    public void testInfiniteWithPartialResultsTop() {
        ScrollCaptureController controller = new TestScenario()
                .withPageHeight(100)
                .withPageVisibleRange(5, 100) // <-- simulate 5px of invisible top
                .withMaxPages(2.5f)
                .withTileHeight(50)
                .withAvailableRange(Integer.MIN_VALUE, Integer.MAX_VALUE)
                .createController(mContext);

        ScrollCaptureController.LongScreenshot screenshot =
                getUnchecked(controller.run(EMPTY_RESPONSE));

        // Each tile is cropped to the visible page size, which is inset 5px from the TOP
        // requested    result
        //   0,   50       5,   50
        // -45,    5     -40,    5   <-- clear previous /  top
        //   5,   55       5,   55   (not cropped, target is positioned fully within visible range)
        //  55,  105      55,  105
        // 105,  155     105,  155
        // 155,  205     155,  205   <-- bottom

        assertEquals("top", -40, screenshot.getTop());
        assertEquals("bottom", 205, screenshot.getBottom());
    }

    @Test
    public void testInfiniteWithPartialResultsBottom() {
        ScrollCaptureController controller = new TestScenario()
                .withPageHeight(100)
                .withPageVisibleRange(0, 95) // <-- simulate 5px of invisible bottom
                .withMaxPages(2.5f)
                .withTileHeight(50)
                .withAvailableRange(Integer.MIN_VALUE, Integer.MAX_VALUE)
                .createController(mContext);

        ScrollCaptureController.LongScreenshot screenshot =
                getUnchecked(controller.run(EMPTY_RESPONSE));

        // Each tile is cropped to the visible page size, which is inset 5px from the BOTTOM
        // requested      result
        //    0,   50        0,   50   // not cropped, positioned within visible range
        //  -50,    0      -50,    0   <-- clear previous/reverse
        //    0,   50     -  0,   45   // target now positioned at page bottom, bottom cropped
        //   45,   95,      45,   90
        //   90,  140,     140,  135
        //  135,  185      185,  180   <-- bottom

        assertEquals("top", -50, screenshot.getTop());
        assertEquals("bottom", 180, screenshot.getBottom());
    }

    @Test
    public void testLimitedBottom() {
        ScrollCaptureController controller = new TestScenario()
+6 −2
Original line number Diff line number Diff line
@@ -82,7 +82,11 @@ public class ScrollCaptureFrameworkSmokeTest extends SysuiTestCase {
        latch.await(1000, TimeUnit.MILLISECONDS);

        assertNotNull(mResponse);
        assertTrue(mResponse.isConnected());
        assertTrue(mResponse.getWindowTitle().contains(ScrollViewActivity.class.getSimpleName()));
        if (!mResponse.isConnected()) {
            Log.e(TAG, "Received response with no connection: " + mResponse);
            fail("expected response.isConnected() == true");
        }
        assertTrue("expected a connection to ScrollViewActivity",
                mResponse.getWindowTitle().contains(ScrollViewActivity.class.getSimpleName()));
    }
}