Search in sources :

Example 6 with ClassNode

use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.

the class TestSynchronized2 method test.

@Test
public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, containsString("private static synchronized boolean test(Object obj) {"));
    assertThat(code, containsString("obj.toString() != null;"));
// TODO
//		assertThat(code, containsString("return obj.toString() != null;"));
//		assertThat(code, not(containsString("synchronized (")));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) IntegrationTest(jadx.tests.api.IntegrationTest) Test(org.junit.Test)

Example 7 with ClassNode

use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.

the class TestFinally2 method test.

@Test
public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, containsOne("decode(inputStream);"));
// TODO
// assertThat(code, not(containsOne("result =")));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) IntegrationTest(jadx.tests.api.IntegrationTest) Test(org.junit.Test)

Example 8 with ClassNode

use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.

the class TestInlineInCatch method test.

@Test
public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, containsOne("File output = null;"));
    assertThat(code, containsOne("output = File.createTempFile(\"f\", \"a\", "));
    assertThat(code, containsOne("return 0;"));
    assertThat(code, containsOne("} catch (Exception e) {"));
    assertThat(code, containsOne("if (output != null) {"));
    assertThat(code, containsOne("output.delete();"));
    assertThat(code, containsOne("return 2;"));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) IntegrationTest(jadx.tests.api.IntegrationTest) Test(org.junit.Test)

Example 9 with ClassNode

use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.

the class TestNestedTryCatch method test.

@Test
public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, containsString("try {"));
    assertThat(code, containsString("Thread.sleep(1);"));
    assertThat(code, containsString("Thread.sleep(2);"));
    assertThat(code, containsString("} catch (InterruptedException e) {"));
    assertThat(code, containsString("} catch (Exception e2) {"));
    assertThat(code, not(containsString("return")));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) IntegrationTest(jadx.tests.api.IntegrationTest) Test(org.junit.Test)

Example 10 with ClassNode

use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.

the class TestTryCatch method test.

@Test
public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, containsString("try {"));
    assertThat(code, containsString("Thread.sleep(50);"));
    assertThat(code, containsString("} catch (InterruptedException e) {"));
    assertThat(code, not(containsString("return")));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) IntegrationTest(jadx.tests.api.IntegrationTest) Test(org.junit.Test)

Aggregations

ClassNode (jadx.core.dex.nodes.ClassNode)236 Test (org.junit.Test)201 IntegrationTest (jadx.tests.api.IntegrationTest)197 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)93 JadxMatchers.countString (jadx.tests.api.utils.JadxMatchers.countString)17 MethodNode (jadx.core.dex.nodes.MethodNode)12 FieldNode (jadx.core.dex.nodes.FieldNode)10 Matchers.containsString (org.hamcrest.Matchers.containsString)10 ConstClassNode (jadx.core.dex.instructions.ConstClassNode)7 InsnNode (jadx.core.dex.nodes.InsnNode)7 ClassInfo (jadx.core.dex.info.ClassInfo)6 IndexInsnNode (jadx.core.dex.instructions.IndexInsnNode)6 DexNode (jadx.core.dex.nodes.DexNode)5 InsnArg (jadx.core.dex.instructions.args.InsnArg)4 ConstructorInsn (jadx.core.dex.instructions.mods.ConstructorInsn)4 SmaliTest (jadx.tests.api.SmaliTest)4 ArrayList (java.util.ArrayList)4 FieldReplaceAttr (jadx.core.dex.attributes.nodes.FieldReplaceAttr)3 FieldInfo (jadx.core.dex.info.FieldInfo)3 MethodInfo (jadx.core.dex.info.MethodInfo)3