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

Commit f61ce18e authored by Seigo Nonaka's avatar Seigo Nonaka
Browse files

Fix canvas crash in CanvasDrawTextTest

Call drawText in begin/end recording section.

Bug: 168846481
Test: atest CanvasDrawTextTest
Change-Id: I512f7a7b3de44236e567f80281a2fd9fbb61be9a
parent 16b02d48
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -53,19 +53,19 @@ public class CanvasDrawTextTest {
        final String text = mTextUtil.nextRandomParagraph(
                WORD_LENGTH, 4 * 1024 * 1024 /* 4mb text */).toString();
        final RenderNode node = RenderNode.create("benchmark", null);
        final RenderNode child = RenderNode.create("child", null);
        child.setLeftTopRightBottom(50, 50, 100, 100);

        RecordingCanvas canvas = node.start(100, 100);
        node.end(canvas);
        canvas = child.start(50, 50);
        child.end(canvas);

        final Random r = new Random(0);

        while (state.keepRunning()) {
            state.pauseTiming();
            RecordingCanvas canvas = node.beginRecording();
            int start = r.nextInt(text.length() - 100);
            state.resumeTiming();

            canvas.drawText(text, start, start + 100, 0, 0, PAINT);

            state.pauseTiming();
            node.endRecording();
            state.resumeTiming();
        }
    }
}