aboutsummaryrefslogtreecommitdiff
path: root/sandbox/src/test/java/org/robolectric/NativeMethodInvocationTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/src/test/java/org/robolectric/NativeMethodInvocationTest.java')
-rw-r--r--sandbox/src/test/java/org/robolectric/NativeMethodInvocationTest.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/sandbox/src/test/java/org/robolectric/NativeMethodInvocationTest.java b/sandbox/src/test/java/org/robolectric/NativeMethodInvocationTest.java
new file mode 100644
index 000000000..2dcda2ae5
--- /dev/null
+++ b/sandbox/src/test/java/org/robolectric/NativeMethodInvocationTest.java
@@ -0,0 +1,33 @@
+package org.robolectric;
+
+import static org.junit.Assert.assertThrows;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.annotation.Implements;
+import org.robolectric.annotation.internal.Instrument;
+import org.robolectric.internal.SandboxTestRunner;
+import org.robolectric.internal.bytecode.SandboxConfig;
+
+/* Tests for native method instrumentation. */
+@RunWith(SandboxTestRunner.class)
+public class NativeMethodInvocationTest {
+ @SandboxConfig(shadows = ShadowClassWithNativeMethods.class)
+ @Test
+ public void callNativeMethodsByDefault_unsatisfiedLinkError() {
+ ClassWithNativeMethods classWithNativeMethods = new ClassWithNativeMethods();
+ assertThrows(UnsatisfiedLinkError.class, ClassWithNativeMethods::staticNativeMethod);
+ assertThrows(UnsatisfiedLinkError.class, classWithNativeMethods::instanceNativeMethod);
+ }
+
+ @Instrument
+ static class ClassWithNativeMethods {
+ static native void staticNativeMethod();
+
+ native void instanceNativeMethod();
+ }
+
+ /** Shadow for {@link NativeMethodInvocationTest.ClassWithNativeMethods} */
+ @Implements(value = ClassWithNativeMethods.class, callNativeMethodsByDefault = true)
+ public static class ShadowClassWithNativeMethods {}
+}