Ejemplo n.º 1
0
  @Test
  public void safeExecutorOnExecutor_beforeICS_withNullParam_shouldCallExecute() throws Exception {
    Robolectric.Reflection.setFinalStaticField(
        Build.VERSION.class, "SDK_INT", HONEYCOMB_MR2.getApiLevel());

    AsyncTasks.safeExecuteOnExecutor(asyncTask, (String) null);

    verify(asyncTask).execute(eq((String) null));
  }
Ejemplo n.º 2
0
  @Test
  public void safeExecuteOnExecutor_atLeastICS_shouldCallExecuteWithParamsWithExecutor()
      throws Exception {
    Robolectric.Reflection.setFinalStaticField(
        Build.VERSION.class, "SDK_INT", ICE_CREAM_SANDWICH.getApiLevel());

    AsyncTasks.safeExecuteOnExecutor(asyncTask, "goodbye");

    verify(asyncTask).executeOnExecutor(eq(THREAD_POOL_EXECUTOR), eq("goodbye"));
  }
Ejemplo n.º 3
0
  @Test
  public void
      safeExecutorOnExecutor_atLeastICS_withNullAsyncTask_shouldThrowIllegalArgumentException()
          throws Exception {
    Robolectric.Reflection.setFinalStaticField(
        Build.VERSION.class, "SDK_INT", ICE_CREAM_SANDWICH.getApiLevel());

    try {
      AsyncTasks.safeExecuteOnExecutor(null, "hello");
      fail("Should have thrown IllegalArgumentException");
    } catch (IllegalArgumentException exception) {
      // pass
    }
  }
Ejemplo n.º 4
0
 public static void setSdkVersionInt(int version) {
   Robolectric.Reflection.setFinalStaticField(Build.VERSION.class, "SDK_INT", version);
 }