1// 2// This file was generated by //third_party/jni_zero/jni_zero.py 3// 4package org.jni_zero; 5 6import org.jni_zero.CheckDiscard; 7import org.jni_zero.JniStaticTestMocker; 8import org.jni_zero.NativeLibraryLoadedStatus; 9import org.jni_zero.module_GEN_JNI; 10 11@CheckDiscard("crbug.com/993421") 12class SampleModuleJni implements SampleModule.Natives { 13 private static SampleModule.Natives testInstance; 14 15 public static final JniStaticTestMocker<SampleModule.Natives> TEST_HOOKS = 16 new JniStaticTestMocker<SampleModule.Natives>() { 17 @Override 18 public void setInstanceForTesting(SampleModule.Natives instance) { 19 if (!module_GEN_JNI.TESTING_ENABLED) { 20 throw new RuntimeException( 21 "Tried to set a JNI mock when mocks aren't enabled!"); 22 } 23 testInstance = instance; 24 } 25 }; 26 27 @Override 28 public boolean bar(int a) { 29 return (boolean) module_GEN_JNI.org_jni_1zero_SampleModule_bar(a); 30 } 31 32 @Override 33 public void foo() { 34 module_GEN_JNI.org_jni_1zero_SampleModule_foo(); 35 } 36 37 public static SampleModule.Natives get() { 38 if (module_GEN_JNI.TESTING_ENABLED) { 39 if (testInstance != null) { 40 return testInstance; 41 } 42 if (module_GEN_JNI.REQUIRE_MOCK) { 43 throw new UnsupportedOperationException( 44 "No mock found for the native implementation of SampleModule.Natives. " 45 + "The current configuration requires implementations be mocked."); 46 } 47 } 48 NativeLibraryLoadedStatus.checkLoaded(); 49 return new SampleModuleJni(); 50 } 51} 52