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

Commit a0ab9fc7 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()" am: 63e68d84 am: ee786a33 am: e69dbea0 am: bb3761e1

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


    @Test
    @Test