tests fixed

This commit is contained in:
Honfika
2013-11-07 23:05:15 +01:00
parent 43ab7dbc55
commit 50df6db4f8
9 changed files with 35 additions and 14 deletions

View File

@@ -96,7 +96,7 @@ public class Graph {
}
} catch (InterruptedException ex) {
throw ex;
} catch (Error ex) {
} catch (Exception | Error ex) {
String s = ex.toString();
//ignore
}

View File

@@ -3,12 +3,15 @@ package com.jpexs.decompiler.flash;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.DoActionTag;
import com.jpexs.decompiler.graph.ExportMode;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import static org.testng.Assert.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -21,7 +24,7 @@ public class ActionScript2AssemblerTest extends ActionStript2TestBase {
@BeforeClass
public void init() throws IOException {
Configuration.setConfig("autoDeobfuscate", false);
Configuration.autoDeobfuscate.set(false);
swf = new SWF(new FileInputStream("testdata/as2/as2.swf"), false);
}
@@ -49,7 +52,7 @@ public class ActionScript2AssemblerTest extends ActionStript2TestBase {
assertEquals(actualResult.trim(), "ok = false;");
assertTrue(decompiled.contains("Push \"ok\" false"));
} catch (IOException | ParseException ex) {
} catch (IOException | ParseException | InterruptedException ex) {
fail();
}
}

View File

@@ -19,11 +19,14 @@ package com.jpexs.decompiler.flash;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.DoActionTag;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import static org.testng.Assert.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -36,7 +39,7 @@ public class ActionScript2DeobfuscatorTest extends ActionStript2TestBase {
@BeforeClass
public void init() throws IOException {
Configuration.setConfig("autoDeobfuscate", true);
Configuration.autoDeobfuscate.set(true);
swf = new SWF(new FileInputStream("testdata/as2/as2.swf"), false);
}
@@ -79,7 +82,7 @@ public class ActionScript2DeobfuscatorTest extends ActionStript2TestBase {
String actualResult = writer.toString();
assertTrue(actualResult.contains("case \"c\":"));
} catch (IOException | ParseException ex) {
} catch (IOException | ParseException | InterruptedException ex) {
fail();
}
}

View File

@@ -17,12 +17,15 @@
package com.jpexs.decompiler.flash;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.DoActionTag;
import com.jpexs.decompiler.flash.tags.ShowFrameTag;
import com.jpexs.decompiler.flash.tags.Tag;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import static org.testng.Assert.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -35,7 +38,7 @@ public class ActionScript2Test extends ActionStript2TestBase {
@BeforeClass
public void init() throws IOException {
Configuration.setConfig("autoDeobfuscate", false);
Configuration.autoDeobfuscate.set(false);
swf = new SWF(new FileInputStream("testdata/as2/as2.swf"), false);
}
@@ -43,7 +46,11 @@ public class ActionScript2Test extends ActionStript2TestBase {
DoActionTag doa = getFrameSource(frame);
assertNotNull(doa);
HilightedTextWriter writer = new HilightedTextWriter(false);
Action.actionsToSource(doa, doa.getActions(swf.version), swf.version, "", writer);
try {
Action.actionsToSource(doa, doa.getActions(swf.version), swf.version, "", writer);
} catch (InterruptedException ex) {
fail();
}
String actualResult = writer.toString().replaceAll("[ \r\n]", "");
expectedResult = expectedResult.replaceAll("[ \r\n]", "");
assertEquals(actualResult, expectedResult);

View File

@@ -1,6 +1,7 @@
package com.jpexs.decompiler.flash;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.DoABCDefineTag;
import com.jpexs.decompiler.flash.tags.Tag;
@@ -38,13 +39,18 @@ public class ActionScript3Test {
clsIndex = tag.getABC().findClassByName("classes.Test");
assertTrue(clsIndex > -1);
this.abc = tag.getABC();
Configuration.setConfig("autoDeobfuscate", false);
Configuration.autoDeobfuscate.set(false);
}
private void decompileMethod(String methodName, String expectedResult, boolean isStatic) {
int bodyIndex = abc.findMethodBodyByName(clsIndex, methodName);
assertTrue(bodyIndex > -1);
HilightedTextWriter writer = abc.bodies[bodyIndex].toString(methodName, ExportMode.SOURCE, isStatic, -1/*FIX?*/, clsIndex, abc,null, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, new ArrayList<String>(), abc.instance_info[clsIndex].instance_traits);
HilightedTextWriter writer = null;
try {
writer = abc.bodies[bodyIndex].toString(methodName, ExportMode.SOURCE, isStatic, -1/*FIX?*/, clsIndex, abc,null, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, new ArrayList<String>(), abc.instance_info[clsIndex].instance_traits);
} catch (InterruptedException ex) {
fail();
}
String actualResult = writer.toString().replaceAll("[ \r\n]", "");
expectedResult = expectedResult.replaceAll("[ \r\n]", "");
assertEquals(actualResult, expectedResult);

View File

@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.graph.ExportMode;
import java.io.File;
import java.io.FileInputStream;
@@ -39,7 +40,7 @@ public class ExportTest {
@BeforeClass
public void addLogger() {
Configuration.setConfig("autoDeobfuscate", true);
Configuration.autoDeobfuscate.set(true);
Logger logger = Logger.getLogger("");
logger.addHandler(new Handler() {
@Override

View File

@@ -1,6 +1,7 @@
package com.jpexs.decompiler.flash;
import com.jpexs.decompiler.flash.abc.NotSameException;
import com.jpexs.decompiler.flash.configuration.Configuration;
import java.io.*;
import static org.testng.Assert.*;
import org.testng.annotations.Test;

View File

@@ -1,8 +1,8 @@
package com.jpexs.decompiler.flash.generators;
import com.jpexs.decompiler.flash.Configuration;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.DoABCDefineTag;
import com.jpexs.decompiler.flash.tags.DoActionTag;
@@ -20,7 +20,7 @@ import java.io.FileOutputStream;
public class AS2Generator {
public static void main(String[] args) throws Exception {
Configuration.setConfig("autoDeobfuscate", false);
Configuration.autoDeobfuscate.set(false);
SWF swf = new SWF(new FileInputStream("testdata/as2/as2.swf"), false);
DoABCDefineTag tag = null;
DoActionTag doa = null;

View File

@@ -1,10 +1,10 @@
package com.jpexs.decompiler.flash.generators;
import com.jpexs.decompiler.flash.Configuration;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.DoABCDefineTag;
import com.jpexs.decompiler.flash.tags.Tag;
@@ -24,7 +24,7 @@ import java.util.Stack;
public class AS3Generator {
public static void main(String[] args) throws Exception {
Configuration.setConfig("autoDeobfuscate", false);
Configuration.autoDeobfuscate.set(false);
SWF swf = new SWF(new FileInputStream("testdata/as3/as3.swf"),false);
DoABCDefineTag tag = null;
for (Tag t : swf.tags) {