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

Commit 7443b7ad authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Make single bounding rect when none set relative to window origin" into main

parents c5278677 cceb6b31
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -355,11 +355,17 @@ public class InsetsSource implements Parcelable {
        final Rect frame = getFrame();
        if (mBoundingRects == null) {
            // No bounding rects set, make a single bounding rect that covers the intersection of
            // the |frame| and the |relativeFrame|.
            // the |frame| and the |relativeFrame|. Also make it relative to the window origin.
            return mTmpBoundingRect.setIntersect(frame, relativeFrame)
                    ? new Rect[]{ new Rect(mTmpBoundingRect) }
                    ? new Rect[]{
                            new Rect(
                                    mTmpBoundingRect.left - relativeFrame.left,
                                    mTmpBoundingRect.top - relativeFrame.top,
                                    mTmpBoundingRect.right - relativeFrame.left,
                                    mTmpBoundingRect.bottom - relativeFrame.top
                            )
                    }
                    : NO_BOUNDING_RECTS;

        }

        // Special treatment for captionBar inset type. During drag-resizing, the |frame| and
+11 −0
Original line number Diff line number Diff line
@@ -290,6 +290,17 @@ public class InsetsSourceTest {
        assertEquals(new Rect(0, 0, 1000, 100), rects[0]);
    }

    @Test
    public void testCalculateBoundingRects_noBoundingRectsAndFrameNotAtOrigin_createsSingleRect() {
        mSource.setFrame(new Rect(100, 100, 1200, 200));
        mSource.setBoundingRects(null);

        final Rect[] rects = mSource.calculateBoundingRects(new Rect(100, 100, 1100, 1100), false);

        assertEquals(1, rects.length);
        assertEquals(new Rect(0, 0, 1000, 100), rects[0]);
    }

    @Test
    public void testCalculateBoundingRects_noBoundingRectsAndLargerFrame_singleRectFitsRelFrame() {
        mSource.setFrame(new Rect(0, 0, 1000, 100));