Home | History | Annotate | Download | only in testing
      1 /*
      2  * Copyright (C) 2016 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 com.android.documentsui.testing;
     18 
     19 import com.android.documentsui.dirlist.DocumentsAdapter;
     20 import com.android.documentsui.dirlist.TestDocumentsAdapter;
     21 import com.android.documentsui.selection.SelectionManager;
     22 import com.android.documentsui.selection.SelectionManager.SelectionMode;
     23 import com.android.documentsui.selection.SelectionManager.SelectionPredicate;
     24 
     25 import java.util.Collections;
     26 import java.util.List;
     27 
     28 public class SelectionManagers {
     29     private SelectionManagers() {}
     30 
     31     public static SelectionManager createTestInstance() {
     32         return createTestInstance(Collections.emptyList());
     33     }
     34 
     35     public static SelectionManager createTestInstance(List<String> docs) {
     36         return createTestInstance(docs, SelectionManager.MODE_MULTIPLE);
     37     }
     38 
     39     public static SelectionManager createTestInstance(
     40             List<String> docs, @SelectionMode int mode) {
     41         return createTestInstance(
     42                 new TestDocumentsAdapter(docs),
     43                 mode,
     44                 (String id, boolean nextState) -> true);
     45     }
     46 
     47     public static SelectionManager createTestInstance(
     48             DocumentsAdapter adapter, @SelectionMode int mode, SelectionPredicate canSetState) {
     49         SelectionManager manager = new SelectionManager(mode);
     50         manager.reset(adapter, canSetState);
     51 
     52         return manager;
     53     }
     54 }
     55