Skip to content

Commit 37b307f

Browse files
committed
Merge branch 'develop' into bugfix/issue_1781
2 parents 73eab78 + b51cda0 commit 37b307f

64 files changed

Lines changed: 494 additions & 310 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public void setUp() throws Exception {
6868
public Void answer(InvocationOnMock invocation) {
6969
Object[] args = invocation.getArguments();
7070
OnPermissionChangeListener onPermissionChangeListener = (OnPermissionChangeListener) args[2];
71-
Map<FunctionID, PermissionStatus > allowedPermissions = new HashMap<>();
71+
Map<FunctionID, PermissionStatus> allowedPermissions = new HashMap<>();
7272
int permissionGroupStatus = PermissionManager.PERMISSION_GROUP_STATUS_DISALLOWED;
73-
onPermissionChangeListener.onPermissionsChange(allowedPermissions,permissionGroupStatus);
73+
onPermissionChangeListener.onPermissionsChange(allowedPermissions, permissionGroupStatus);
7474
return null;
7575
}
7676
};

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ public void testPresentAlertTruncatedText() {
194194

195195
windowCapability = getWindowCapability(2);
196196

197-
presentAlertOperation = new PresentAlertOperation(internalInterface, alertView, windowCapability, speechCapabilities, fileManager, 1, alertCompletionListener, alertSoftButtonClearListener);
197+
presentAlertOperation = new PresentAlertOperation(internalInterface, alertView, windowCapability, speechCapabilities, fileManager, 1, alertCompletionListener, alertSoftButtonClearListener);
198198
alert = presentAlertOperation.alertRpc();
199199
assertEquals(alert.getAlertText1(), alertView.getText());
200-
assertEquals(alert.getAlertText2(),alertView.getSecondaryText() + " - " + alertView.getTertiaryText());
200+
assertEquals(alert.getAlertText2(), alertView.getSecondaryText() + " - " + alertView.getTertiaryText());
201201
}
202202

203203
@Test

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

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -209,22 +209,19 @@ public void testSettingSoftButtonId() {
209209
SoftButtonObject softButtonObject3 = new SoftButtonObject("object1", Arrays.asList(softButtonState1, softButtonState2), softButtonState1.getName(), null);
210210
SoftButtonObject softButtonObject4 = new SoftButtonObject("object2", Arrays.asList(softButtonState3, softButtonState4), softButtonState3.getName(), null);
211211
assertTrue(screenManager.checkAndAssignButtonIds(softButtonObjects, BaseScreenManager.ManagerLocation.SOFTBUTTON_MANAGER));
212-
213-
214-
215-
216-
217212
}
213+
218214
@Test
219215
public void testAssigningIdsToSoftButtonObjects() {
216+
SoftButtonState defaultState = new SoftButtonState("default", "hi", null);
220217
SoftButtonObject sbo1, sbo2, sbo3, sbo4, sbo5;
221218

222219
// Case 1 - don't set id for any button (Manager should set ids automatically starting from 1 and up)
223-
sbo1 = new SoftButtonObject(null, Collections.EMPTY_LIST, null, null);
224-
sbo2 = new SoftButtonObject(null, Collections.EMPTY_LIST, null, null);
225-
sbo3 = new SoftButtonObject(null, Collections.EMPTY_LIST, null, null);
226-
sbo4 = new SoftButtonObject(null, Collections.EMPTY_LIST, null, null);
227-
sbo5 = new SoftButtonObject(null, Collections.EMPTY_LIST, null, null);
220+
sbo1 = new SoftButtonObject(null, defaultState, null);
221+
sbo2 = new SoftButtonObject(null, defaultState, null);
222+
sbo3 = new SoftButtonObject(null, defaultState, null);
223+
sbo4 = new SoftButtonObject(null, defaultState, null);
224+
sbo5 = new SoftButtonObject(null, defaultState, null);
228225
screenManager.checkAndAssignButtonIds(Arrays.asList(sbo1, sbo2, sbo3, sbo4, sbo5), BaseScreenManager.ManagerLocation.SOFTBUTTON_MANAGER);
229226
assertEquals("SoftButtonObject id doesn't match the expected value", 1, sbo1.getButtonId());
230227
assertEquals("SoftButtonObject id doesn't match the expected value", 2, sbo2.getButtonId());
@@ -234,15 +231,15 @@ public void testAssigningIdsToSoftButtonObjects() {
234231

235232

236233
// Case 2 - Set ids for all buttons (Manager shouldn't alter the ids set by developer)
237-
sbo1 = new SoftButtonObject(null, Collections.EMPTY_LIST, null, null);
234+
sbo1 = new SoftButtonObject(null, defaultState, null);
238235
sbo1.setButtonId(100);
239-
sbo2 = new SoftButtonObject(null, Collections.EMPTY_LIST, null, null);
236+
sbo2 = new SoftButtonObject(null, defaultState, null);
240237
sbo2.setButtonId(200);
241-
sbo3 = new SoftButtonObject(null, Collections.EMPTY_LIST, null, null);
238+
sbo3 = new SoftButtonObject(null, defaultState, null);
242239
sbo3.setButtonId(300);
243-
sbo4 = new SoftButtonObject(null, Collections.EMPTY_LIST, null, null);
240+
sbo4 = new SoftButtonObject(null, defaultState, null);
244241
sbo4.setButtonId(400);
245-
sbo5 = new SoftButtonObject(null, Collections.EMPTY_LIST, null, null);
242+
sbo5 = new SoftButtonObject(null, defaultState, null);
246243
sbo5.setButtonId(500);
247244
screenManager.checkAndAssignButtonIds(Arrays.asList(sbo1, sbo2, sbo3, sbo4, sbo5), BaseScreenManager.ManagerLocation.SOFTBUTTON_MANAGER);
248245
assertEquals("SoftButtonObject id doesn't match the expected value", 100, sbo1.getButtonId());
@@ -253,13 +250,13 @@ public void testAssigningIdsToSoftButtonObjects() {
253250

254251

255252
// Case 3 - Set ids for some buttons (Manager shouldn't alter the ids set by developer. And it should assign ids for the ones that don't have id)
256-
sbo1 = new SoftButtonObject(null, Collections.EMPTY_LIST, null, null);
253+
sbo1 = new SoftButtonObject(null, defaultState, null);
257254
sbo1.setButtonId(50);
258-
sbo2 = new SoftButtonObject(null, Collections.EMPTY_LIST, null, null);
259-
sbo3 = new SoftButtonObject(null, Collections.EMPTY_LIST, null, null);
260-
sbo4 = new SoftButtonObject(null, Collections.EMPTY_LIST, null, null);
255+
sbo2 = new SoftButtonObject(null, defaultState, null);
256+
sbo3 = new SoftButtonObject(null, defaultState, null);
257+
sbo4 = new SoftButtonObject(null, defaultState, null);
261258
sbo4.setButtonId(100);
262-
sbo5 = new SoftButtonObject(null, Collections.EMPTY_LIST, null, null);
259+
sbo5 = new SoftButtonObject(null, defaultState, null);
263260
screenManager.checkAndAssignButtonIds(Arrays.asList(sbo1, sbo2, sbo3, sbo4, sbo5), BaseScreenManager.ManagerLocation.SOFTBUTTON_MANAGER);
264261
assertEquals("SoftButtonObject id doesn't match the expected value", 50, sbo1.getButtonId());
265262
assertEquals("SoftButtonObject id doesn't match the expected value", 101, sbo2.getButtonId());

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

Lines changed: 118 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import java.util.Collections;
4545
import java.util.List;
4646

47+
4748
import static junit.framework.TestCase.assertEquals;
4849
import static junit.framework.TestCase.assertFalse;
4950
import static junit.framework.TestCase.assertNull;
@@ -350,8 +351,8 @@ public void onEvent(SoftButtonObject softButtonObject, OnButtonEvent onButtonEve
350351
softButtonStateList.add(softButtonState1);
351352
softButtonStateList2.add(softButtonState1);
352353
softButtonStateList2.add(softButtonState2);
353-
softButtonObject1 = new SoftButtonObject("hi", softButtonStateList, "Hi", null);
354-
softButtonObject2 = new SoftButtonObject("hi", softButtonStateList2, "Hi", null);
354+
softButtonObject1 = new SoftButtonObject("hi", softButtonStateList, softButtonStateList.get(0).getName(), null);
355+
softButtonObject2 = new SoftButtonObject("hi", softButtonStateList2, softButtonStateList2.get(0).getName(), null);
355356
assertNotEquals(softButtonObject1, softButtonObject2);
356357

357358
// Case 5: SoftButtonStates are not the same, assertFalse
@@ -365,8 +366,8 @@ public void onEvent(SoftButtonObject softButtonObject, OnButtonEvent onButtonEve
365366
assertNotEquals(softButtonObject1, softButtonObject2);
366367

367368
// Case 7: SoftButtonObject currentStateName not same, assertFalse
368-
softButtonObject1 = new SoftButtonObject("hi", softButtonStateList, "Hi", null);
369-
softButtonObject2 = new SoftButtonObject("hi", softButtonStateList, "Hi2", null);
369+
softButtonObject1 = new SoftButtonObject("hi", softButtonStateList2, softButtonStateList2.get(0).getName(), null);
370+
softButtonObject2 = new SoftButtonObject("hi", softButtonStateList2, softButtonStateList2.get(1).getName(), null);
370371
assertNotEquals(softButtonObject1, softButtonObject2);
371372
}
372373

@@ -402,4 +403,117 @@ public void testSoftButtonStateEquals() {
402403
softButtonState2 = new SoftButtonState("object1-state1", "o1s1", artwork1);
403404
assertEquals(softButtonState1, softButtonState2);
404405
}
406+
407+
/**
408+
* Test constructing SoftButtonObject with an empty state list
409+
*/
410+
@Test
411+
public void testConstructSoftButtonObjectWithEmptyStateList() {
412+
List<SoftButtonState> stateList = new ArrayList<>();
413+
SoftButtonObject softButtonObject = new SoftButtonObject("hello_there", stateList, "general_kenobi", null);
414+
assertNull(softButtonObject.getStates());
415+
}
416+
417+
/**
418+
* Test constructing SoftButtonObject with an nonempty state list
419+
*/
420+
@Test
421+
public void testConstructSoftButtonObjectWithNonEmptyStateList() {
422+
List<SoftButtonState> stateList = new ArrayList<>();
423+
SoftButtonState softButtonState = new SoftButtonState("general_kenobi", "General Kenobi", null);
424+
stateList.add(softButtonState);
425+
SoftButtonObject softButtonObject = new SoftButtonObject("hello_there", stateList, "general_kenobi", null);
426+
assertEquals(stateList, softButtonObject.getStates());
427+
}
428+
429+
/**
430+
* Test constructing SoftButtonObject with an invalid initialStateName
431+
*/
432+
@Test
433+
public void testConstructSoftButtonObjectWithInvalidInitialStateName() {
434+
List<SoftButtonState> stateList = new ArrayList<>();
435+
SoftButtonState softButtonState = new SoftButtonState("general_kenobi", "General Kenobi", null);
436+
stateList.add(softButtonState);
437+
SoftButtonObject softButtonObject = new SoftButtonObject("hello_there", stateList, "hello_there", null);
438+
assertNull(softButtonObject.getStates());
439+
}
440+
441+
/**
442+
* Test assigning an empty state list to existing SoftButtonObject
443+
*/
444+
@Test
445+
public void testAssignEmptyStateListToSoftButtonObject() {
446+
List<SoftButtonState> nonEmptyStateList = new ArrayList<>();
447+
List<SoftButtonState> emptyStateList = new ArrayList<>();
448+
SoftButtonState softButtonState = new SoftButtonState("general_kenobi", "General Kenobi", null);
449+
nonEmptyStateList.add(softButtonState);
450+
451+
SoftButtonObject softButtonObject = new SoftButtonObject("hello_there", nonEmptyStateList, "general_kenobi", null);
452+
453+
softButtonObject.setStates(emptyStateList);
454+
assertEquals(nonEmptyStateList, softButtonObject.getStates());
455+
}
456+
457+
/**
458+
* Test assigning a state list with the current state to existing SoftButtonObject
459+
*/
460+
@Test
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() {
483+
List<SoftButtonState> stateList1 = new ArrayList<>();
484+
SoftButtonState softButtonState1 = new SoftButtonState("hello_there", "Hello there", null);
485+
stateList1.add(softButtonState1);
486+
487+
List<SoftButtonState> stateList2 = new ArrayList<>();
488+
SoftButtonState softButtonState2 = new SoftButtonState("general_kenobi", "General Kenobi", null);
489+
stateList2.add(softButtonState2);
490+
491+
SoftButtonObject softButtonObject = new SoftButtonObject("general_kenobi", stateList1, "hello_there", null);
492+
493+
softButtonObject.setStates(stateList2);
494+
495+
assertEquals(stateList2, softButtonObject.getStates());
496+
}
497+
498+
/**
499+
* Test assigning a state list with states that have the same name to existing SoftButtonObject
500+
*/
501+
@Test
502+
public void testAssignSameNameStateListToSoftButtonObject() {
503+
List<SoftButtonState> stateListUnique = new ArrayList<>();
504+
SoftButtonState softButtonState1 = new SoftButtonState("hello_there", "Hello there", null);
505+
stateListUnique.add(softButtonState1);
506+
507+
List<SoftButtonState> stateListDuplicateNames = new ArrayList<>();
508+
SoftButtonState softButtonState2 = new SoftButtonState("general_kenobi", "General Kenobi", null);
509+
stateListDuplicateNames.add(softButtonState2);
510+
SoftButtonState softButtonState3 = new SoftButtonState("general_kenobi", "General Kenobi Again", null);
511+
stateListDuplicateNames.add(softButtonState3);
512+
513+
SoftButtonObject softButtonObject = new SoftButtonObject("general_kenobi", stateListUnique, "hello_there", null);
514+
515+
softButtonObject.setStates(stateListDuplicateNames);
516+
517+
assertEquals(stateListUnique, softButtonObject.getStates());
518+
}
405519
}

android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManagerTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,15 @@ public void testDefaultWindowCapabilityNotSet() throws NoSuchFieldException, Ill
279279
newCSM.setKeyboardConfiguration(newCSM.defaultKeyboardConfiguration());
280280
Field field = BaseChoiceSetManager.class.getDeclaredField("keyboardConfiguration");
281281
field.setAccessible(true);
282-
KeyboardProperties properties = (KeyboardProperties)field.get(newCSM);
282+
KeyboardProperties properties = (KeyboardProperties) field.get(newCSM);
283283
assertEquals(properties, csm.defaultKeyboardConfiguration());
284284

285285
// Test presentKeyboard
286286
newCSM = new ChoiceSetManager(internalInterface, fileManager);
287287
newCSM.presentKeyboard("qwerty", newCSM.defaultKeyboardConfiguration(), null);
288288
field = BaseChoiceSetManager.class.getDeclaredField("keyboardConfiguration");
289289
field.setAccessible(true);
290-
properties = (KeyboardProperties)field.get(newCSM);
290+
properties = (KeyboardProperties) field.get(newCSM);
291291
assertEquals(properties, csm.defaultKeyboardConfiguration());
292292
}
293293

@@ -314,7 +314,7 @@ public void testDefaultWindowCapabilityTooManyKeys() throws NoSuchFieldException
314314
Field field = BaseChoiceSetManager.class.getDeclaredField("keyboardConfiguration");
315315
field.setAccessible(true);
316316

317-
KeyboardProperties getProperties = (KeyboardProperties)field.get(newCSM);
317+
KeyboardProperties getProperties = (KeyboardProperties) field.get(newCSM);
318318

319319
assertEquals(getProperties.getCustomKeys().size(), 1);
320320
}
@@ -342,7 +342,7 @@ public void testCustomKeysNull() throws NoSuchFieldException, IllegalAccessExcep
342342
Field field = BaseChoiceSetManager.class.getDeclaredField("keyboardConfiguration");
343343
field.setAccessible(true);
344344

345-
KeyboardProperties getProperties = (KeyboardProperties)field.get(newCSM);
345+
KeyboardProperties getProperties = (KeyboardProperties) field.get(newCSM);
346346

347347
assertNull(getProperties.getCustomKeys());
348348
}
@@ -373,7 +373,7 @@ public void testMaskInputCharactersNotSupported() throws NoSuchFieldException, I
373373
Field field = BaseChoiceSetManager.class.getDeclaredField("keyboardConfiguration");
374374
field.setAccessible(true);
375375

376-
KeyboardProperties getProperties = (KeyboardProperties)field.get(newCSM);
376+
KeyboardProperties getProperties = (KeyboardProperties) field.get(newCSM);
377377

378378
assertNull(getProperties.getMaskInputCharacters());
379379
}

android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PreloadPresentChoicesOperationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ public void testCancelingChoiceSetIfThreadHasFinished() {
344344
when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(6, 0));
345345
WindowCapability windowCapability = new WindowCapability();
346346
HashSet<ChoiceCell> loadedCells = new HashSet<>();
347-
presentChoicesOperation = new PreloadPresentChoicesOperation(internalInterface, fileManager, choiceSet, InteractionMode.MANUAL_ONLY, null, null, TestValues.GENERAL_INTEGER,null, windowCapability, true, loadedCells, null, null);
347+
presentChoicesOperation = new PreloadPresentChoicesOperation(internalInterface, fileManager, choiceSet, InteractionMode.MANUAL_ONLY, null, null, TestValues.GENERAL_INTEGER, null, windowCapability, true, loadedCells, null, null);
348348
presentChoicesOperation.finishOperation(false);
349349

350350
assertEquals(Task.FINISHED, presentChoicesOperation.getState());
@@ -360,7 +360,7 @@ public void testCancelingChoiceSetIfThreadHasCanceled() {
360360
when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(6, 0));
361361
WindowCapability windowCapability = new WindowCapability();
362362
HashSet<ChoiceCell> loadedCells = new HashSet<>();
363-
presentChoicesOperation = new PreloadPresentChoicesOperation(internalInterface, fileManager, choiceSet, InteractionMode.MANUAL_ONLY, null, null, TestValues.GENERAL_INTEGER,null, windowCapability, true, loadedCells, null, null);
363+
presentChoicesOperation = new PreloadPresentChoicesOperation(internalInterface, fileManager, choiceSet, InteractionMode.MANUAL_ONLY, null, null, TestValues.GENERAL_INTEGER, null, windowCapability, true, loadedCells, null, null);
364364
presentChoicesOperation.cancelTask();
365365

366366
assertEquals(Task.CANCELED, presentChoicesOperation.getState());

android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuConfigurationUpdateOperationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public void run() {
192192
transactionQueue.add(operation, false);
193193
}
194194

195-
private Answer<Void> createSetGlobalPropertiesAnswer(final boolean success){
195+
private Answer<Void> createSetGlobalPropertiesAnswer(final boolean success) {
196196
return new Answer<Void>() {
197197
@Override
198198
public Void answer(InvocationOnMock invocation) {
@@ -206,7 +206,7 @@ public Void answer(InvocationOnMock invocation) {
206206
};
207207
}
208208

209-
private WindowCapability createWindowCapability (boolean supportsList, boolean supportsTile) {
209+
private WindowCapability createWindowCapability(boolean supportsList, boolean supportsTile) {
210210
WindowCapability windowCapability = new WindowCapability();
211211
windowCapability.setMenuLayoutsAvailable(new ArrayList<MenuLayout>());
212212
if (supportsList) {

android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuManagerTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public Void answer(InvocationOnMock invocation) {
145145
@Override
146146
public Void answer(InvocationOnMock invocation) {
147147
Object[] args = invocation.getArguments();
148-
List<RPCMessage> rpcs = (List<RPCMessage>) args[0];
148+
List<RPCMessage> rpcs = (List<RPCMessage>) args[0];
149149
OnMultipleRequestListener listener = (OnMultipleRequestListener) args[1];
150150

151151
for (RPCMessage rpcMessage : rpcs) {
@@ -550,7 +550,7 @@ public void testClearingMenu() {
550550
// Sleep to give time to Taskmaster to run the operations
551551
sleep();
552552

553-
assertEquals(0 , menuManager.currentMenuCells.size());
553+
assertEquals(0, menuManager.currentMenuCells.size());
554554
}
555555

556556
@Test

0 commit comments

Comments
 (0)