Search in sources :

Example 11 with ClassNode

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

the class TestTryCatch2 method test.

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

Example 12 with ClassNode

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

the class TestIfInLoop2 method test.

@Test
public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, not(containsString("for (int at = 0; at < len; at = endAt) {")));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) IntegrationTest(jadx.tests.api.IntegrationTest) Test(org.junit.Test)

Example 13 with ClassNode

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

the class TestIndexForLoop method test.

@Test
public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, containsLines(2, "int sum = 0;", "for (int i = 0; i < b; i++) {", indent(1) + "sum += a[i];", "}", "return sum;"));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) IntegrationTest(jadx.tests.api.IntegrationTest) Test(org.junit.Test)

Example 14 with ClassNode

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

the class TestIterableForEach method test.

@Test
public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, containsLines(2, "StringBuilder sb = new StringBuilder();", "for (String s : a) {", indent(1) + "sb.append(s);", "}", "return sb.toString();"));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) IntegrationTest(jadx.tests.api.IntegrationTest) Test(org.junit.Test)

Example 15 with ClassNode

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

the class TestIterableForEach3 method test.

@Test
public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, containsOne("for (T s : set) {"));
    assertThat(code, containsOne("if (str.length() == 0) {"));
// TODO move return outside 'if'
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) 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