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

Commit 9817a0df authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "include unit test for enhanced error handling" into rvc-dev am: 42472cb3 am: 448ba813

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11844551

Change-Id: I93b8d28be82e2781f07f7bf7f546b5d6e56cc63d
parents ce4d0339 448ba813
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -227,6 +227,23 @@ public class SliceClientPermissionsTest extends UiServiceTestCase {
        assertEquivalent(client, deser);
    }

    @Test(expected = XmlPullParserException.class)
    public void testReadEmptyFile_ThrowException() throws XmlPullParserException, IOException {
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        XmlSerializer serializer = XmlPullParserFactory.newInstance().newSerializer();
        serializer.setOutput(output, Encoding.UTF_8.name());
        // create empty xml document
        serializer.startDocument(null, true);
        serializer.endDocument();
        serializer.flush();

        ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
        XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
        parser.setInput(input, Encoding.UTF_8.name());
        SliceClientPermissions.createFrom(parser, mock(DirtyTracker.class));
        // Should throw exception since the xml is empty
    }

    private void assertEquivalent(SliceClientPermissions o1, SliceClientPermissions o2) {
        assertEquals(o1.getPkg(), o2.getPkg());
        ArrayList<SliceAuthority> a1 = new ArrayList<>(o1.getAuthorities());