Home | History | Annotate | Download | only in test
      1 /*
      2  * Copyright 2018 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package androidx.work.test;
     18 
     19 import android.content.Context;
     20 import android.support.annotation.NonNull;
     21 import android.support.annotation.RestrictTo;
     22 
     23 import androidx.work.Configuration;
     24 import androidx.work.WorkManager;
     25 import androidx.work.impl.Scheduler;
     26 import androidx.work.impl.WorkManagerImpl;
     27 
     28 import java.util.List;
     29 
     30 /**
     31  * A concrete implementation of {@link WorkManager} which can be used for testing.
     32  * This implementation makes it easy to swap Schedulers.
     33  *
     34  * @hide
     35  */
     36 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
     37 abstract class TestWorkManagerImpl extends WorkManagerImpl implements TestDriver {
     38     TestWorkManagerImpl(
     39             @NonNull Context context,
     40             @NonNull Configuration configuration) {
     41 
     42         // Note: This implies that the call to ForceStopRunnable() actually does nothing.
     43         // This is okay when testing.
     44         super(context, configuration, true);
     45     }
     46 
     47     /**
     48      * @return The list of Schedulers used when testing.
     49      */
     50     @Override
     51     @NonNull
     52     public abstract List<Scheduler> getSchedulers();
     53 }
     54