aboutsummaryrefslogtreecommitdiff
path: root/nativeruntime/src/test/java/org/robolectric/nativeruntime/DefaultNativeRuntimeLazyLoadTest.java
blob: 5fa5ad3646898f1671444ada9e13e0a5926b5e15 (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
package org.robolectric.nativeruntime;

import static com.google.common.truth.Truth.assertThat;
import static org.robolectric.annotation.Config.ALL_SDKS;

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;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = ALL_SDKS)
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.
   */
  @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();
  }
}