diff options
Diffstat (limited to 'src/test/java/cuchaz/enigma/TestTranslator.java')
| -rw-r--r-- | src/test/java/cuchaz/enigma/TestTranslator.java | 155 |
1 files changed, 0 insertions, 155 deletions
diff --git a/src/test/java/cuchaz/enigma/TestTranslator.java b/src/test/java/cuchaz/enigma/TestTranslator.java deleted file mode 100644 index a420afe..0000000 --- a/src/test/java/cuchaz/enigma/TestTranslator.java +++ /dev/null | |||
| @@ -1,155 +0,0 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2015 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Lesser General Public | ||
| 5 | * License v3.0 which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/lgpl.html | ||
| 7 | * | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | |||
| 12 | package cuchaz.enigma; | ||
| 13 | |||
| 14 | import cuchaz.enigma.translation.representation.entry.Entry; | ||
| 15 | import org.junit.BeforeClass; | ||
| 16 | import org.junit.Test; | ||
| 17 | |||
| 18 | import static cuchaz.enigma.TestEntryFactory.*; | ||
| 19 | |||
| 20 | public class TestTranslator { | ||
| 21 | |||
| 22 | @BeforeClass | ||
| 23 | public static void beforeClass() | ||
| 24 | throws Exception { | ||
| 25 | //TODO FIx | ||
| 26 | //deobfuscator = new Enigma(new JarFile("build/test-obf/translation.jar")); | ||
| 27 | //try (InputStream in = TestTranslator.class.getResourceAsStream("/cuchaz/enigma/resources/translation.mappings")) { | ||
| 28 | // mappings = new MappingsJsonReader().read(new InputStreamReader(in)); | ||
| 29 | // deobfuscator.setMappings(mappings); | ||
| 30 | // deobfTranslator = deobfuscator.getTranslator(TranslationDirection.Deobfuscating); | ||
| 31 | // obfTranslator = deobfuscator.getTranslator(TranslationDirection.Obfuscating); | ||
| 32 | //} | ||
| 33 | } | ||
| 34 | |||
| 35 | @Test | ||
| 36 | public void basicClasses() { | ||
| 37 | assertMapping(newClass("a"), newClass("deobf/A_Basic")); | ||
| 38 | assertMapping(newClass("b"), newClass("deobf/B_BaseClass")); | ||
| 39 | assertMapping(newClass("c"), newClass("deobf/C_SubClass")); | ||
| 40 | } | ||
| 41 | |||
| 42 | @Test | ||
| 43 | public void basicFields() { | ||
| 44 | assertMapping(newField("a", "a", "I"), newField("deobf/A_Basic", "f1", "I")); | ||
| 45 | assertMapping(newField("a", "a", "F"), newField("deobf/A_Basic", "f2", "F")); | ||
| 46 | assertMapping(newField("a", "a", "Ljava/lang/String;"), newField("deobf/A_Basic", "f3", "Ljava/lang/String;")); | ||
| 47 | } | ||
| 48 | |||
| 49 | @Test | ||
| 50 | public void basicMethods() { | ||
| 51 | assertMapping(newMethod("a", "a", "()V"), newMethod("deobf/A_Basic", "m1", "()V")); | ||
| 52 | assertMapping(newMethod("a", "a", "()I"), newMethod("deobf/A_Basic", "m2", "()I")); | ||
| 53 | assertMapping(newMethod("a", "a", "(I)V"), newMethod("deobf/A_Basic", "m3", "(I)V")); | ||
| 54 | assertMapping(newMethod("a", "a", "(I)I"), newMethod("deobf/A_Basic", "m4", "(I)I")); | ||
| 55 | } | ||
| 56 | |||
| 57 | // TODO: basic constructors | ||
| 58 | |||
| 59 | @Test | ||
| 60 | public void inheritanceFields() { | ||
| 61 | assertMapping(newField("b", "a", "I"), newField("deobf/B_BaseClass", "f1", "I")); | ||
| 62 | assertMapping(newField("b", "a", "C"), newField("deobf/B_BaseClass", "f2", "C")); | ||
| 63 | assertMapping(newField("c", "b", "I"), newField("deobf/C_SubClass", "f3", "I")); | ||
| 64 | assertMapping(newField("c", "c", "I"), newField("deobf/C_SubClass", "f4", "I")); | ||
| 65 | } | ||
| 66 | |||
| 67 | @Test | ||
| 68 | public void inheritanceFieldsShadowing() { | ||
| 69 | assertMapping(newField("c", "b", "C"), newField("deobf/C_SubClass", "f2", "C")); | ||
| 70 | } | ||
| 71 | |||
| 72 | @Test | ||
| 73 | public void inheritanceFieldsBySubClass() { | ||
| 74 | assertMapping(newField("c", "a", "I"), newField("deobf/C_SubClass", "f1", "I")); | ||
| 75 | // NOTE: can't reference b.C by subclass since it's shadowed | ||
| 76 | } | ||
| 77 | |||
| 78 | @Test | ||
| 79 | public void inheritanceMethods() { | ||
| 80 | assertMapping(newMethod("b", "a", "()I"), newMethod("deobf/B_BaseClass", "m1", "()I")); | ||
| 81 | assertMapping(newMethod("b", "b", "()I"), newMethod("deobf/B_BaseClass", "m2", "()I")); | ||
| 82 | assertMapping(newMethod("c", "c", "()I"), newMethod("deobf/C_SubClass", "m3", "()I")); | ||
| 83 | } | ||
| 84 | |||
| 85 | @Test | ||
| 86 | public void inheritanceMethodsOverrides() { | ||
| 87 | assertMapping(newMethod("c", "a", "()I"), newMethod("deobf/C_SubClass", "m1", "()I")); | ||
| 88 | } | ||
| 89 | |||
| 90 | @Test | ||
| 91 | public void inheritanceMethodsBySubClass() { | ||
| 92 | assertMapping(newMethod("c", "b", "()I"), newMethod("deobf/C_SubClass", "m2", "()I")); | ||
| 93 | } | ||
| 94 | |||
| 95 | @Test | ||
| 96 | public void innerClasses() { | ||
| 97 | |||
| 98 | // classes | ||
| 99 | assertMapping(newClass("g"), newClass("deobf/G_OuterClass")); | ||
| 100 | assertMapping(newClass("g$a"), newClass("deobf/G_OuterClass$A_InnerClass")); | ||
| 101 | assertMapping(newClass("g$a$a"), newClass("deobf/G_OuterClass$A_InnerClass$A_InnerInnerClass")); | ||
| 102 | assertMapping(newClass("g$b"), newClass("deobf/G_OuterClass$b")); | ||
| 103 | assertMapping(newClass("g$b$a"), newClass("deobf/G_OuterClass$b$A_NamedInnerClass")); | ||
| 104 | |||
| 105 | // fields | ||
| 106 | assertMapping(newField("g$a", "a", "I"), newField("deobf/G_OuterClass$A_InnerClass", "f1", "I")); | ||
| 107 | assertMapping(newField("g$a", "a", "Ljava/lang/String;"), newField("deobf/G_OuterClass$A_InnerClass", "f2", "Ljava/lang/String;")); | ||
| 108 | assertMapping(newField("g$a$a", "a", "I"), newField("deobf/G_OuterClass$A_InnerClass$A_InnerInnerClass", "f3", "I")); | ||
| 109 | assertMapping(newField("g$b$a", "a", "I"), newField("deobf/G_OuterClass$b$A_NamedInnerClass", "f4", "I")); | ||
| 110 | |||
| 111 | // methods | ||
| 112 | assertMapping(newMethod("g$a", "a", "()V"), newMethod("deobf/G_OuterClass$A_InnerClass", "m1", "()V")); | ||
| 113 | assertMapping(newMethod("g$a$a", "a", "()V"), newMethod("deobf/G_OuterClass$A_InnerClass$A_InnerInnerClass", "m2", "()V")); | ||
| 114 | } | ||
| 115 | |||
| 116 | @Test | ||
| 117 | public void namelessClass() { | ||
| 118 | assertMapping(newClass("h"), newClass("h")); | ||
| 119 | } | ||
| 120 | |||
| 121 | @Test | ||
| 122 | public void testGenerics() { | ||
| 123 | |||
| 124 | // classes | ||
| 125 | assertMapping(newClass("i"), newClass("deobf/I_Generics")); | ||
| 126 | assertMapping(newClass("i$a"), newClass("deobf/I_Generics$A_Type")); | ||
| 127 | assertMapping(newClass("i$b"), newClass("deobf/I_Generics$B_Generic")); | ||
| 128 | |||
| 129 | // fields | ||
| 130 | assertMapping(newField("i", "a", "Ljava/util/List;"), newField("deobf/I_Generics", "f1", "Ljava/util/List;")); | ||
| 131 | assertMapping(newField("i", "b", "Ljava/util/List;"), newField("deobf/I_Generics", "f2", "Ljava/util/List;")); | ||
| 132 | assertMapping(newField("i", "a", "Ljava/util/Map;"), newField("deobf/I_Generics", "f3", "Ljava/util/Map;")); | ||
| 133 | assertMapping(newField("i$b", "a", "Ljava/lang/Object;"), newField("deobf/I_Generics$B_Generic", "f4", "Ljava/lang/Object;")); | ||
| 134 | assertMapping(newField("i", "a", "Li$b;"), newField("deobf/I_Generics", "f5", "Ldeobf/I_Generics$B_Generic;")); | ||
| 135 | assertMapping(newField("i", "b", "Li$b;"), newField("deobf/I_Generics", "f6", "Ldeobf/I_Generics$B_Generic;")); | ||
| 136 | |||
| 137 | // methods | ||
| 138 | assertMapping(newMethod("i$b", "a", "()Ljava/lang/Object;"), newMethod("deobf/I_Generics$B_Generic", "m1", "()Ljava/lang/Object;")); | ||
| 139 | } | ||
| 140 | |||
| 141 | private void assertMapping(Entry<?> obf, Entry<?> deobf) { | ||
| 142 | //assertThat(deobfTranslator.translateEntry(obf), is(deobf)); | ||
| 143 | //assertThat(obfTranslator.translateEntry(deobf), is(obf)); | ||
| 144 | |||
| 145 | //String deobfName = deobfTranslator.translate(obf); | ||
| 146 | //if (deobfName != null) { | ||
| 147 | // assertThat(deobfName, is(deobf.getName())); | ||
| 148 | //} | ||
| 149 | |||
| 150 | //String obfName = obfTranslator.translate(deobf); | ||
| 151 | //if (obfName != null) { | ||
| 152 | // assertThat(obfName, is(obf.getName())); | ||
| 153 | //} | ||
| 154 | } | ||
| 155 | } | ||