• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 com.android.settings.testutils.shadow;
18 
19 import static org.robolectric.RuntimeEnvironment.application;
20 
21 import android.content.pm.ShortcutInfo;
22 import android.content.pm.ShortcutManager;
23 import java.util.List;
24 import org.robolectric.annotation.Implementation;
25 import org.robolectric.annotation.Implements;
26 import org.robolectric.annotation.Resetter;
27 import org.robolectric.shadow.api.Shadow;
28 
29 @Implements(ShortcutManager.class)
30 public class ShadowShortcutManager extends org.robolectric.shadows.ShadowShortcutManager {
31 
32     private List<ShortcutInfo> mPinnedShortcuts;
33     private List<ShortcutInfo> mLastUpdatedShortcuts;
34 
35     @Resetter
reset()36     public void reset() {
37         mPinnedShortcuts = null;
38         mLastUpdatedShortcuts = null;
39     }
40 
get()41     public static ShadowShortcutManager get() {
42         return Shadow.extract(application.getSystemService(ShortcutManager.class));
43     }
44 
45     @Implementation
updateShortcuts(List<ShortcutInfo> shortcutInfoList)46     public boolean updateShortcuts(List<ShortcutInfo> shortcutInfoList) {
47         mLastUpdatedShortcuts = shortcutInfoList;
48         return true;
49     }
50 
getLastUpdatedShortcuts()51     public List<ShortcutInfo> getLastUpdatedShortcuts() {
52         return mLastUpdatedShortcuts;
53     }
54 
55     @Implementation
getPinnedShortcuts()56     public List<ShortcutInfo> getPinnedShortcuts() {
57         return mPinnedShortcuts;
58     }
59 
setPinnedShortcuts(List<ShortcutInfo> shortcutInfos)60     public void setPinnedShortcuts(List<ShortcutInfo> shortcutInfos) {
61         mPinnedShortcuts = shortcutInfos;
62     }
63 }
64