From b79375eaf0751a3c845f4e3879d0b083b5ff3716 Mon Sep 17 00:00:00 2001 From: kikfox Date: Fri, 15 Sep 2023 12:50:04 +0200 Subject: [PATCH] test xml decompile with empty resource table --- .../arsc/chunk/xml/ResXmlDocumentTest.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/reandroid/arsc/chunk/xml/ResXmlDocumentTest.java b/src/test/java/com/reandroid/arsc/chunk/xml/ResXmlDocumentTest.java index a0538b5e4..35a742434 100644 --- a/src/test/java/com/reandroid/arsc/chunk/xml/ResXmlDocumentTest.java +++ b/src/test/java/com/reandroid/arsc/chunk/xml/ResXmlDocumentTest.java @@ -1,6 +1,7 @@ package com.reandroid.arsc.chunk.xml; import com.reandroid.apk.AndroidFrameworks; +import com.reandroid.apk.ApkModule; import com.reandroid.arsc.chunk.TableBlock; import com.reandroid.arsc.model.ResourceLibrary; import com.reandroid.xml.XMLFactory; @@ -115,7 +116,7 @@ public void testRemoveAttribute(){ @Test public void testEncodeDecodeXml() throws XmlPullParserException, IOException { ResXmlDocument document = new ResXmlDocument(); - document.setPackageBlock(createDummy().pickOne()); + document.setApkFile(createEmptyApkModule()); XmlPullParser parser = XMLFactory.newPullParser(XML_STRING); document.parse(parser); @@ -140,11 +141,15 @@ public void testEncodeDecodeXml() throws XmlPullParserException, IOException { decoded = decoded.replaceAll("\\s+", ""); Assert.assertEquals(org, decoded); } - private static TableBlock createDummy() throws IOException { + private static ApkModule createEmptyApkModule() throws IOException { + ApkModule apkModule = new ApkModule(); + apkModule.setTableBlock(createEmptyTable()); + return apkModule; + } + private static TableBlock createEmptyTable() throws IOException { TableBlock tableBlock = new TableBlock(); - tableBlock.newPackage(0x7f, "com.example.package"); - tableBlock.refresh(); tableBlock.addFramework(AndroidFrameworks.getLatest().getTableBlock()); + tableBlock.refresh(); return tableBlock; } private static final String XML_STRING = "\n" +