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
17package com.android.documentsui.testing;
18
19import com.android.documentsui.dirlist.DocumentsAdapter;
20import com.android.documentsui.dirlist.TestDocumentsAdapter;
21import com.android.documentsui.selection.SelectionManager;
22import com.android.documentsui.selection.SelectionManager.SelectionMode;
23import com.android.documentsui.selection.SelectionManager.SelectionPredicate;
24
25import java.util.Collections;
26import java.util.List;
27
28public 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