Skip to content

Commit

Permalink
Merge 1e85ab2 into 6834f99
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianKast authored Sep 27, 2021
2 parents 6834f99 + 1e85ab2 commit 93407eb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.smartdevicelink.proxy.rpc.SetDisplayLayoutResponse;
import com.smartdevicelink.proxy.rpc.SoftButtonCapabilities;
import com.smartdevicelink.proxy.rpc.SystemCapability;
import com.smartdevicelink.proxy.rpc.TextField;
import com.smartdevicelink.proxy.rpc.VideoStreamingCapability;
import com.smartdevicelink.proxy.rpc.WindowCapability;
import com.smartdevicelink.proxy.rpc.WindowTypeCapabilities;
Expand All @@ -52,6 +53,7 @@
import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
import com.smartdevicelink.proxy.rpc.enums.SystemContext;
import com.smartdevicelink.proxy.rpc.enums.TextFieldName;
import com.smartdevicelink.proxy.rpc.enums.WindowType;
import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCListener;
Expand Down Expand Up @@ -689,6 +691,35 @@ public void testGetAndAddListenerForDisplaysCapability() {
verify(internalInterface, times(0)).sendRPC(any(GetSystemCapability.class));
}

/**
* Test to verify that we can get null for templatesAvailable without hitting an NPE and
* test media field conversion for NON_MEDIA to NON-MEDIA for Sync bug.
*/
@Test
public void testMediaFieldConversion() {
SystemCapabilityManager systemCapabilityManager = new SystemCapabilityManager(new InternalSDLInterface());

RegisterAppInterfaceResponse raiResponse = new RegisterAppInterfaceResponse();
DisplayCapabilities displayCapabilities = new DisplayCapabilities();
displayCapabilities.setGraphicSupported(false);
TextField textField = new TextField();
textField.setName(TextFieldName.mainField1);
displayCapabilities.setTextFields(Collections.singletonList(textField));
raiResponse.setDisplayCapabilities(displayCapabilities);
raiResponse.setSuccess(true);
systemCapabilityManager.parseRAIResponse(raiResponse);

WindowCapability windowCapability = systemCapabilityManager.getDefaultMainWindowCapability();
assertNull(windowCapability.getTemplatesAvailable());

List<String> templates = new ArrayList<>();
templates.add("NON_MEDIA");
displayCapabilities.setTemplatesAvailable(templates);
systemCapabilityManager.parseRAIResponse(raiResponse);
windowCapability = systemCapabilityManager.getDefaultMainWindowCapability();
assertTrue(windowCapability.getTemplatesAvailable().contains("NON-MEDIA"));
}

@Test
public void testListConversion() {
SystemCapabilityManager systemCapabilityManager = createSampleManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,15 @@ private List<DisplayCapability> createDisplayCapabilityList(DisplayCapabilities

// HAX: Issue #1705, Ford Sync bug returning incorrect template name for "NON-MEDIA" (https://github.com/smartdevicelink/sdl_java_suite/issues/1705).
List<String> templatesAvailable = display.getTemplatesAvailable();
for (int i = 0; i < templatesAvailable.size(); i++) {
if (templatesAvailable.get(i).equals("NON_MEDIA")) {
templatesAvailable.set(i, "NON-MEDIA");
break;
if (templatesAvailable != null) {
for (int i = 0; i < templatesAvailable.size(); i++) {
if ("NON_MEDIA".equals(templatesAvailable.get(i))) {
templatesAvailable.set(i, "NON-MEDIA");
break;
}
}
}

// copy all available display capabilities
defaultWindowCapability.setTemplatesAvailable(templatesAvailable);
defaultWindowCapability.setNumCustomPresetsAvailable(display.getNumCustomPresetsAvailable());
Expand Down

0 comments on commit 93407eb

Please sign in to comment.