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

Commit 037df74b authored by Lucas Lin's avatar Lucas Lin Committed by Automerger Merge Worker
Browse files

Merge "Refine NetworkMonitorTest#testReadAsString_StreamShorterThanLimit()"...

Merge "Refine NetworkMonitorTest#testReadAsString_StreamShorterThanLimit()" into rvc-dev am: e2509d6f

Change-Id: If3f9fa976cfb69c6c7527484f361d0e4826e32c6
parents 36ae7e91 e2509d6f
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -1861,15 +1861,13 @@ public class NetworkMonitorTest {
    @Test
    public void testReadAsString_StreamShorterThanLimit() throws Exception {
        final WrappedNetworkMonitor wnm = makeNotMeteredNetworkMonitor();
        final String content = "The HTTP response code is 200 but it is not a captive portal.";
        ByteArrayInputStream inputStream = new ByteArrayInputStream(
                content.getBytes(StandardCharsets.UTF_8));
        assertEquals(content, wnm.readAsString(inputStream, content.length(),
                StandardCharsets.UTF_8));
        // Reset the inputStream and test the case that the stream ends earlier than the limit.
        inputStream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8));
        assertEquals(content, wnm.readAsString(inputStream, content.length() + 10,
                StandardCharsets.UTF_8));
        final byte[] content = "The HTTP response code is 200 but it is not a captive portal."
                .getBytes(StandardCharsets.UTF_8);
        assertEquals(new String(content), wnm.readAsString(new ByteArrayInputStream(content),
                content.length, StandardCharsets.UTF_8));
        // Test the case that the stream ends earlier than the limit.
        assertEquals(new String(content), wnm.readAsString(new ByteArrayInputStream(content),
                content.length + 10, StandardCharsets.UTF_8));
    }

    @Test