示例#1
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"));
  }
示例#2
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
    }
  }