@Test public void testUpdateShortcut_dynamic() throws Exception { ShortcutInfo shortcut1 = createShortcut("id1"); when(shortcut1.getLongLabel()).thenReturn("original"); ShortcutInfo shortcutUpdated = createShortcut("id1"); when(shortcutUpdated.getLongLabel()).thenReturn("updated"); shortcutManager.addDynamicShortcuts( ImmutableList.of(shortcut1)); assertThat(shortcutManager.getDynamicShortcuts()).containsExactly(shortcut1); shortcutManager.updateShortcuts(ImmutableList.of(shortcutUpdated)); assertThat(shortcutManager.getDynamicShortcuts()).containsExactly(shortcutUpdated); }
@Test @Config(minSdk = Build.VERSION_CODES.O) public void testUpdateShortcut_pinned() throws Exception { ShortcutInfo shortcut1 = createShortcut("id1"); when(shortcut1.getLongLabel()).thenReturn("original"); ShortcutInfo shortcutUpdated = createShortcut("id1"); when(shortcutUpdated.getLongLabel()).thenReturn("updated"); shortcutManager.requestPinShortcut( shortcut1, null /* resultIntent */); assertThat(shortcutManager.getPinnedShortcuts()).containsExactly(shortcut1); shortcutManager.updateShortcuts(ImmutableList.of(shortcutUpdated)); assertThat(shortcutManager.getPinnedShortcuts()).containsExactly(shortcutUpdated); }
@Test public void testUpdateShortcutsOnlyUpdatesExistingShortcuts() throws Exception { ShortcutInfo shortcut1 = createShortcut("id1"); when(shortcut1.getLongLabel()).thenReturn("original"); ShortcutInfo shortcutUpdated = createShortcut("id1"); when(shortcutUpdated.getLongLabel()).thenReturn("updated"); ShortcutInfo shortcut2 = createShortcut("id2"); shortcutManager.addDynamicShortcuts(ImmutableList.of(shortcut1)); assertThat(shortcutManager.getDynamicShortcuts()).containsExactly(shortcut1); shortcutManager.updateShortcuts(ImmutableList.of(shortcutUpdated, shortcut2)); assertThat(shortcutManager.getDynamicShortcuts()).containsExactly(shortcutUpdated); assertThat(shortcutManager.getDynamicShortcuts().get(0).getLongLabel()).isEqualTo("updated"); }
ShortcutInfo thisRailShortcut = ShortcutsUtils.createRailShortcut(this, railNumber, nextIcon, nextRotation, r); shortcutManager.updateShortcuts(Collections.singletonList(thisRailShortcut)); shortcutManager.removeDynamicShortcuts(Collections.singletonList(id));