1 package org.robolectric.nativeruntime; 2 3 import static com.google.common.truth.Truth.assertThat; 4 import static org.robolectric.annotation.Config.ALL_SDKS; 5 6 import android.app.Application; 7 import android.database.CursorWindow; 8 import org.junit.Test; 9 import org.junit.runner.RunWith; 10 import org.robolectric.RobolectricTestRunner; 11 import org.robolectric.RuntimeEnvironment; 12 import org.robolectric.annotation.Config; 13 14 @RunWith(RobolectricTestRunner.class) 15 @Config(sdk = ALL_SDKS) 16 public final class DefaultNativeRuntimeLazyLoadTest { 17 18 /** 19 * Checks to see that RNR is not loaded by default when an empty application is created. RNR load 20 * times are typically 0.5-1s, so it is desirable to have it lazy loaded when native code is 21 * called. 22 */ 23 @SuppressWarnings("UnusedVariable") 24 @Test lazyLoad()25 public void lazyLoad() throws Exception { 26 Application application = RuntimeEnvironment.getApplication(); 27 assertThat(DefaultNativeRuntimeLoader.isLoaded()).isFalse(); 28 CursorWindow cursorWindow = new CursorWindow("hi"); 29 cursorWindow.close(); 30 assertThat(DefaultNativeRuntimeLoader.isLoaded()).isTrue(); 31 } 32 } 33