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 package android.content.pm.cts.shortcut.backup.publisher3; 17 18 import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.assertWith; 19 import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.list; 20 import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.makePersistableBundle; 21 import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.set; 22 23 import android.content.Intent; 24 import android.content.pm.ShortcutInfo; 25 import android.content.pm.cts.shortcut.device.common.ShortcutManagerDeviceTestBase; 26 import android.graphics.BitmapFactory; 27 import android.graphics.drawable.Icon; 28 import android.test.suitebuilder.annotation.SmallTest; 29 30 @SmallTest 31 public class ShortcutManagerPreBackupTest extends ShortcutManagerDeviceTestBase { 32 public void testPreBackup() { 33 final Icon icon1 = Icon.createWithBitmap(BitmapFactory.decodeResource( 34 getContext().getResources(), R.drawable.black_16x64)); 35 final Icon icon3 = Icon.createWithResource(getContext(), R.drawable.black_64x16); 36 37 final ShortcutInfo s1 = new ShortcutInfo.Builder(getContext(), "s1") 38 .setShortLabel("shortlabel1") 39 .setLongLabel("longlabel1") 40 .setIcon(icon1) 41 .setDisabledMessage("disabledmessage1") 42 .setIntents(new Intent[]{new Intent("view").putExtra("k1", "v1")}) 43 .setExtras(makePersistableBundle("ek1", "ev1")) 44 .setCategories(set("cat1")) 45 .build(); 46 47 final ShortcutInfo s2 = new ShortcutInfo.Builder(getContext(), "s2") 48 .setShortLabel("shortlabel2") 49 .setIntents(new Intent[]{new Intent("main")}) 50 .build(); 51 52 final ShortcutInfo s3 = new ShortcutInfo.Builder(getContext(), "s3") 53 .setShortLabel("shortlabel2") 54 .setIcon(icon3) 55 .setIntents(new Intent[]{new Intent("main")}) 56 .build(); 57 58 assertTrue(getManager().setDynamicShortcuts(list(s1, s2, s3))); 59 60 assertWith(getManager().getDynamicShortcuts()) 61 .haveIds("s1", "s2", "s3") 62 .areAllNotPinned(); 63 64 assertWith(getManager().getManifestShortcuts()) 65 .haveIds("ms1", "ms2") 66 .areAllNotPinned(); 67 } 68 } 69