Search in sources :

Example 91 with ClassNode

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

the class TestConditions13 method test.

@Test
public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, containsOne("if (quality >= 10 && raw != 0) {"));
    assertThat(code, containsOne("System.out.println(\"OK\" + raw);"));
    assertThat(code, containsOne("qualityReading = false;"));
    assertThat(code, containsOne("} else if (raw == 0 || quality < 6 || !qualityReading) {"));
    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 92 with ClassNode

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

the class TestConditions15 method test.

@Test
public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, containsOne("\"1\".equals(name)"));
    assertThat(code, containsOne("\"30\".equals(name)"));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) IntegrationTest(jadx.tests.api.IntegrationTest) Test(org.junit.Test)

Example 93 with ClassNode

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

the class TestSyntheticInline method test.

@Test
public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, not(containsString("synthetic")));
    assertThat(code, not(containsString("access$")));
    assertThat(code, not(containsString("x0")));
    assertThat(code, containsString("f = v;"));
    //		assertThat(code, containsString("return f;"));
    //		assertThat(code, containsString("return func();"));
    // Temporary solution
    assertThat(code, containsString("return TestSyntheticInline$TestCls.this.f;"));
    assertThat(code, containsString("return TestSyntheticInline$TestCls.this.func();"));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) IntegrationTest(jadx.tests.api.IntegrationTest) Test(org.junit.Test)

Example 94 with ClassNode

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

the class TestAnonymousClass2 method test.

@Test
public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, not(containsString("synthetic")));
    assertThat(code, not(containsString("AnonymousClass_")));
    assertThat(code, containsString("f = 1;"));
    //		assertThat(code, containsString("f = i;"));
    assertThat(code, not(containsString("Inner obj = ;")));
    assertThat(code, containsString("Inner.this;"));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) IntegrationTest(jadx.tests.api.IntegrationTest) Test(org.junit.Test)

Example 95 with ClassNode

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

the class TestAnonymousClass3 method test.

@Test
public void test() {
    disableCompilation();
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, containsString(indent(4) + "public void run() {"));
    assertThat(code, containsString(indent(3) + "}.start();"));
//		assertThat(code, not(containsString("synthetic")));
//		assertThat(code, not(containsString("AnonymousClass_")));
//		assertThat(code, containsString("a = f--;"));
}
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