MCPcopy Index your code
hub / github.com/HumbleUI/Skija / StreamAssetTest

Class StreamAssetTest

tests/java/StreamAssetTest.java:8–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6import io.github.humbleui.skija.*;
7
8public class StreamAssetTest implements Executable {
9 static final int fontStreamLength = 680112;
10
11 @Override
12 public void execute() throws Exception {
13 Typeface typeface = FontMgr.getDefault().makeFromFile("fonts/InterHinted-Regular.ttf", 0);
14 int[] ttcIndex = new int[1];
15 ttcIndex[0] = -1;
16 StreamAsset stream = typeface.openStream(ttcIndex);
17 assertNotNull(stream);
18 assertEquals(0, ttcIndex[0]);
19 assertEquals(fontStreamLength, stream.getLength());
20
21 byte[] buffer = new byte[1024];
22 int bytesRead = stream.read(buffer, buffer.length);
23 int pos = stream.getPosition();
24 assertEquals(1024, bytesRead);
25 assertEquals(1024, pos);
26 assertEquals(true, stream.move(10));
27 assertEquals(1034, stream.getPosition());
28 assertEquals(true, stream.rewind());
29 assertEquals(0, stream.getPosition());
30 assertEquals(true, stream.seek(1000));
31 assertEquals(1000, stream.getPosition());
32 stream.close();
33 }
34}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected