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

Commit 5eb0532c 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: 117ed1b6

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

Change-Id: Idb4f48feb474d3d52761933449a9e9eed6689bdc
parents 36c0922d 117ed1b6
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());