@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")); }
@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 } }