MockSuggestionService.java revision e4b5ac2f971b6697b41a5bc5d6e63770b4f0fcfe
1/*
2 * Copyright (C) 2017 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 android.service.settings.suggestions;
18
19import android.support.annotation.VisibleForTesting;
20
21import java.util.ArrayList;
22import java.util.List;
23
24public class MockSuggestionService extends SuggestionService {
25
26    @VisibleForTesting
27    static boolean sOnSuggestionLaunchedCalled;
28    @VisibleForTesting
29    static boolean sOnSuggestionDismissedCalled;
30
31    public static void reset() {
32        sOnSuggestionLaunchedCalled = false;
33        sOnSuggestionDismissedCalled = false;
34    }
35
36    @Override
37    public List<Suggestion> onGetSuggestions() {
38        final List<Suggestion> data = new ArrayList<>();
39
40        data.add(new Suggestion.Builder("test")
41                .setTitle("title")
42                .setSummary("summary")
43                .build());
44        return data;
45    }
46
47    @Override
48    public void onSuggestionDismissed(Suggestion suggestion) {
49        sOnSuggestionDismissedCalled = true;
50    }
51
52    @Override
53    public void onSuggestionLaunched(Suggestion suggestion) {
54        sOnSuggestionLaunchedCalled = true;
55    }
56}
57