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