Skip to content

Commit

Permalink
Merge pull request #1171 from smartdevicelink/move_menuLayoutsAvailable
Browse files Browse the repository at this point in the history
Move menuLayoutsAvailable to WindowCapability
  • Loading branch information
BrettyWhite authored Oct 3, 2019
2 parents e62d723 + b75359c commit e71879a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public void setUp(){
msg.setMediaClockFormats(Test.GENERAL_MEDIACLOCKFORMAT_LIST);
msg.setScreenParams(Test.GENERAL_SCREENPARAMS);
msg.setTemplatesAvailable(Test.GENERAL_STRING_LIST);
msg.setMenuLayoutsAvailable(Test.GENERAL_MENU_LAYOUT_LIST);
}

/**
Expand All @@ -60,8 +59,7 @@ public void testRpcValues () {
List<MediaClockFormat> mediaClock = msg.getMediaClockFormats();
List<TextField> textFields = msg.getTextFields();
List<ImageField> imageFields = msg.getImageFields();
List<MenuLayout> menuLayouts = msg.getMenuLayoutsAvailable();


// Valid Tests
assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, graphicSupported);
assertEquals(Test.MATCH, Test.GENERAL_INT, numPresets);
Expand All @@ -72,8 +70,7 @@ public void testRpcValues () {
assertEquals(Test.MATCH, Test.GENERAL_MEDIACLOCKFORMAT_LIST.size(), mediaClock.size());
assertEquals(Test.MATCH, Test.GENERAL_TEXTFIELD_LIST.size(), textFields.size());
assertEquals(Test.MATCH, Test.GENERAL_IMAGEFIELD_LIST.size(), imageFields.size());
assertEquals(Test.MATCH, Test.GENERAL_MENU_LAYOUT_LIST.size(), menuLayouts.size());


for(int i = 0; i < Test.GENERAL_STRING_LIST.size(); i++){
assertEquals(Test.MATCH, Test.GENERAL_STRING_LIST.get(i), templatesAvailable.get(i));
}
Expand All @@ -90,9 +87,6 @@ public void testRpcValues () {
assertTrue(Test.TRUE, Validator.validateImageFields(Test.GENERAL_IMAGEFIELD_LIST.get(i), imageFields.get(i)));
}

for(int i = 0; i < Test.GENERAL_MENU_LAYOUT_LIST.size(); i++){
assertEquals(Test.MATCH, Test.GENERAL_MENU_LAYOUT_LIST.get(i), menuLayouts.get(i));
}

// Invalid/Null Tests
DisplayCapabilities msg = new DisplayCapabilities();
Expand All @@ -107,7 +101,6 @@ public void testRpcValues () {
assertNull(Test.NULL, msg.getScreenParams());
assertNull(Test.NULL, msg.getTemplatesAvailable());
assertNull(Test.NULL, msg.getTextFields());
assertNull(Test.NULL, msg.getMenuLayoutsAvailable());
}

public void testJson(){
Expand All @@ -123,7 +116,6 @@ public void testJson(){
reference.put(DisplayCapabilities.KEY_TEXT_FIELDS, Test.JSON_TEXTFIELDS);
reference.put(DisplayCapabilities.KEY_IMAGE_FIELDS, Test.JSON_IMAGEFIELDS);
reference.put(DisplayCapabilities.KEY_SCREEN_PARAMS, Test.JSON_SCREENPARAMS);
reference.put(DisplayCapabilities.KEY_MENU_LAYOUTS_AVAILABLE, JsonUtils.createJsonArray(Test.GENERAL_MENU_LAYOUT_LIST));

JSONObject underTest = msg.serializeJSON();
assertEquals(Test.MATCH, reference.length(), underTest.length());
Expand Down Expand Up @@ -163,7 +155,7 @@ public void testJson(){
Hashtable<String, Object> hashTest= JsonRPCMarshaller.deserializeJSONObject(underTestArray);

assertTrue(Test.TRUE, Validator.validateScreenParams(new ScreenParams(hashReference), new ScreenParams(hashTest)));
} else if(key.equals(DisplayCapabilities.KEY_MEDIA_CLOCK_FORMATS) || key.equals(DisplayCapabilities.KEY_MENU_LAYOUTS_AVAILABLE)){
} else if(key.equals(DisplayCapabilities.KEY_MEDIA_CLOCK_FORMATS)){
JSONArray referenceArray = JsonUtils.readJsonArrayFromJsonObject(reference, key);
JSONArray underTestArray = JsonUtils.readJsonArrayFromJsonObject(underTest, key);
assertEquals(Test.MATCH, referenceArray.length(), underTestArray.length());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.smartdevicelink.proxy.rpc.TextField;
import com.smartdevicelink.proxy.rpc.WindowCapability;
import com.smartdevicelink.proxy.rpc.enums.ImageType;
import com.smartdevicelink.proxy.rpc.enums.MenuLayout;
import com.smartdevicelink.test.JsonUtils;
import com.smartdevicelink.test.Test;
import com.smartdevicelink.test.Validator;
Expand Down Expand Up @@ -39,6 +40,7 @@ public void setUp() {
msg.setNumCustomPresetsAvailable(Test.GENERAL_INT);
msg.setButtonCapabilities(Test.GENERAL_BUTTONCAPABILITIES_LIST);
msg.setSoftButtonCapabilities(Test.GENERAL_SOFTBUTTONCAPABILITIES_LIST);
msg.setMenuLayoutsAvailable(Test.GENERAL_MENU_LAYOUT_LIST);
}

/**
Expand All @@ -54,6 +56,7 @@ public void testRpcValues() {
int numCustomPresetsAvailable = msg.getNumCustomPresetsAvailable();
List<ButtonCapabilities> buttonCapabilities = msg.getButtonCapabilities();
List<SoftButtonCapabilities> softButtonCapabilities = msg.getSoftButtonCapabilities();
List<MenuLayout> menuLayouts = msg.getMenuLayoutsAvailable();

// Valid Tests
assertEquals(Test.MATCH, Test.GENERAL_INT, windowID);
Expand All @@ -64,6 +67,7 @@ public void testRpcValues() {
assertEquals(Test.MATCH, Test.GENERAL_INT, numCustomPresetsAvailable);
assertEquals(Test.MATCH, Test.GENERAL_BUTTONCAPABILITIES_LIST.size(), buttonCapabilities.size());
assertEquals(Test.MATCH, Test.GENERAL_SOFTBUTTONCAPABILITIES_LIST.size(), softButtonCapabilities.size());
assertEquals(Test.MATCH, Test.GENERAL_MENU_LAYOUT_LIST.size(), menuLayouts.size());

for (int i = 0; i < Test.GENERAL_TEXTFIELD_LIST.size(); i++) {
assertTrue(Test.TRUE, Validator.validateTextFields(Test.GENERAL_TEXTFIELD_LIST.get(i), textFields.get(i)));
Expand All @@ -81,6 +85,10 @@ public void testRpcValues() {
assertEquals(Test.MATCH, Test.GENERAL_STRING_LIST.get(i), templatesAvailable.get(i));
}

for(int i = 0; i < Test.GENERAL_MENU_LAYOUT_LIST.size(); i++){
assertEquals(Test.MATCH, Test.GENERAL_MENU_LAYOUT_LIST.get(i), menuLayouts.get(i));
}

assertTrue(Test.TRUE, Validator.validateButtonCapabilities(Test.GENERAL_BUTTONCAPABILITIES_LIST, buttonCapabilities));
assertTrue(Test.TRUE, Validator.validateSoftButtonCapabilities(Test.GENERAL_SOFTBUTTONCAPABILITIES_LIST, softButtonCapabilities));

Expand All @@ -96,6 +104,7 @@ public void testRpcValues() {
assertNull(Test.NULL, msg.getNumCustomPresetsAvailable());
assertNull(Test.NULL, msg.getButtonCapabilities());
assertNull(Test.NULL, msg.getSoftButtonCapabilities());
assertNull(Test.NULL, msg.getMenuLayoutsAvailable());
}

public void testJson() {
Expand All @@ -110,6 +119,7 @@ public void testJson() {
reference.put(WindowCapability.KEY_NUM_CUSTOM_PRESETS_AVAILABLE, Test.GENERAL_INT);
reference.put(WindowCapability.KEY_BUTTON_CAPABILITIES, Test.JSON_BUTTONCAPABILITIES);
reference.put(WindowCapability.KEY_SOFT_BUTTON_CAPABILITIES, Test.JSON_SOFTBUTTONCAPABILITIES);
reference.put(WindowCapability.KEY_MENU_LAYOUTS_AVAILABLE, JsonUtils.createJsonArray(Test.GENERAL_MENU_LAYOUT_LIST));

JSONObject underTest = msg.serializeJSON();
assertEquals(Test.MATCH, reference.length(), underTest.length());
Expand Down Expand Up @@ -171,7 +181,7 @@ public void testJson() {
testList.add(new SoftButtonCapabilities(hashTest));
}
assertTrue(Test.TRUE, Validator.validateSoftButtonCapabilities(referenceList, testList));
} else if (key.equals(WindowCapability.KEY_IMAGE_TYPE_SUPPORTED)) {
} else if (key.equals(WindowCapability.KEY_IMAGE_TYPE_SUPPORTED) || (key.equals(WindowCapability.KEY_MENU_LAYOUTS_AVAILABLE))) {
List<String> referenceList = JsonUtils.readStringListFromJsonObject(reference, key);
List<String> underTestList = JsonUtils.readStringListFromJsonObject(underTest, key);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,15 +464,15 @@ public boolean openSubMenu(@NonNull MenuCell cell){
}

/**
* The main menu layout. See available menu layouts on DisplayCapabilities.menuLayoutsAvailable.
* The main menu layout. See available menu layouts on WindowCapability.menuLayoutsAvailable.
* @param menuConfiguration - The default menuConfiguration
*/
public void setMenuConfiguration(@NonNull MenuConfiguration menuConfiguration) {
this.menuManager.setMenuConfiguration(menuConfiguration);
}

/**
* The main menu layout. See available menu layouts on DisplayCapabilities.menuLayoutsAvailable.
* The main menu layout. See available menu layouts on WindowCapability.menuLayoutsAvailable.
* @return the currently set MenuConfiguration
*/
public MenuConfiguration getMenuConfiguration(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.DisplayType;
import com.smartdevicelink.proxy.rpc.enums.MediaClockFormat;
import com.smartdevicelink.proxy.rpc.enums.MenuLayout;
import com.smartdevicelink.util.Version;

import java.util.Hashtable;
Expand Down Expand Up @@ -86,12 +85,6 @@
* <td>The display's persistent screen supports referencing a static or dynamic image.</td>
* <td>SmartDeviceLink 2.0</td>
* </tr>
* <tr>
* <td>menuLayoutsAvailable</td>
* <td>MenuLayout[]</td>
* <td>An array of available menu layouts. If this parameter is not provided, only the `LIST` layout is assumed to be available</td>
* <td>SmartDeviceLink 6.0</td>
* </tr>
* </table>
* @since SmartDeviceLink 1.0
* @see DisplayType
Expand All @@ -110,7 +103,6 @@ public class DisplayCapabilities extends RPCStruct {
public static final String KEY_SCREEN_PARAMS = "screenParams";
public static final String KEY_TEMPLATES_AVAILABLE = "templatesAvailable";
public static final String KEY_NUM_CUSTOM_PRESETS_AVAILABLE = "numCustomPresetsAvailable";
public static final String KEY_MENU_LAYOUTS_AVAILABLE = "menuLayoutsAvailable";
/**
* Constructs a newly allocated DisplayCapabilities object
*/
Expand Down Expand Up @@ -279,23 +271,4 @@ public void setScreenParams(ScreenParams screenParams) {
public ScreenParams getScreenParams() {
return (ScreenParams) getObject(ScreenParams.class, KEY_SCREEN_PARAMS);
}

/**
* An array of available menu layouts. If this parameter is not provided, only the `LIST` layout
* is assumed to be available
* @param menuLayout - An array of MenuLayouts
*/
public void setMenuLayoutsAvailable(List<MenuLayout> menuLayout) {
setValue(KEY_MENU_LAYOUTS_AVAILABLE, menuLayout);
}

/**
* An array of available menu layouts. If this parameter is not provided, only the `LIST` layout
* is assumed to be available
* @return MenuLayout[]
*/
@SuppressWarnings("unchecked")
public List<MenuLayout> getMenuLayoutsAvailable() {
return (List<MenuLayout>) getObject(MenuLayout.class, KEY_MENU_LAYOUTS_AVAILABLE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.ImageType;
import com.smartdevicelink.proxy.rpc.enums.MenuLayout;

import java.util.Hashtable;
import java.util.List;

Expand All @@ -17,6 +19,7 @@ public class WindowCapability extends RPCStruct {
public static final String KEY_NUM_CUSTOM_PRESETS_AVAILABLE = "numCustomPresetsAvailable";
public static final String KEY_BUTTON_CAPABILITIES = "buttonCapabilities";
public static final String KEY_SOFT_BUTTON_CAPABILITIES = "softButtonCapabilities";
public static final String KEY_MENU_LAYOUTS_AVAILABLE = "menuLayoutsAvailable";

public WindowCapability() {
}
Expand Down Expand Up @@ -183,4 +186,23 @@ public void setSoftButtonCapabilities(List<SoftButtonCapabilities> softButtonCap
public List<SoftButtonCapabilities> getSoftButtonCapabilities() {
return (List<SoftButtonCapabilities>) getObject(SoftButtonCapabilities.class, KEY_SOFT_BUTTON_CAPABILITIES);
}

/**
* An array of available menu layouts. If this parameter is not provided, only the `LIST` layout
* is assumed to be available
* @param menuLayout - An array of MenuLayouts
*/
public void setMenuLayoutsAvailable(List<MenuLayout> menuLayout) {
setValue(KEY_MENU_LAYOUTS_AVAILABLE, menuLayout);
}

/**
* An array of available menu layouts. If this parameter is not provided, only the `LIST` layout
* is assumed to be available
* @return MenuLayout[]
*/
@SuppressWarnings("unchecked")
public List<MenuLayout> getMenuLayoutsAvailable() {
return (List<MenuLayout>) getObject(MenuLayout.class, KEY_MENU_LAYOUTS_AVAILABLE);
}
}

0 comments on commit e71879a

Please sign in to comment.