diff options
Diffstat (limited to 'android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/SoftButtonCapabilitiesTest.java')
-rw-r--r-- | android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/SoftButtonCapabilitiesTest.java | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/SoftButtonCapabilitiesTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/SoftButtonCapabilitiesTest.java index 25feeb6f8..7778c60a4 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/SoftButtonCapabilitiesTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/SoftButtonCapabilitiesTest.java @@ -12,73 +12,73 @@ import org.json.JSONObject; import java.util.Iterator; /** - * This is a unit test class for the SmartDeviceLink library project class : + * This is a unit test class for the SmartDeviceLink library project class : * {@link com.smartdevicelink.proxy.rpc.SoftButtonCapabilities} */ public class SoftButtonCapabilitiesTest extends TestCase { - private SoftButtonCapabilities msg; + private SoftButtonCapabilities msg; - @Override - public void setUp() { - msg = new SoftButtonCapabilities(); - - msg.setImageSupported(TestValues.GENERAL_BOOLEAN); - msg.setShortPressAvailable(TestValues.GENERAL_BOOLEAN); - msg.setLongPressAvailable(TestValues.GENERAL_BOOLEAN); - msg.setUpDownAvailable(TestValues.GENERAL_BOOLEAN); - msg.setTextSupported(TestValues.GENERAL_BOOLEAN); - } + @Override + public void setUp() { + msg = new SoftButtonCapabilities(); + + msg.setImageSupported(TestValues.GENERAL_BOOLEAN); + msg.setShortPressAvailable(TestValues.GENERAL_BOOLEAN); + msg.setLongPressAvailable(TestValues.GENERAL_BOOLEAN); + msg.setUpDownAvailable(TestValues.GENERAL_BOOLEAN); + msg.setTextSupported(TestValues.GENERAL_BOOLEAN); + } /** - * Tests the expected values of the RPC message. - */ - public void testRpcValues () { - // Test Values - Boolean imageSupp = msg.getImageSupported(); - Boolean updown = msg.getUpDownAvailable(); - Boolean longPress = msg.getLongPressAvailable(); - Boolean shortPress = msg.getShortPressAvailable(); - Boolean textSupported = msg.getTextSupported(); - - // Valid Tests - assertEquals(TestValues.MATCH, (Boolean) TestValues.GENERAL_BOOLEAN, imageSupp); - assertEquals(TestValues.MATCH, (Boolean) TestValues.GENERAL_BOOLEAN, updown); - assertEquals(TestValues.MATCH, (Boolean) TestValues.GENERAL_BOOLEAN, longPress); - assertEquals(TestValues.MATCH, (Boolean) TestValues.GENERAL_BOOLEAN, shortPress); - assertEquals(TestValues.MATCH, (Boolean) TestValues.GENERAL_BOOLEAN, textSupported); - - // Invalid/Null Tests - SoftButtonCapabilities msg = new SoftButtonCapabilities(); - assertNotNull(TestValues.NOT_NULL, msg); - - assertNull(TestValues.NULL, msg.getImageSupported()); - assertNull(TestValues.NULL, msg.getLongPressAvailable()); - assertNull(TestValues.NULL, msg.getShortPressAvailable()); - assertNull(TestValues.NULL, msg.getUpDownAvailable()); - assertNull(TestValues.NULL, msg.getTextSupported()); - } - - public void testJson() { - JSONObject reference = new JSONObject(); - - try { - reference.put(SoftButtonCapabilities.KEY_IMAGE_SUPPORTED, TestValues.GENERAL_BOOLEAN); - reference.put(SoftButtonCapabilities.KEY_UP_DOWN_AVAILABLE, TestValues.GENERAL_BOOLEAN); - reference.put(SoftButtonCapabilities.KEY_LONG_PRESS_AVAILABLE, TestValues.GENERAL_BOOLEAN); - reference.put(SoftButtonCapabilities.KEY_SHORT_PRESS_AVAILABLE, TestValues.GENERAL_BOOLEAN); - reference.put(SoftButtonCapabilities.KEY_TEXT_SUPPORTED, TestValues.GENERAL_BOOLEAN); - - JSONObject underTest = msg.serializeJSON(); - assertEquals(TestValues.MATCH, reference.length(), underTest.length()); - - Iterator<?> iterator = reference.keys(); - while (iterator.hasNext()) { - String key = (String) iterator.next(); - assertEquals(TestValues.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key)); - } - } catch (JSONException e) { - fail(TestValues.JSON_FAIL); - } - } + * Tests the expected values of the RPC message. + */ + public void testRpcValues() { + // Test Values + Boolean imageSupp = msg.getImageSupported(); + Boolean updown = msg.getUpDownAvailable(); + Boolean longPress = msg.getLongPressAvailable(); + Boolean shortPress = msg.getShortPressAvailable(); + Boolean textSupported = msg.getTextSupported(); + + // Valid Tests + assertEquals(TestValues.MATCH, (Boolean) TestValues.GENERAL_BOOLEAN, imageSupp); + assertEquals(TestValues.MATCH, (Boolean) TestValues.GENERAL_BOOLEAN, updown); + assertEquals(TestValues.MATCH, (Boolean) TestValues.GENERAL_BOOLEAN, longPress); + assertEquals(TestValues.MATCH, (Boolean) TestValues.GENERAL_BOOLEAN, shortPress); + assertEquals(TestValues.MATCH, (Boolean) TestValues.GENERAL_BOOLEAN, textSupported); + + // Invalid/Null Tests + SoftButtonCapabilities msg = new SoftButtonCapabilities(); + assertNotNull(TestValues.NOT_NULL, msg); + + assertNull(TestValues.NULL, msg.getImageSupported()); + assertNull(TestValues.NULL, msg.getLongPressAvailable()); + assertNull(TestValues.NULL, msg.getShortPressAvailable()); + assertNull(TestValues.NULL, msg.getUpDownAvailable()); + assertNull(TestValues.NULL, msg.getTextSupported()); + } + + public void testJson() { + JSONObject reference = new JSONObject(); + + try { + reference.put(SoftButtonCapabilities.KEY_IMAGE_SUPPORTED, TestValues.GENERAL_BOOLEAN); + reference.put(SoftButtonCapabilities.KEY_UP_DOWN_AVAILABLE, TestValues.GENERAL_BOOLEAN); + reference.put(SoftButtonCapabilities.KEY_LONG_PRESS_AVAILABLE, TestValues.GENERAL_BOOLEAN); + reference.put(SoftButtonCapabilities.KEY_SHORT_PRESS_AVAILABLE, TestValues.GENERAL_BOOLEAN); + reference.put(SoftButtonCapabilities.KEY_TEXT_SUPPORTED, TestValues.GENERAL_BOOLEAN); + + JSONObject underTest = msg.serializeJSON(); + assertEquals(TestValues.MATCH, reference.length(), underTest.length()); + + Iterator<?> iterator = reference.keys(); + while (iterator.hasNext()) { + String key = (String) iterator.next(); + assertEquals(TestValues.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key)); + } + } catch (JSONException e) { + fail(TestValues.JSON_FAIL); + } + } }
\ No newline at end of file |