示例#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));
  }
示例#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"));
  }
示例#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
    }
  }
示例#4
0
文件: Util.java 项目: longzhou3/glide
 public static void setSdkVersionInt(int version) {
   Robolectric.Reflection.setFinalStaticField(Build.VERSION.class, "SDK_INT", version);
 }