summaryrefslogtreecommitdiff
path: root/startop/view_compiler/dex_builder_test
diff options
context:
space:
mode:
authorEric Holk <eholk@google.com>2018-12-13 11:35:58 -0800
committerEric Holk <eholk@google.com>2018-12-14 09:14:12 -0800
commitc69449d95c145365d192cf9d347674494bc8fa70 (patch)
tree2aed52610e6a258fe85c4943b1641d53cf1b2004 /startop/view_compiler/dex_builder_test
parent657d61220648e924b24973c62f984d8654f7bd1f (diff)
[view-compiler] DexBuilder: Add more instructions
This CL adds the ability to generate code that calls static and virtual methods which return objects, as well as the not-equal-to-zero comparison operator. Bug: 111895153 Change-Id: I4ae9b3cb2edc6540671112b73c02bf6380d23051
Diffstat (limited to 'startop/view_compiler/dex_builder_test')
-rw-r--r--startop/view_compiler/dex_builder_test/src/android/startop/test/DexBuilderTest.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/startop/view_compiler/dex_builder_test/src/android/startop/test/DexBuilderTest.java b/startop/view_compiler/dex_builder_test/src/android/startop/test/DexBuilderTest.java
index e20f3a9406c0..1508ad9ee56b 100644
--- a/startop/view_compiler/dex_builder_test/src/android/startop/test/DexBuilderTest.java
+++ b/startop/view_compiler/dex_builder_test/src/android/startop/test/DexBuilderTest.java
@@ -84,6 +84,15 @@ public class DexBuilderTest {
}
@Test
+ public void returnIfNotZero() throws Exception {
+ ClassLoader loader = loadDexFile("simple.dex");
+ Class clazz = loader.loadClass("android.startop.test.testcases.SimpleTests");
+ Method method = clazz.getMethod("returnIfNotZero", int.class);
+ Assert.assertEquals(3, method.invoke(null, 0));
+ Assert.assertEquals(5, method.invoke(null, 17));
+ }
+
+ @Test
public void backwardsBranch() throws Exception {
ClassLoader loader = loadDexFile("simple.dex");
Class clazz = loader.loadClass("android.startop.test.testcases.SimpleTests");
@@ -124,4 +133,22 @@ public class DexBuilderTest {
Assert.assertEquals("b", method.invoke(null, 0));
Assert.assertEquals("a", method.invoke(null, 1));
}
+
+ @Test
+ public void invokeStaticReturnObject() throws Exception {
+ ClassLoader loader = loadDexFile("simple.dex");
+ Class clazz = loader.loadClass("android.startop.test.testcases.SimpleTests");
+ Method method = clazz.getMethod("invokeStaticReturnObject", int.class, int.class);
+ Assert.assertEquals("10", method.invoke(null, 10, 10));
+ Assert.assertEquals("a", method.invoke(null, 10, 16));
+ Assert.assertEquals("5", method.invoke(null, 5, 16));
+ }
+
+ @Test
+ public void invokeVirtualReturnObject() throws Exception {
+ ClassLoader loader = loadDexFile("simple.dex");
+ Class clazz = loader.loadClass("android.startop.test.testcases.SimpleTests");
+ Method method = clazz.getMethod("invokeVirtualReturnObject", String.class, int.class);
+ Assert.assertEquals("bc", method.invoke(null, "abc", 1));
+ }
}