File tree Expand file tree Collapse file tree
android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu
base/src/main/java/com/smartdevicelink/managers/screen/menu Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -425,6 +425,27 @@ public void testAlgorithmTest5(){
425425 assertEquals (menuManager .keepsOld .size (), 3 );
426426 }
427427
428+ public void testSettingNullMenu (){
429+
430+ // Make sure we can send an empty menu with no issues
431+ // start fresh
432+ menuManager .oldMenuCells = null ;
433+ menuManager .menuCells = null ;
434+ menuManager .inProgressUpdate = null ;
435+ menuManager .waitingUpdateMenuCells = null ;
436+ menuManager .waitingOnHMIUpdate = false ;
437+
438+ menuManager .currentHMILevel = HMILevel .HMI_FULL ;
439+ // send new cells. They should set the old way
440+ List <MenuCell > oldMenu = createDynamicMenu1 ();
441+ List <MenuCell > newMenu = null ;
442+ menuManager .setMenuCells (oldMenu );
443+ assertEquals (menuManager .menuCells .size (), 4 );
444+
445+ menuManager .setMenuCells (newMenu );
446+ assertEquals (menuManager .menuCells .size (), 0 );
447+ }
448+
428449 public void testClearingMenu (){
429450
430451 // Make sure we can send an empty menu with no issues
Original file line number Diff line number Diff line change @@ -175,7 +175,10 @@ public void setMenuCells(@NonNull List<MenuCell> cells){
175175 if (currentHMILevel == null || currentHMILevel .equals (HMILevel .HMI_NONE ) || currentSystemContext .equals (SystemContext .SYSCTXT_MENU )){
176176 // We are in NONE or the menu is in use, bail out of here
177177 waitingOnHMIUpdate = true ;
178- waitingUpdateMenuCells = new ArrayList <>(clonedCells );
178+ waitingUpdateMenuCells = new ArrayList <>();
179+ if (clonedCells != null && !clonedCells .isEmpty ()) {
180+ waitingUpdateMenuCells .addAll (clonedCells );
181+ }
179182 return ;
180183 }
181184 waitingOnHMIUpdate = false ;
@@ -186,7 +189,10 @@ public void setMenuCells(@NonNull List<MenuCell> cells){
186189 oldMenuCells = new ArrayList <>(menuCells );
187190 }
188191 // copy new list
189- menuCells = new ArrayList <>(clonedCells );
192+ menuCells = new ArrayList <>();
193+ if (clonedCells != null && !clonedCells .isEmpty ()) {
194+ menuCells .addAll (clonedCells );
195+ }
190196
191197 // HashSet order doesnt matter / does not allow duplicates
192198 HashSet <String > titleCheckSet = new HashSet <>();
You can’t perform that action at this time.
0 commit comments