use of org.jf.dexlib2.DexFileFactory.DexEntryFinder in project smali by JesusFreke.
the class DexEntryFinderTest method testSimilarEntries.
@Test
public void testSimilarEntries() throws Exception {
Map<String, DexBackedDexFile> entries = Maps.newHashMap();
DexBackedDexFile dexFile1 = mock(DexBackedDexFile.class);
entries.put("/system/framework/framework.jar", dexFile1);
DexBackedDexFile dexFile2 = mock(DexBackedDexFile.class);
entries.put("system/framework/framework.jar", dexFile2);
DexEntryFinder testFinder = new DexEntryFinder("blah.oat", new TestMultiDexContainer(entries));
Assert.assertEquals(dexFile1, testFinder.findEntry("/system/framework/framework.jar", true).getDexFile());
Assert.assertEquals(dexFile2, testFinder.findEntry("system/framework/framework.jar", true).getDexFile());
assertMultipleMatchingEntries(testFinder, "/system/framework/framework.jar");
assertMultipleMatchingEntries(testFinder, "system/framework/framework.jar");
assertMultipleMatchingEntries(testFinder, "/framework/framework.jar");
assertMultipleMatchingEntries(testFinder, "framework/framework.jar");
assertMultipleMatchingEntries(testFinder, "/framework.jar");
assertMultipleMatchingEntries(testFinder, "framework.jar");
}
use of org.jf.dexlib2.DexFileFactory.DexEntryFinder in project smali by JesusFreke.
the class DexEntryFinderTest method testMatchingSuffix.
@Test
public void testMatchingSuffix() throws Exception {
Map<String, DexBackedDexFile> entries = Maps.newHashMap();
DexBackedDexFile dexFile1 = mock(DexBackedDexFile.class);
entries.put("/system/framework/framework.jar", dexFile1);
DexBackedDexFile dexFile2 = mock(DexBackedDexFile.class);
entries.put("/framework/framework.jar", dexFile2);
DexEntryFinder testFinder = new DexEntryFinder("blah.oat", new TestMultiDexContainer(entries));
Assert.assertEquals(dexFile1, testFinder.findEntry("/system/framework/framework.jar", true).getDexFile());
Assert.assertEquals(dexFile2, testFinder.findEntry("/framework/framework.jar", true).getDexFile());
Assert.assertEquals(dexFile2, testFinder.findEntry("/framework/framework.jar", false).getDexFile());
Assert.assertEquals(dexFile2, testFinder.findEntry("framework/framework.jar", false).getDexFile());
assertMultipleMatchingEntries(testFinder, "/framework.jar");
assertMultipleMatchingEntries(testFinder, "framework.jar");
}
use of org.jf.dexlib2.DexFileFactory.DexEntryFinder in project smali by JesusFreke.
the class DexEntryFinderTest method testNonDexEntries.
@Test
public void testNonDexEntries() throws Exception {
Map<String, DexBackedDexFile> entries = Maps.newHashMap();
DexBackedDexFile dexFile1 = mock(DexBackedDexFile.class);
entries.put("classes.dex", dexFile1);
entries.put("/blah/classes.dex", null);
DexEntryFinder testFinder = new DexEntryFinder("blah.oat", new TestMultiDexContainer(entries));
Assert.assertEquals(dexFile1, testFinder.findEntry("classes.dex", true).getDexFile());
Assert.assertEquals(dexFile1, testFinder.findEntry("classes.dex", false).getDexFile());
assertUnsupportedFileType(testFinder, "/blah/classes.dex", true);
assertDexFileNotFound(testFinder, "/blah/classes.dex", false);
}
use of org.jf.dexlib2.DexFileFactory.DexEntryFinder in project smali by JesusFreke.
the class DexEntryFinderTest method testNormalStuff.
@Test
public void testNormalStuff() throws Exception {
Map<String, DexBackedDexFile> entries = Maps.newHashMap();
DexBackedDexFile dexFile1 = mock(DexBackedDexFile.class);
entries.put("/system/framework/framework.jar", dexFile1);
DexBackedDexFile dexFile2 = mock(DexBackedDexFile.class);
entries.put("/system/framework/framework.jar:classes2.dex", dexFile2);
DexEntryFinder testFinder = new DexEntryFinder("blah.oat", new TestMultiDexContainer(entries));
Assert.assertEquals(dexFile1, testFinder.findEntry("/system/framework/framework.jar", true).getDexFile());
assertEntryNotFound(testFinder, "system/framework/framework.jar", true);
assertEntryNotFound(testFinder, "/framework/framework.jar", true);
assertEntryNotFound(testFinder, "framework/framework.jar", true);
assertEntryNotFound(testFinder, "/framework.jar", true);
assertEntryNotFound(testFinder, "framework.jar", true);
Assert.assertEquals(dexFile1, testFinder.findEntry("system/framework/framework.jar", false).getDexFile());
Assert.assertEquals(dexFile1, testFinder.findEntry("/framework/framework.jar", false).getDexFile());
Assert.assertEquals(dexFile1, testFinder.findEntry("framework/framework.jar", false).getDexFile());
Assert.assertEquals(dexFile1, testFinder.findEntry("/framework.jar", false).getDexFile());
Assert.assertEquals(dexFile1, testFinder.findEntry("framework.jar", false).getDexFile());
assertEntryNotFound(testFinder, "ystem/framework/framework.jar", false);
assertEntryNotFound(testFinder, "ssystem/framework/framework.jar", false);
assertEntryNotFound(testFinder, "ramework/framework.jar", false);
assertEntryNotFound(testFinder, "ramework.jar", false);
assertEntryNotFound(testFinder, "framework", false);
Assert.assertEquals(dexFile2, testFinder.findEntry("/system/framework/framework.jar:classes2.dex", true).getDexFile());
assertEntryNotFound(testFinder, "system/framework/framework.jar:classes2.dex", true);
assertEntryNotFound(testFinder, "framework.jar:classes2.dex", true);
assertEntryNotFound(testFinder, "classes2.dex", true);
Assert.assertEquals(dexFile2, testFinder.findEntry("system/framework/framework.jar:classes2.dex", false).getDexFile());
Assert.assertEquals(dexFile2, testFinder.findEntry("/framework/framework.jar:classes2.dex", false).getDexFile());
Assert.assertEquals(dexFile2, testFinder.findEntry("framework/framework.jar:classes2.dex", false).getDexFile());
Assert.assertEquals(dexFile2, testFinder.findEntry("/framework.jar:classes2.dex", false).getDexFile());
Assert.assertEquals(dexFile2, testFinder.findEntry("framework.jar:classes2.dex", false).getDexFile());
Assert.assertEquals(dexFile2, testFinder.findEntry(":classes2.dex", false).getDexFile());
Assert.assertEquals(dexFile2, testFinder.findEntry("classes2.dex", false).getDexFile());
assertEntryNotFound(testFinder, "ystem/framework/framework.jar:classes2.dex", false);
assertEntryNotFound(testFinder, "ramework.jar:classes2.dex", false);
assertEntryNotFound(testFinder, "lasses2.dex", false);
assertEntryNotFound(testFinder, "classes2", false);
}
Aggregations