Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Review and standup feedback fixes
  • Loading branch information
noah-livio committed Jan 28, 2022
commit 14b7569d7892952d37ea6f6963e05ba57c996af1
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,31 @@ public void testAssignEmptyStateListToSoftButtonObject() {
}

/**
* Test assigning a nonempty state list to existing SoftButtonObject
* Test assigning a state list with the current state to existing SoftButtonObject
*/
@Test
public void testAssignNonEmptyStateListToSoftButtonObject() {
public void testAssignStateListWithCurrentStateToSoftButtonObject() {
List<SoftButtonState> stateList1 = new ArrayList<>();
SoftButtonState softButtonState1 = new SoftButtonState("hello_there", "Hello there", null);
stateList1.add(softButtonState1);

List<SoftButtonState> stateList2 = new ArrayList<>();
SoftButtonState softButtonState2 = new SoftButtonState("general_kenobi", "General Kenobi", null);
stateList2.add(softButtonState1);
stateList2.add(softButtonState2);

SoftButtonObject softButtonObject = new SoftButtonObject("general_kenobi", stateList1, "hello_there", null);

softButtonObject.setStates(stateList2);

assertEquals(stateList2, softButtonObject.getStates());
}

/**
* Test assigning a state list without the current state to existing SoftButtonObject
*/
@Test
public void testAssignStateListWithoutCurrentStateToSoftButtonObject() {
List<SoftButtonState> stateList1 = new ArrayList<>();
SoftButtonState softButtonState1 = new SoftButtonState("hello_there", "Hello there", null);
stateList1.add(softButtonState1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,16 +283,20 @@ public void setStates(@NonNull List<SoftButtonState> states) {
return;
}

if (states.isEmpty()) {
DebugTool.logError(TAG, "A SoftButtonObject must contain at least one state");
return;
}

boolean hasStateWithCurrentName = false;
for (SoftButtonState state : states) {
if(state.getName().equals(currentStateName)) {
hasStateWithCurrentNameName = true;
hasStateWithCurrentName = true;
break;
}
}
if (!hasStateWithCurrentName) {
DebugTool.logError(TAG, "A SoftButtonObject must have a state with currentStateName.");
return;
DebugTool.logError(TAG, "A SoftButtonObject should have a state with currentStateName.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DebugTool.logError(TAG, "A SoftButtonObject should have a state with currentStateName.");
DebugTool.logError(TAG, "A SoftButtonObject setting states must contain a state with currentStateName.");

Can you also include the name of currentStateName?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is an easy change

}

this.states = states;
Expand Down