Code format & Organize imports

This commit is contained in:
Jindra Pet��k
2014-02-02 05:39:36 +01:00
parent 7b6d54bc68
commit e595437dc2
59 changed files with 2350 additions and 1509 deletions
@@ -21,7 +21,8 @@ import com.jpexs.decompiler.flash.abc.ABCOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import static org.testng.Assert.*;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import org.testng.annotations.Test;
/**
@@ -27,7 +27,9 @@ import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.List;
import static org.testng.Assert.*;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -45,14 +47,14 @@ public class ActionScript2AssemblerTest extends ActionStript2TestBase {
@Test
public void testModifiedConstantPools() {
String actionsString = "ConstantPool \"ok\"\n" +
"Jump loc001f\n" +
"loc000d:Push \"ok\" false\n" +
"SetVariable\n" +
"Jump loc002f\n" +
"loc001f:ConstantPool \"wrong\"\n" +
"Jump loc000d\n" +
"loc002f:";
String actionsString = "ConstantPool \"ok\"\n"
+ "Jump loc001f\n"
+ "loc000d:Push \"ok\" false\n"
+ "SetVariable\n"
+ "Jump loc002f\n"
+ "loc001f:ConstantPool \"wrong\"\n"
+ "Jump loc000d\n"
+ "loc002f:";
try {
List<Action> actions = ASMParser.parse(0, 0, true, actionsString, swf.version, false);
@@ -26,7 +26,8 @@ import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.List;
import static org.testng.Assert.*;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -44,33 +45,33 @@ public class ActionScript2DeobfuscatorTest extends ActionStript2TestBase {
@Test
public void testRemoveJumpsToTheNextAction() {
String actionsString = "ConstantPool \"a\" \"b\" \"c\"\n" +
"Push false register1\n" +
"StoreRegister 2\n" +
"Pop\n" +
"Push register2\n" +
"StoreRegister 0\n" +
"Push \"a\"\n" +
"StrictEquals\n" +
"If loc005a\n" +
"Push register0 \"b\"\n" +
"StrictEquals\n" +
"If loc0068\n" +
"Jump loc0048;\n" +
"loc0048:Push register0 \"c\"\n" +
"StrictEquals\n" +
"If loc0076\n" +
"Jump loc0084\n" +
"loc005a:Push 1\n" +
"Trace\n" +
"Jump loc0084\n" +
"loc0068:Push 2\n" +
"Trace\n" +
"Jump loc0084\n" +
"loc0076:Push 3\n" +
"Trace\n" +
"Jump loc0084\n" +
"loc0084:";
String actionsString = "ConstantPool \"a\" \"b\" \"c\"\n"
+ "Push false register1\n"
+ "StoreRegister 2\n"
+ "Pop\n"
+ "Push register2\n"
+ "StoreRegister 0\n"
+ "Push \"a\"\n"
+ "StrictEquals\n"
+ "If loc005a\n"
+ "Push register0 \"b\"\n"
+ "StrictEquals\n"
+ "If loc0068\n"
+ "Jump loc0048;\n"
+ "loc0048:Push register0 \"c\"\n"
+ "StrictEquals\n"
+ "If loc0076\n"
+ "Jump loc0084\n"
+ "loc005a:Push 1\n"
+ "Trace\n"
+ "Jump loc0084\n"
+ "loc0068:Push 2\n"
+ "Trace\n"
+ "Jump loc0084\n"
+ "loc0076:Push 3\n"
+ "Trace\n"
+ "Jump loc0084\n"
+ "loc0084:";
try {
List<Action> actions = ASMParser.parse(0, 0, true, actionsString, swf.version, false);
@@ -25,7 +25,9 @@ import com.jpexs.decompiler.flash.tags.Tag;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import static org.testng.Assert.*;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.fail;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -749,5 +751,5 @@ public class ActionScript2Test extends ActionStript2TestBase {
+ "unloadMovieNum(4);\r\n"
+ "updateAfterEvent();\r\n");
}
}
@@ -29,7 +29,10 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Stack;
import static org.testng.Assert.*;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -25,7 +25,7 @@ import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import static org.testng.Assert.*;
import static org.testng.Assert.fail;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -83,12 +83,12 @@ public class ExportTest {
public void testDecompileAS(File f) {
testDecompile(f, ExportMode.SOURCE);
}
@Test(dataProvider = "swfFiles")
public void testDecompilePcode(File f) {
testDecompile(f, ExportMode.PCODE);
}
public void testDecompile(File f, ExportMode exportMode) {
try {
SWF swf = new SWF(new FileInputStream(f), false);
@@ -107,7 +107,7 @@ public class ExportTest {
public AbortRetryIgnoreHandler getNewInstance() {
return this;
}
}, fdir.getAbsolutePath(), exportMode, false);
} catch (Exception ex) {
fail();
@@ -18,8 +18,13 @@ 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 java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import static org.testng.Assert.fail;
import org.testng.annotations.Test;
/**
@@ -20,7 +20,8 @@ import com.jpexs.decompiler.flash.types.RECT;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import static org.testng.Assert.*;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
/**
@@ -156,7 +157,7 @@ public class SWFStreamTest {
assertEquals(ff, sis.readFIXED8());
sis.close();
}
@Test
public void testRECT() throws IOException {
RECT rect;
@@ -60,23 +60,22 @@ public class AS2Generator {
doa = null;
continue;
}
String[] srcs = src.split("[\r\n]+");
String testName="frame"+frame+"_Test";
String pref="trace(\"";
for(String p:srcs){
if(p.trim().matches("trace\\(\"(.*)Test\"\\);")){
testName="frame"+frame+"_"+p.substring(pref.length(),p.length()-3/* "); */);
String testName = "frame" + frame + "_Test";
String pref = "trace(\"";
for (String p : srcs) {
if (p.trim().matches("trace\\(\"(.*)Test\"\\);")) {
testName = "frame" + frame + "_" + p.substring(pref.length(), p.length() - 3/* "); */);
}
}
s.append("@Test\r\npublic void ");
s.append(testName);
s.append("(){\r\ncompareSrc(");
s.append(frame);
s.append(",");
for (int i = 0; i < srcs.length; i++) {
String ss = srcs[i];
s.append("\"");
@@ -42,7 +42,7 @@ public class AS3Generator {
public static void main(String[] args) throws Exception {
Configuration.autoDeobfuscate.set(false);
SWF swf = new SWF(new BufferedInputStream(new FileInputStream("testdata/as3/as3.swf")),false);
SWF swf = new SWF(new BufferedInputStream(new FileInputStream("testdata/as3/as3.swf")), false);
DoABCDefineTag tag = null;
for (Tag t : swf.tags) {
if (t instanceof DoABCDefineTag) {
@@ -63,7 +63,7 @@ public class AS3Generator {
s.append(name);
s.append("\", ");
HilightedTextWriter src = new HilightedTextWriter(false);
abc.findBody(((TraitMethodGetterSetter) t).method_info).toString("", ExportMode.SOURCE, false, -1/*FIX?*/, classId, abc, null,abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, src, new ArrayList<String>(), abc.instance_info[classId].instance_traits);
abc.findBody(((TraitMethodGetterSetter) t).method_info).toString("", ExportMode.SOURCE, false, -1/*FIX?*/, classId, abc, null, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, src, new ArrayList<String>(), abc.instance_info[classId].instance_traits);
String[] srcs = src.toString().split("[\r\n]+");
for (int i = 0; i < srcs.length; i++) {
String ss = srcs[i];