Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement SDL 0221 Allow Multiple Modules per Module Type #1166

Merged
merged 25 commits into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c80386f
Merge pull request #2 from smartdevicelink/develop
Tnnnguyen Jun 6, 2019
5b2ec87
Multiple Module, 1st batch
Tnnnguyen Jul 16, 2019
d51ee44
- handle new response msg for GetInteriorVehicleDataConsentResponse a…
Tnnnguyen Jul 16, 2019
57325d1
Add overridden methods onGetInteriorVehicleDataConsentResponse and on…
Tnnnguyen Jul 17, 2019
ec6a6ef
Fix test cases, add more enum to enum tests and refractor functionId …
Tnnnguyen Jul 17, 2019
340acfa
Add tests for ModuleInfo
Tnnnguyen Jul 19, 2019
638fa96
Add unit tests for SeatLocationCapability
Tnnnguyen Jul 23, 2019
ccfd846
Add unit tests for Grid, SeatLocation, GetInteriorVehicleDataConsent
Tnnnguyen Jul 24, 2019
2941586
Add unit tests for Grid, SeatLocation, GetInteriorVehicleDataConsent
Tnnnguyen Jul 24, 2019
3e4e2e8
Add test for GetInteriorVehicleDataConsentResponse
Tnnnguyen Jul 24, 2019
4e17c37
Add unit tests for ReleaseInteriorVehicleDataModule and ReleaseInteri…
Tnnnguyen Jul 24, 2019
ff68529
Add unit tests for ReleaseInteriorVehicleDataModule and ReleaseInteri…
Tnnnguyen Jul 24, 2019
535dae3
Add more unit tests
Tnnnguyen Jul 25, 2019
7ba046b
Merge new changes from develop branch
Tnnnguyen Jul 29, 2019
0d0da4a
Merge new changes from develop branch
Tnnnguyen Jul 29, 2019
90855d5
Merge branch 'develop_mainRepo' into multipleModule
Tnnnguyen Jul 29, 2019
17b2216
Resolve more conflict.
Tnnnguyen Jul 29, 2019
9de53f4
Merge branch 'develop_mainRepo' into multipleModule
Tnnnguyen Jul 31, 2019
12e0106
Attempt a work-around to fix failed test suite on server.
Tnnnguyen Jul 31, 2019
3ede8b3
Revert "Attempt a work-around to fix failed test suite on server."
Tnnnguyen Jul 31, 2019
8794787
Merge branch 'develop_mainRepo' into multipleModule
Tnnnguyen Aug 13, 2019
3f49e16
Removed unused import.
Tnnnguyen Aug 13, 2019
f6a773c
Fix per code review recommendations: remove unused imports and attemp…
Tnnnguyen Aug 13, 2019
3107370
Merge branch 'develop' into testMM
BrettyWhite Sep 6, 2019
7fae28a
fix bracket
BrettyWhite Sep 6, 2019
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"request":{
"name":"GetInteriorVehicleDataConsent",
"correlationID":168,
"parameters":{
"moduleType":"CLIMATE",
"moduleIds":[
"A0A",
"R0A"
]
}
},
"response":{
"name":"GetInteriorVehicleDataConsent",
"correlationID":169,
"parameters":{
"allowed":[
true,
true
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"request":{
"name":"ReleaseInteriorVehicleDataModule",
"correlationID":172,
"parameters":{
"moduleType":"CLIMATE",
"moduleIds":"A0A"
}
},
"response":{
"name":"ReleaseInteriorVehicleDataModule",
"correlationID":173
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,24 @@ public static List<Integer> readIntegerListFromJsonObject(JSONObject json, Strin

return null;
}

public static List<Boolean> readBooleanListFromJsonObject(JSONObject json, String key){
JSONArray jsonArray = readJsonArrayFromJsonObject(json, key);

if(jsonArray != null){
int len = jsonArray.length();
List<Boolean> result = new ArrayList<>(len);
for(int i=0; i<len; i++){
try {
Boolean bool = jsonArray.getBoolean(i);
result.add(bool);
} catch (JSONException e) {}
}
return result;
}

return null;
}

public static List<Double> readDoubleListFromJsonObject(JSONObject json, String key){
JSONArray jsonArray = readJsonArrayFromJsonObject(json, key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.smartdevicelink.proxy.rpc.DisplayCapabilities;
import com.smartdevicelink.proxy.rpc.DisplayCapability;
import com.smartdevicelink.proxy.rpc.EqualizerSettings;
import com.smartdevicelink.proxy.rpc.Grid;
import com.smartdevicelink.proxy.rpc.HMICapabilities;
import com.smartdevicelink.proxy.rpc.HMIPermissions;
import com.smartdevicelink.proxy.rpc.HMISettingsControlCapabilities;
Expand All @@ -57,6 +58,7 @@
import com.smartdevicelink.proxy.rpc.MenuParams;
import com.smartdevicelink.proxy.rpc.MetadataTags;
import com.smartdevicelink.proxy.rpc.ModuleData;
import com.smartdevicelink.proxy.rpc.ModuleInfo;
import com.smartdevicelink.proxy.rpc.NavigationCapability;
import com.smartdevicelink.proxy.rpc.NavigationInstruction;
import com.smartdevicelink.proxy.rpc.NavigationServiceData;
Expand All @@ -76,6 +78,7 @@
import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
import com.smartdevicelink.proxy.rpc.SeatControlCapabilities;
import com.smartdevicelink.proxy.rpc.SeatControlData;
import com.smartdevicelink.proxy.rpc.SeatLocation;
import com.smartdevicelink.proxy.rpc.SeatMemoryAction;
import com.smartdevicelink.proxy.rpc.SingleTireStatus;
import com.smartdevicelink.proxy.rpc.SisData;
Expand Down Expand Up @@ -424,8 +427,10 @@ public class Test {
public static final HapticRect GENERAL_HAPTIC_RECT = new HapticRect();
public static final FuelType GENERAL_FUELTYPE = FuelType.GASOLINE;
public static final LockScreenConfig GENERAL_LOCKSCREENCONFIG = new LockScreenConfig();
public static final Grid GENERAL_GRID = new Grid();
public static final SeatLocation GENERAL_SEAT_LOCATION = new SeatLocation();
public static final ModuleInfo GENERAL_MODULE_INFO = new ModuleInfo();
public static final WindowType GENERAL_WINDOW_TYPE = WindowType.MAIN;

public static final List<Long> GENERAL_LONG_LIST = Arrays.asList(new Long[]{ 1L, 2L });
public static final List<Turn> GENERAL_TURN_LIST = new ArrayList<Turn>();
public static final List<Choice> GENERAL_CHOICE_LIST = new ArrayList<Choice>();
Expand Down Expand Up @@ -473,6 +478,8 @@ public class Test {
public static final List<WeatherData> GENERAL_WEATHERDATA_LIST = Arrays.asList(GENERAL_WEATHERDATA);
public static final List<WeatherAlert> GENERAL_WEATHERALERT_LIST = Arrays.asList(GENERAL_WEATHERALERT);
public static final List<NavigationInstruction> GENERAL_NAVIGATION_INSTRUCTION_LIST = Arrays.asList(GENERAL_NAVIGATION_INSTRUCTION);
public static final List<SeatLocation> GENERAL_SEAT_LIST = new ArrayList<>(1);
public static final List<Boolean> GENERAL_BOOLEAN_LIST = Arrays.asList(new Boolean[]{Boolean.TRUE, Boolean.TRUE});
public static final List<Integer> GENERAL_AVAILABLE_HD_CHANNELS_LIST = Arrays.asList(new Integer[]{ 1, 2});
public static final List<ImageType> GENERAL_IMAGE_TYPE_LIST = Arrays.asList(new ImageType[]{ImageType.DYNAMIC, ImageType.STATIC});
public static final List<WindowTypeCapabilities> GENERAL_WINDOW_TYPE_CAPABILITIES_LIST = new ArrayList<WindowTypeCapabilities>(1);
Expand Down Expand Up @@ -515,6 +522,7 @@ public void onVoiceCommandSelected() {
public static final JSONArray JSON_RADIOCONTROLCAPABILITIES = new JSONArray();
public static final JSONArray JSON_CLIMATECONTROLCAPABILITIES = new JSONArray();
public static final JSONArray JSON_TEXTFIELDTYPES = new JSONArray();
public static final JSONArray JSON_SEAT_LOCATIONS = new JSONArray();
public static final JSONObject JSON_TURN = new JSONObject();
public static final JSONObject JSON_IMAGE = new JSONObject();
public static final JSONObject JSON_CHOICE = new JSONObject();
Expand Down Expand Up @@ -542,6 +550,8 @@ public void onVoiceCommandSelected() {
public static final JSONObject JSON_RGBCOLOR = new JSONObject();
public static final JSONObject JSON_DAYCOLORSCHEME = new JSONObject();
public static final JSONObject JSON_NIGHTCOLORSCHEME = new JSONObject();
public static final JSONObject JSON_GRID = new JSONObject();
public static final JSONObject JSON_MODULE_INFO = new JSONObject();
public static final JSONArray JSON_IMAGE_TYPE_SUPPORTED = new JSONArray();
public static final JSONObject JSON_WINDOW_TYPE_CAPABILITIES = new JSONObject();
public static final JSONArray JSON_WINDOW_TYPE_CAPABILITIES_LIST = new JSONArray();
Expand All @@ -550,7 +560,6 @@ public void onVoiceCommandSelected() {
public static final JSONArray JSON_IMAGE_TYPES = new JSONArray();
public static final JSONObject JSON_DISPLAYCAPABILITY = new JSONObject();
public static final JSONArray JSON_DISPLAYCAPABILITY_LIST = new JSONArray();

static {
GENERAL_TOUCHEVENTCAPABILITIES.setDoublePressAvailable(GENERAL_BOOLEAN);
GENERAL_TOUCHEVENTCAPABILITIES.setMultiTouchAvailable(GENERAL_BOOLEAN);
Expand Down Expand Up @@ -721,6 +730,7 @@ public void onVoiceCommandSelected() {

GENERAL_MEDIACLOCKFORMAT_LIST.add(MediaClockFormat.CLOCK1);
GENERAL_MEDIACLOCKFORMAT_LIST.add(MediaClockFormat.CLOCK2);
GENERAL_SEAT_LIST.add(GENERAL_SEAT_LOCATION);

GENERAL_IMAGE.setValue(GENERAL_STRING);
GENERAL_IMAGE.setImageType(GENERAL_IMAGETYPE);
Expand Down Expand Up @@ -1094,6 +1104,10 @@ public void onVoiceCommandSelected() {
GENERAL_NAVIGATION_INSTRUCTION.setDrivingSide(GENERAL_DIRECTION);
GENERAL_NAVIGATION_INSTRUCTION.setDetails(GENERAL_STRING);
GENERAL_NAVIGATION_INSTRUCTION.setImage(GENERAL_IMAGE);
GENERAL_MODULE_INFO.setModuleId(Test.GENERAL_STRING);
GENERAL_MODULE_INFO.setModuleLocation(Test.GENERAL_GRID);
GENERAL_MODULE_INFO.setModuleServiceArea(Test.GENERAL_GRID);
GENERAL_MODULE_INFO.setMultipleAccessAllowance(Test.GENERAL_BOOLEAN);


try {
Expand Down Expand Up @@ -1323,6 +1337,13 @@ public void onVoiceCommandSelected() {
JSON_TEXTFIELDTYPES.put(MetadataType.MEDIA_ALBUM);
JSON_TEXTFIELDTYPES.put(MetadataType.MEDIA_ARTIST);

JSON_SEAT_LOCATIONS.put(JSON_GRID);
JSON_MODULE_INFO.put(ModuleInfo.KEY_MODULE_ID, Test.GENERAL_STRING);
JSON_MODULE_INFO.put(ModuleInfo.KEY_MODULE_LOCATION, Test.JSON_GRID);
JSON_MODULE_INFO.put(ModuleInfo.KEY_MODULE_SERVICE_AREA, Test.JSON_GRID);
JSON_MODULE_INFO.put(ModuleInfo.KEY_MULTIPLE_ACCESS_ALLOWED, Test.GENERAL_BOOLEAN);


} catch (JSONException e) {
Log.e("Test", "Static Json Construction Failed.", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.smartdevicelink.proxy.rpc.EqualizerSettings;
import com.smartdevicelink.proxy.rpc.FuelRange;
import com.smartdevicelink.proxy.rpc.GPSData;
import com.smartdevicelink.proxy.rpc.Grid;
import com.smartdevicelink.proxy.rpc.HMICapabilities;
import com.smartdevicelink.proxy.rpc.HMIPermissions;
import com.smartdevicelink.proxy.rpc.HMISettingsControlCapabilities;
Expand All @@ -53,6 +54,7 @@
import com.smartdevicelink.proxy.rpc.MediaServiceManifest;
import com.smartdevicelink.proxy.rpc.MenuParams;
import com.smartdevicelink.proxy.rpc.ModuleData;
import com.smartdevicelink.proxy.rpc.ModuleInfo;
import com.smartdevicelink.proxy.rpc.MyKey;
import com.smartdevicelink.proxy.rpc.NavigationCapability;
import com.smartdevicelink.proxy.rpc.NavigationInstruction;
Expand All @@ -73,6 +75,7 @@
import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
import com.smartdevicelink.proxy.rpc.SeatControlCapabilities;
import com.smartdevicelink.proxy.rpc.SeatControlData;
import com.smartdevicelink.proxy.rpc.SeatLocation;
import com.smartdevicelink.proxy.rpc.SeatMemoryAction;
import com.smartdevicelink.proxy.rpc.SingleTireStatus;
import com.smartdevicelink.proxy.rpc.SisData;
Expand Down Expand Up @@ -3787,4 +3790,73 @@ public static boolean validateVideoStreamingCapability(VideoStreamingCapability

return true;
}

public static boolean validateGrid(Grid g1, Grid g2) {
String tag = "validateGrid";
if (g1 == null) {
return (g2 == null);
}
if (g2 == null) {
return (g1 == null);
}
if (g1.getColumn() != g2.getColumn()) {
log(tag, "Columns do not match");
return false;
}
if (g1.getRow() != g2.getRow()) {
log(tag, "Rows do not match");
return false;
}
if (g1.getLevel() != g2.getLevel()) {
log(tag, "Levels do not match");
return false;
}
if (g1.getColumnSpan() != g2.getColumnSpan()) {
log(tag, "Column spans do not match");
return false;
}
if (g1.getRowSpan() != g2.getRowSpan()) {
log(tag, "Row spans do not match");
return false;
}
if (g1.getLevelSpan() != g2.getLevelSpan()) {
log(tag, "Level spans do not match");
return false;
}

return true;
}

public static boolean validateModuleInfo(ModuleInfo m1, ModuleInfo m2) {
if (m1 == null) {
return (m2 == null);
}
if (m2 == null) {
return (m1 == null);
}
if (!m1.getModuleId().equals(m2.getModuleId())) {
return false;
}
if (!m1.getMultipleAccessAllowance().equals(m2.getMultipleAccessAllowance())) {
return false;
}
if (!validateGrid(m1.getModuleLocation(), m2.getModuleLocation())) {
return false;
}
if (!validateGrid(m1.getModuleServiceArea(), m2.getModuleServiceArea())) {
return false;
}

return true;
}

public static boolean validateSeatLocation(SeatLocation cap1, SeatLocation cap2) {
if (cap1 == null) {
return (cap2 == null);
}
if (cap2 == null) {
return (cap1 == null);
}
return validateGrid(cap1.getGrid(), cap2.getGrid());
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package com.smartdevicelink.test.rpc.datatypes;

import com.smartdevicelink.marshal.JsonRPCMarshaller;
import com.smartdevicelink.proxy.rpc.AudioControlCapabilities;
import com.smartdevicelink.proxy.rpc.ModuleInfo;
import com.smartdevicelink.test.JsonUtils;
import com.smartdevicelink.test.Test;
import com.smartdevicelink.test.Validator;

import junit.framework.TestCase;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.Hashtable;
import java.util.Iterator;

/**
Expand All @@ -30,6 +34,7 @@ public void setUp() {
msg.setEqualizerAvailable(Test.GENERAL_BOOLEAN);
msg.setVolumeAvailable(Test.GENERAL_BOOLEAN);
msg.setEqualizerMaxChannelId(Test.GENERAL_INT);
msg.setModuleInfo(Test.GENERAL_MODULE_INFO);
}

/**
Expand All @@ -44,6 +49,7 @@ public void testRpcValues() {
Boolean volumeAvailable = msg.getVolumeAvailable();
Boolean equalizerAvailable = msg.getEqualizerAvailable();
int equalizerMaxChannelId = msg.getEqualizerMaxChannelId();
ModuleInfo info = msg.getModuleInfo();

// Valid Tests
assertEquals(Test.MATCH, Test.GENERAL_STRING, moduleName);
Expand All @@ -52,6 +58,7 @@ public void testRpcValues() {
assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, (boolean) volumeAvailable);
assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, (boolean) equalizerAvailable);
assertEquals(Test.MATCH, Test.GENERAL_INT, equalizerMaxChannelId);
assertEquals(Test.MATCH, Test.GENERAL_MODULE_INFO, info);

// Invalid/Null Tests
AudioControlCapabilities msg = new AudioControlCapabilities();
Expand All @@ -63,6 +70,7 @@ public void testRpcValues() {
assertNull(Test.NULL, msg.getVolumeAvailable());
assertNull(Test.NULL, msg.getEqualizerAvailable());
assertNull(Test.NULL, msg.getEqualizerMaxChannelId());
assertNull(Test.NULL, msg.getModuleInfo());
}

public void testJson() {
Expand All @@ -76,16 +84,23 @@ public void testJson() {
reference.put(AudioControlCapabilities.KEY_VOLUME_AVAILABLE, Test.GENERAL_BOOLEAN);
reference.put(AudioControlCapabilities.KEY_EQUALIZER_AVAILABLE, Test.GENERAL_BOOLEAN);
reference.put(AudioControlCapabilities.KEY_EQUALIZER_MAX_CHANNEL_ID, Test.GENERAL_INT);
reference.put(AudioControlCapabilities.KEY_MODULE_INFO, Test.JSON_MODULE_INFO);

JSONObject underTest = msg.serializeJSON();
assertEquals(Test.MATCH, reference.length(), underTest.length());

Iterator<?> iterator = reference.keys();
while (iterator.hasNext()) {
String key = (String) iterator.next();

assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));

if (key.equals(AudioControlCapabilities.KEY_MODULE_INFO)) {
JSONObject o1 = (JSONObject) JsonUtils.readObjectFromJsonObject(reference, key);
JSONObject o2 = (JSONObject) JsonUtils.readObjectFromJsonObject(underTest, key);
Hashtable<String, Object> h1 = JsonRPCMarshaller.deserializeJSONObject(o1);
Hashtable<String, Object> h2 = JsonRPCMarshaller.deserializeJSONObject(o2);
assertTrue(Test.TRUE, Validator.validateModuleInfo(new ModuleInfo(h1), new ModuleInfo(h2)));
} else {
assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}
} catch (JSONException e) {
fail(Test.JSON_FAIL);
Expand Down
Loading