summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRHenigan <heniganr1@gmail.com>2020-08-14 14:12:58 -0400
committerRHenigan <heniganr1@gmail.com>2020-08-14 14:12:58 -0400
commit9251568adc9462db3d1c4e491ffd819204bd1922 (patch)
treee909f2bb684e626e761df5408cc88a657a0eda15
parentae561fcd103f4de5fb5a0e795938afb9d606f390 (diff)
downloadsdl_android-feature/0268_MainMenuUpdating_Pagination.tar.gz
Add Unit Tests for WindowCapabilityfeature/0268_MainMenuUpdating_Pagination
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java9
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowCapabilityTests.java23
2 files changed, 32 insertions, 0 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java
index b76fbade1..d15c1a300 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java
@@ -38,6 +38,7 @@ import com.smartdevicelink.proxy.rpc.DeviceInfo;
import com.smartdevicelink.proxy.rpc.DisplayCapabilities;
import com.smartdevicelink.proxy.rpc.DisplayCapability;
import com.smartdevicelink.proxy.rpc.DriverDistractionCapability;
+import com.smartdevicelink.proxy.rpc.DynamicUpdateCapabilities;
import com.smartdevicelink.proxy.rpc.EqualizerSettings;
import com.smartdevicelink.proxy.rpc.Grid;
import com.smartdevicelink.proxy.rpc.HMICapabilities;
@@ -418,6 +419,7 @@ public class TestValues {
public static final AudioControlData GENERAL_AUDIOCONTROLDATA = new AudioControlData();
public static final LightControlData GENERAL_LIGHTCONTROLDATA = new LightControlData();
public static final HMISettingsControlData GENERAL_HMISETTINGSCONTROLDATA = new HMISettingsControlData();
+ public static final DynamicUpdateCapabilities GENERAL_DYNAMICUPDATECAPABILITIES = new DynamicUpdateCapabilities();
public static final VehicleDataResult GENERAL_OEM_CUSTOM_VEHICLE_DATA = new VehicleDataResult();
public static final TemplateConfiguration GENERAL_TEMPLATE_CONFIGURATION = new TemplateConfiguration();
@@ -574,6 +576,7 @@ public class TestValues {
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();
+ public static final JSONObject JSON_DYNAMICUPDATECAPABILITIES = new JSONObject();
static {
GENERAL_TOUCHEVENTCAPABILITIES.setDoublePressAvailable(GENERAL_BOOLEAN);
GENERAL_TOUCHEVENTCAPABILITIES.setMultiTouchAvailable(GENERAL_BOOLEAN);
@@ -626,6 +629,9 @@ public class TestValues {
GENERAL_HMISETTINGSCONTROLDATA.setTemperatureUnit(GENERAL_TEMPERATUREUNIT);
GENERAL_HMISETTINGSCONTROLDATA.setDisplayMode(GENERAL_DISPLAYMODE);
+ GENERAL_DYNAMICUPDATECAPABILITIES.setSupportsDynamicSubMenus(GENERAL_BOOLEAN);
+ GENERAL_DYNAMICUPDATECAPABILITIES.setSupportedDynamicImageFieldNames(Collections.singletonList(GENERAL_IMAGEFIELDNAME));
+
GENERAL_LIGHTCONTROLDATA.setLightState(GENERAL_LIGHTSTATE_LIST);
GENERAL_STATIONIDNUMBER.setCountryCode(GENERAL_INT);
@@ -1342,6 +1348,9 @@ public class TestValues {
JSON_DISPLAYCAPABILITY.put(DisplayCapability.KEY_WINDOW_CAPABILITIES, JSON_WINDOW_CAPABILITIES);
JSON_DISPLAYCAPABILITY_LIST.put(JSON_DISPLAYCAPABILITY);
+ JSON_DYNAMICUPDATECAPABILITIES.put(DynamicUpdateCapabilities.KEY_SUPPORTS_DYNAMIC_SUB_MENUS, GENERAL_BOOLEAN);
+ JSON_DYNAMICUPDATECAPABILITIES.put(DynamicUpdateCapabilities.KEY_SUPPORTED_DYNAMIC_IMAGE_FIELD_NAMES, JsonUtils.createJsonArray(Collections.singletonList(GENERAL_IMAGEFIELDNAME)));
+
JSON_TOUCHCOORD.put(TouchCoord.KEY_X, GENERAL_INT);
JSON_TOUCHCOORD.put(TouchCoord.KEY_Y, GENERAL_INT);
JSON_TOUCHCOORDS.put(JSON_TOUCHCOORD);
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowCapabilityTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowCapabilityTests.java
index 62f2e4337..6ddee819b 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowCapabilityTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowCapabilityTests.java
@@ -2,10 +2,12 @@ package com.smartdevicelink.test.rpc.datatypes;
import com.smartdevicelink.marshal.JsonRPCMarshaller;
import com.smartdevicelink.proxy.rpc.ButtonCapabilities;
+import com.smartdevicelink.proxy.rpc.DynamicUpdateCapabilities;
import com.smartdevicelink.proxy.rpc.ImageField;
import com.smartdevicelink.proxy.rpc.SoftButtonCapabilities;
import com.smartdevicelink.proxy.rpc.TextField;
import com.smartdevicelink.proxy.rpc.WindowCapability;
+import com.smartdevicelink.proxy.rpc.enums.ImageFieldName;
import com.smartdevicelink.proxy.rpc.enums.ImageType;
import com.smartdevicelink.proxy.rpc.enums.MenuLayout;
import com.smartdevicelink.test.JsonUtils;
@@ -43,6 +45,7 @@ public class WindowCapabilityTests extends TestCase {
msg.setButtonCapabilities(TestValues.GENERAL_BUTTONCAPABILITIES_LIST);
msg.setSoftButtonCapabilities(TestValues.GENERAL_SOFTBUTTONCAPABILITIES_LIST);
msg.setMenuLayoutsAvailable(TestValues.GENERAL_MENU_LAYOUT_LIST);
+ msg.setDynamicUpdateCapabilities(TestValues.GENERAL_DYNAMICUPDATECAPABILITIES);
}
/**
@@ -59,6 +62,7 @@ public class WindowCapabilityTests extends TestCase {
List<ButtonCapabilities> buttonCapabilities = msg.getButtonCapabilities();
List<SoftButtonCapabilities> softButtonCapabilities = msg.getSoftButtonCapabilities();
List<MenuLayout> menuLayouts = msg.getMenuLayoutsAvailable();
+ DynamicUpdateCapabilities dynamicUpdateCapabilities = msg.getDynamicUpdateCapabilities();
// Valid Tests
assertEquals(TestValues.MATCH, TestValues.GENERAL_INT, windowID);
@@ -70,6 +74,7 @@ public class WindowCapabilityTests extends TestCase {
assertEquals(TestValues.MATCH, TestValues.GENERAL_BUTTONCAPABILITIES_LIST.size(), buttonCapabilities.size());
assertEquals(TestValues.MATCH, TestValues.GENERAL_SOFTBUTTONCAPABILITIES_LIST.size(), softButtonCapabilities.size());
assertEquals(TestValues.MATCH, TestValues.GENERAL_MENU_LAYOUT_LIST.size(), menuLayouts.size());
+ assertEquals(TestValues.MATCH, TestValues.GENERAL_DYNAMICUPDATECAPABILITIES, dynamicUpdateCapabilities);
for (int i = 0; i < TestValues.GENERAL_TEXTFIELD_LIST.size(); i++) {
assertTrue(TestValues.TRUE, Validator.validateTextFields(TestValues.GENERAL_TEXTFIELD_LIST.get(i), textFields.get(i)));
@@ -107,6 +112,7 @@ public class WindowCapabilityTests extends TestCase {
assertNull(TestValues.NULL, msg.getButtonCapabilities());
assertNull(TestValues.NULL, msg.getSoftButtonCapabilities());
assertNull(TestValues.NULL, msg.getMenuLayoutsAvailable());
+ assertNull(TestValues.NULL, msg.getDynamicUpdateCapabilities());
}
public void testJson() {
@@ -122,6 +128,7 @@ public class WindowCapabilityTests extends TestCase {
reference.put(WindowCapability.KEY_BUTTON_CAPABILITIES, TestValues.JSON_BUTTONCAPABILITIES);
reference.put(WindowCapability.KEY_SOFT_BUTTON_CAPABILITIES, TestValues.JSON_SOFTBUTTONCAPABILITIES);
reference.put(WindowCapability.KEY_MENU_LAYOUTS_AVAILABLE, JsonUtils.createJsonArray(TestValues.GENERAL_MENU_LAYOUT_LIST));
+ reference.put(WindowCapability.KEY_DYNAMIC_UPDATE_CAPABILITIES, TestValues.JSON_DYNAMICUPDATECAPABILITIES);
JSONObject underTest = msg.serializeJSON();
assertEquals(TestValues.MATCH, reference.length(), underTest.length());
@@ -191,6 +198,22 @@ public class WindowCapabilityTests extends TestCase {
for (int i = 0; i < referenceList.size(); i++) {
assertEquals(TestValues.MATCH, referenceList.get(i), underTestList.get(i));
}
+ } else if (key.equals(WindowCapability.KEY_DYNAMIC_UPDATE_CAPABILITIES)) {
+ JSONArray referenceArray = JsonUtils.readJsonArrayFromJsonObject(reference.getJSONObject(key), DynamicUpdateCapabilities.KEY_SUPPORTED_DYNAMIC_IMAGE_FIELD_NAMES);
+ JSONArray underTestArray = JsonUtils.readJsonArrayFromJsonObject(underTest.getJSONObject(key), DynamicUpdateCapabilities.KEY_SUPPORTED_DYNAMIC_IMAGE_FIELD_NAMES);
+ List<ImageFieldName> imageFieldNameListReference = new ArrayList<>();
+ List<ImageFieldName> imageFieldNameListTest = new ArrayList<>();
+ boolean referenceBool = JsonUtils.readBooleanFromJsonObject(reference.getJSONObject(key), DynamicUpdateCapabilities.KEY_SUPPORTS_DYNAMIC_SUB_MENUS);
+ boolean underTestBool = JsonUtils.readBooleanFromJsonObject(underTest.getJSONObject(key), DynamicUpdateCapabilities.KEY_SUPPORTS_DYNAMIC_SUB_MENUS);
+
+ assertEquals(TestValues.MATCH, referenceBool, underTestBool);
+ assertEquals(TestValues.MATCH, referenceArray.length(), underTestArray.length());
+
+ for (int i = 0; i < referenceArray.length(); i++) {
+ imageFieldNameListReference.add( (ImageFieldName) referenceArray.get(i));
+ imageFieldNameListTest.add( (ImageFieldName) underTestArray.get(i));
+ }
+ assertTrue(TestValues.TRUE, imageFieldNameListReference.containsAll(imageFieldNameListTest) && imageFieldNameListTest.containsAll(imageFieldNameListReference));
} else {
assertEquals(TestValues.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}