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

Commit 448ba813 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

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

Change-Id: I93e0b441034327dedf54d303742d84d8c2d58203
parents cf50e800 42472cb3
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());