Skip to content

Commit 14b7569

Browse files
committed
Review and standup feedback fixes
1 parent 666f99a commit 14b7569

2 files changed

Lines changed: 30 additions & 5 deletions

File tree

android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/SoftButtonManagerTests.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,31 @@ public void testAssignEmptyStateListToSoftButtonObject() {
455455
}
456456

457457
/**
458-
* Test assigning a nonempty state list to existing SoftButtonObject
458+
* Test assigning a state list with the current state to existing SoftButtonObject
459459
*/
460460
@Test
461-
public void testAssignNonEmptyStateListToSoftButtonObject() {
461+
public void testAssignStateListWithCurrentStateToSoftButtonObject() {
462+
List<SoftButtonState> stateList1 = new ArrayList<>();
463+
SoftButtonState softButtonState1 = new SoftButtonState("hello_there", "Hello there", null);
464+
stateList1.add(softButtonState1);
465+
466+
List<SoftButtonState> stateList2 = new ArrayList<>();
467+
SoftButtonState softButtonState2 = new SoftButtonState("general_kenobi", "General Kenobi", null);
468+
stateList2.add(softButtonState1);
469+
stateList2.add(softButtonState2);
470+
471+
SoftButtonObject softButtonObject = new SoftButtonObject("general_kenobi", stateList1, "hello_there", null);
472+
473+
softButtonObject.setStates(stateList2);
474+
475+
assertEquals(stateList2, softButtonObject.getStates());
476+
}
477+
478+
/**
479+
* Test assigning a state list without the current state to existing SoftButtonObject
480+
*/
481+
@Test
482+
public void testAssignStateListWithoutCurrentStateToSoftButtonObject() {
462483
List<SoftButtonState> stateList1 = new ArrayList<>();
463484
SoftButtonState softButtonState1 = new SoftButtonState("hello_there", "Hello there", null);
464485
stateList1.add(softButtonState1);

base/src/main/java/com/smartdevicelink/managers/screen/SoftButtonObject.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,16 +283,20 @@ public void setStates(@NonNull List<SoftButtonState> states) {
283283
return;
284284
}
285285

286+
if (states.isEmpty()) {
287+
DebugTool.logError(TAG, "A SoftButtonObject must contain at least one state");
288+
return;
289+
}
290+
286291
boolean hasStateWithCurrentName = false;
287292
for (SoftButtonState state : states) {
288293
if(state.getName().equals(currentStateName)) {
289-
hasStateWithCurrentNameName = true;
294+
hasStateWithCurrentName = true;
290295
break;
291296
}
292297
}
293298
if (!hasStateWithCurrentName) {
294-
DebugTool.logError(TAG, "A SoftButtonObject must have a state with currentStateName.");
295-
return;
299+
DebugTool.logError(TAG, "A SoftButtonObject should have a state with currentStateName.");
296300
}
297301

298302
this.states = states;

0 commit comments

Comments
 (0)