@Test public void testConstraintsChanged_withConstraint() throws InterruptedException { when(mBatteryChargingTracker.getInitialState()).thenReturn(true); OneTimeWorkRequest work = new OneTimeWorkRequest.Builder(TestWorker.class) .setPeriodStartTime(System.currentTimeMillis(), TimeUnit.MILLISECONDS) .setConstraints(new Constraints.Builder() .setRequiresCharging(true) .build()) .build(); insertWork(work); final Intent constraintChanged = CommandHandler.createConstraintsChangedIntent(mContext); mSpyDispatcher.postOnMainThread( new SystemAlarmDispatcher.AddRunnable(mSpyDispatcher, constraintChanged, START_ID)); mLatch.await(TEST_TIMEOUT, TimeUnit.SECONDS); assertThat(mLatch.getCount(), is(0L)); }
void postOnMainThread(@NonNull Runnable runnable) { mMainHandler.post(runnable); }
SystemAlarmDispatcher implements ExecutionListener { void postOnMainThread(@NonNull Runnable runnable) { mMainHandler.post(runnable); } }
SystemAlarmDispatcher implements ExecutionListener { void postOnMainThread(@NonNull Runnable runnable) { mMainHandler.post(runnable); } SystemAlarmDispatcher(@NonNull Context context); @VisibleForTesting  SystemAlarmDispatcher(
            @NonNull Context context,
            @Nullable Processor processor,
            @Nullable WorkManagerImpl workManager); }
SystemAlarmDispatcher implements ExecutionListener { void postOnMainThread(@NonNull Runnable runnable) { mMainHandler.post(runnable); } SystemAlarmDispatcher(@NonNull Context context); @VisibleForTesting  SystemAlarmDispatcher(
            @NonNull Context context,
            @Nullable Processor processor,
            @Nullable WorkManagerImpl workManager); @Override void onExecuted(
            @NonNull String workSpecId,
            boolean isSuccessful,
            boolean needsReschedule); @MainThread boolean add(@NonNull final Intent intent, final int startId); }
SystemAlarmDispatcher implements ExecutionListener { void postOnMainThread(@NonNull Runnable runnable) { mMainHandler.post(runnable); } SystemAlarmDispatcher(@NonNull Context context); @VisibleForTesting  SystemAlarmDispatcher(
            @NonNull Context context,
            @Nullable Processor processor,
            @Nullable WorkManagerImpl workManager); @Override void onExecuted(
            @NonNull String workSpecId,
            boolean isSuccessful,
            boolean needsReschedule); @MainThread boolean add(@NonNull final Intent intent, final int startId);  }