summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikayla Ray <mikayla@livioconnect.com>2015-05-28 16:25:19 -0400
committerMikayla Ray <mikayla@livioconnect.com>2015-05-28 16:25:19 -0400
commiteaa941ad26f86e3b5faba0951b678d2dffcc04aa (patch)
tree28aa6090f9c89bf5d1dcb5713284dee015c5b806
parent14ad41176eef98d75d0526f58a3e035137214eca (diff)
downloadsdl_android-eaa941ad26f86e3b5faba0951b678d2dffcc04aa.tar.gz
Updated and documented all of the rpc datatype test classes.
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/Test.java132
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/AirbagStatusTests.java167
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/AudioPassThruCapabilitiesTest.java96
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/BeltStatusTests.java256
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/BodyInformationTests.java139
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ButtonCapabilitiesTests.java108
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ChoiceTests.java180
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ClusterModeStatusTests.java107
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DIDResultTests.java77
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DTCTests.java61
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DeviceInfoTests.java136
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DeviceStatusTests.java217
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DisplayCapabilitiesTests.java319
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ECallInfoTests.java78
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/EmergencyEventTests.java108
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/GPSDataTests.java292
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/HMIPermissionsTests.java83
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/HeadLampStatusTests.java80
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/HeadersTests.java175
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ImageFieldTests.java110
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ImageResolutionTests.java64
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ImageTests.java72
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/KeyboardPropertiesTests.java123
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/MenuParamsTests.java75
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/MyKeyTests.java50
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ParameterPermissionsTests.java62
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/PermissionItemTest.java113
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/PresetBankCapabilitiesTest.java49
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ScreenParamsTest.java98
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SdlMsgVersionTest.java62
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SingleTireStatusTest.java48
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SoftButtonCapabilitiesTest.java92
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SoftButtonTest.java137
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/StartTimeTest.java77
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TTSChunkTest.java58
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TextFieldTest.java92
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TireStatusTest.java140
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TouchCoordTest.java62
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TouchEventCapabilitiesTest.java77
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TouchEventTest.java138
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TurnTests.java59
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/VehicleDataResultTest.java56
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/VehicleTypeTest.java88
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/VrHelpItemTest.java89
44 files changed, 2004 insertions, 2898 deletions
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/Test.java b/sdl_android_tests/src/com/smartdevicelink/test/Test.java
index 3b5a769c5..0ec756aee 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/Test.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/Test.java
@@ -40,6 +40,7 @@ import com.smartdevicelink.proxy.rpc.Turn;
import com.smartdevicelink.proxy.rpc.VehicleDataResult;
import com.smartdevicelink.proxy.rpc.VehicleType;
import com.smartdevicelink.proxy.rpc.VrHelpItem;
+import com.smartdevicelink.proxy.rpc.enums.AmbientLightStatus;
import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
import com.smartdevicelink.proxy.rpc.enums.AppInterfaceUnregisteredReason;
import com.smartdevicelink.proxy.rpc.enums.AudioStreamingState;
@@ -48,12 +49,22 @@ import com.smartdevicelink.proxy.rpc.enums.BitsPerSample;
import com.smartdevicelink.proxy.rpc.enums.ButtonEventMode;
import com.smartdevicelink.proxy.rpc.enums.ButtonName;
import com.smartdevicelink.proxy.rpc.enums.ButtonPressMode;
+import com.smartdevicelink.proxy.rpc.enums.CarModeStatus;
import com.smartdevicelink.proxy.rpc.enums.CharacterSet;
+import com.smartdevicelink.proxy.rpc.enums.CompassDirection;
+import com.smartdevicelink.proxy.rpc.enums.ComponentVolumeStatus;
+import com.smartdevicelink.proxy.rpc.enums.DeviceLevelStatus;
+import com.smartdevicelink.proxy.rpc.enums.Dimension;
import com.smartdevicelink.proxy.rpc.enums.DisplayType;
+import com.smartdevicelink.proxy.rpc.enums.ECallConfirmationStatus;
+import com.smartdevicelink.proxy.rpc.enums.EmergencyEventType;
import com.smartdevicelink.proxy.rpc.enums.FileType;
+import com.smartdevicelink.proxy.rpc.enums.FuelCutoffStatus;
import com.smartdevicelink.proxy.rpc.enums.GlobalProperty;
import com.smartdevicelink.proxy.rpc.enums.HMILevel;
import com.smartdevicelink.proxy.rpc.enums.HmiZoneCapabilities;
+import com.smartdevicelink.proxy.rpc.enums.IgnitionStableStatus;
+import com.smartdevicelink.proxy.rpc.enums.IgnitionStatus;
import com.smartdevicelink.proxy.rpc.enums.ImageFieldName;
import com.smartdevicelink.proxy.rpc.enums.ImageType;
import com.smartdevicelink.proxy.rpc.enums.InteractionMode;
@@ -64,7 +75,10 @@ import com.smartdevicelink.proxy.rpc.enums.Language;
import com.smartdevicelink.proxy.rpc.enums.LayoutMode;
import com.smartdevicelink.proxy.rpc.enums.LockScreenStatus;
import com.smartdevicelink.proxy.rpc.enums.MediaClockFormat;
+import com.smartdevicelink.proxy.rpc.enums.PowerModeQualificationStatus;
+import com.smartdevicelink.proxy.rpc.enums.PowerModeStatus;
import com.smartdevicelink.proxy.rpc.enums.PrerecordedSpeech;
+import com.smartdevicelink.proxy.rpc.enums.PrimaryAudioSource;
import com.smartdevicelink.proxy.rpc.enums.RequestType;
import com.smartdevicelink.proxy.rpc.enums.SamplingRate;
import com.smartdevicelink.proxy.rpc.enums.SoftButtonType;
@@ -77,9 +91,13 @@ import com.smartdevicelink.proxy.rpc.enums.TextFieldName;
import com.smartdevicelink.proxy.rpc.enums.TouchType;
import com.smartdevicelink.proxy.rpc.enums.TriggerSource;
import com.smartdevicelink.proxy.rpc.enums.UpdateMode;
+import com.smartdevicelink.proxy.rpc.enums.VehicleDataEventStatus;
+import com.smartdevicelink.proxy.rpc.enums.VehicleDataNotificationStatus;
import com.smartdevicelink.proxy.rpc.enums.VehicleDataResultCode;
+import com.smartdevicelink.proxy.rpc.enums.VehicleDataStatus;
import com.smartdevicelink.proxy.rpc.enums.VehicleDataType;
import com.smartdevicelink.proxy.rpc.enums.VrCapabilities;
+import com.smartdevicelink.proxy.rpc.enums.WarningLightStatus;
public class Test {
@@ -102,7 +120,34 @@ public class Test {
public static final KeyboardEvent GENERAL_KEYBOARDEVENT = KeyboardEvent.ENTRY_SUBMITTED;
public static final LockScreenStatus GENERAL_SHOWLOCKSCREEN = LockScreenStatus.REQUIRED;
public static final TBTState GENERAL_TBTSTATE = TBTState.NEXT_TURN_REQUEST;
-
+ public static final PowerModeQualificationStatus GENERAL_POWERMODEQUALIFICATIONSTATUS = PowerModeQualificationStatus.POWER_MODE_OK;
+ public static final CarModeStatus GENERAL_CARMODESTATUS = CarModeStatus.NORMAL;
+ public static final PowerModeStatus GENERAL_POWERMODESTATUS = PowerModeStatus.RUNNING_2;
+ public static final DeviceLevelStatus GENERAL_DEVICELEVELSTATUS = DeviceLevelStatus.FOUR_LEVEL_BARS;
+ public static final PrimaryAudioSource GENERAL_PRIMARYAUDIOSOURCE = PrimaryAudioSource.BLUETOOTH_STEREO_BTST;
+ public static final ECallConfirmationStatus GENERAL_ECALLCONFIRMATIONSTATUS = ECallConfirmationStatus.CALL_IN_PROGRESS;
+ public static final VehicleDataNotificationStatus GENERAL_VEHICLEDATANOTIFICATIONSTATUS = VehicleDataNotificationStatus.NORMAL;
+ public static final EmergencyEventType GENERAL_EMERGENCYEVENTTYPE = EmergencyEventType.FAULT;
+ public static final FuelCutoffStatus GENERAL_FUELCUTOFFSTATUS = FuelCutoffStatus.NORMAL_OPERATION;
+ public static final Dimension GENERAL_DIMENSION = Dimension._2D;
+ public static final CompassDirection GENERAL_COMPASSDIRECTION = CompassDirection.EAST;
+ public static final AmbientLightStatus GENERAL_AMBIENTLIGHTSTATUS = AmbientLightStatus.NIGHT;
+ public static final SoftButtonType GENERAL_SOFTBUTTONTYPE = SoftButtonType.SBT_BOTH;
+ public static final SystemAction GENERAL_SYSTEMACTION = SystemAction.DEFAULT_ACTION;
+ public static final ImageResolution GENERAL_IMAGERESOLUTION = new ImageResolution();
+ public static final TouchEventCapabilities GENERAL_TOUCHEVENTCAPABILITIES = new TouchEventCapabilities();
+ public static final VehicleDataStatus GENERAL_VEHICLEDATASTATUS = VehicleDataStatus.ON;
+ public static final TextFieldName GENERAL_TEXTFIELDNAME = TextFieldName.ETA;
+ public static final CharacterSet GENERAL_CHARACTERSET = CharacterSet.CID1SET;
+ public static final ImageType GENERAL_IMAGETYPE = ImageType.DYNAMIC;
+ public static final KeyboardLayout GENERAL_KEYBOARDLAYOUT = KeyboardLayout.QWERTY;
+ public static final KeypressMode GENERAL_KEYPRESSMODE = KeypressMode.QUEUE_KEYPRESSES;
+ public static final ImageFieldName GENERAL_IMAGEFIELDNAME = ImageFieldName.graphic;
+ public static final HMIPermissions GENERAL_HMIPERMISSIONS = new HMIPermissions();
+ public static final ParameterPermissions GENERAL_PARAMETERPERMISSIONS = new ParameterPermissions();
+ public static final SpeechCapabilities GENERAL_SPEECHCAPABILITIES = SpeechCapabilities.TEXT;
+ public static final DisplayType GENERAL_DISPLAYTYPE = DisplayType.CID;
+
// Rpc Request & Response Values
public static final int GENERAL_INT = 100;
public static final float GENERAL_FLOAT = 100f;
@@ -129,18 +174,28 @@ public class Test {
public static final BitsPerSample GENERAL_BITSPERSAMPLE = BitsPerSample._8_BIT;
public static final TextAlignment GENERAL_TEXTALIGNMENT = TextAlignment.CENTERED;
public static final SdlMsgVersion GENERAL_SDLMSGVERSION = new SdlMsgVersion();
+ public static final IgnitionStatus GENERAL_IGNITIONSTATUS = IgnitionStatus.RUN;
+ public static final VehicleDataType GENERAL_VEHICLEDATATYPE = VehicleDataType.VEHICLEDATA_BRAKING;
public static final InteractionMode GENERAL_INTERACTIONMODE = InteractionMode.BOTH;
+ public static final WarningLightStatus GENERAL_WARNINGLIGHTSTATUS = WarningLightStatus.OFF;
public static final KeyboardProperties GENERAL_KEYBOARDPROPERTIES = new KeyboardProperties();
public static final DisplayCapabilities GENERAL_DISPLAYCAPABILITIES = new DisplayCapabilities();
+ public static final IgnitionStableStatus GENERAL_IGNITIONSTABLESTATUS = IgnitionStableStatus.IGNITION_SWITCH_STABLE;
+ public static final VehicleDataResultCode GENERAL_VEHICLEDATARESULTCODE = VehicleDataResultCode.IGNORED;
+ public static final ComponentVolumeStatus GENERAL_COMPONENTVOLUMESTATUS = ComponentVolumeStatus.LOW;
public static final PresetBankCapabilities GENERAL_PRESETBANKCAPABILITIES = new PresetBankCapabilities();
+ public static final VehicleDataEventStatus GENERAL_VEHCILEDATAEVENTSTATUS = VehicleDataEventStatus.YES;
public static final List<Turn> GENERAL_TURN_LIST = new ArrayList<Turn>();
public static final List<Choice> GENERAL_CHOICE_LIST = new ArrayList<Choice>();
public static final List<String> GENERAL_STRING_LIST = Arrays.asList(new String[] { "a", "b"});
public static final List<Integer> GENERAL_INTEGER_LIST = Arrays.asList(new Integer[]{ -1, -2});
public static final List<TTSChunk> GENERAL_TTSCHUNK_LIST = new ArrayList<TTSChunk>(2);
+ public static final List<HMILevel> GENERAL_HMILEVEL_LIST = Arrays.asList(new HMILevel[]{HMILevel.HMI_FULL, HMILevel.HMI_BACKGROUND});
+ public static final List<FileType> GENERAL_FILETYPE_LIST = new ArrayList<FileType>(1);
public static final List<TextField> GENERAL_TEXTFIELD_LIST = new ArrayList<TextField>(1);
public static final List<DIDResult> GENERAL_DIDRESULT_LIST = new ArrayList<DIDResult>(1);
+ public static final List<TouchCoord> GENERAL_TOUCHCOORD_LIST = new ArrayList<TouchCoord>(1);
public static final List<AppHMIType> GENERAL_APPHMITYPE_LIST = new ArrayList<AppHMIType>(2);
public static final List<VrHelpItem> GENERAL_VRHELPITEM_LIST = new ArrayList<VrHelpItem>(2);
public static final List<SoftButton> GENERAL_SOFTBUTTON_LIST = new ArrayList<SoftButton>(1);
@@ -160,9 +215,11 @@ public class Test {
public static final JSONArray JSON_TURNS = new JSONArray();
public static final JSONArray JSON_CHOICES = new JSONArray();
+ public static final JSONArray JSON_HMILEVELS = new JSONArray();
public static final JSONArray JSON_TTSCHUNKS = new JSONArray();
public static final JSONArray JSON_DIDRESULTS = new JSONArray();
public static final JSONArray JSON_TEXTFIELDS = new JSONArray();
+ public static final JSONArray JSON_TOUCHCOORDS = new JSONArray();
public static final JSONArray JSON_VRHELPITEMS = new JSONArray();
public static final JSONArray JSON_SOFTBUTTONS = new JSONArray();
public static final JSONArray JSON_IMAGEFIELDS = new JSONArray();
@@ -179,11 +236,24 @@ public class Test {
public static final JSONObject JSON_DEVICEINFO = new JSONObject();
public static final JSONObject JSON_SCREENPARAMS = new JSONObject();
public static final JSONObject JSON_SDLMSGVERSION = new JSONObject();
+ public static final JSONObject JSON_HMIPERMISSIONS = new JSONObject();
+ public static final JSONObject JSON_IMAGERESOLUTION = new JSONObject();
public static final JSONObject JSON_KEYBOARDPROPERTIES = new JSONObject();
public static final JSONObject JSON_DISPLAYCAPABILITIES = new JSONObject();
+ public static final JSONObject JSON_PARAMETERPERMISSIONS = new JSONObject();
public static final JSONObject JSON_PRESETBANKCAPABILITIES = new JSONObject();
-
+ public static final JSONObject JSON_TOUCHEVENTCAPABILITIES = new JSONObject();
+
static {
+ // TouchEventCapabilities Setup
+ GENERAL_TOUCHEVENTCAPABILITIES.setDoublePressAvailable(GENERAL_BOOLEAN);
+ GENERAL_TOUCHEVENTCAPABILITIES.setMultiTouchAvailable(GENERAL_BOOLEAN);
+ GENERAL_TOUCHEVENTCAPABILITIES.setPressAvailable(GENERAL_BOOLEAN);
+
+ // ImageResolution Setup
+ GENERAL_IMAGERESOLUTION.setResolutionHeight(GENERAL_INT);
+ GENERAL_IMAGERESOLUTION.setResolutionWidth(GENERAL_INT);
+
// Choice Setup
GENERAL_CHOICE.setMenuName(GENERAL_STRING);
GENERAL_CHOICE.setSecondaryText(GENERAL_STRING);
@@ -197,13 +267,12 @@ public class Test {
TouchCoord touchCoord = new TouchCoord();
touchCoord.setX(GENERAL_INT);
touchCoord.setY(GENERAL_INT);
- List<TouchCoord> coordList = new ArrayList<TouchCoord>();
- coordList.add(touchCoord);
+ GENERAL_TOUCHCOORD_LIST.add(touchCoord);
TouchEvent touchEvent = new TouchEvent();
touchEvent.setId(GENERAL_INT);
touchEvent.setTs(GENERAL_INTEGER_LIST);
- touchEvent.setC(coordList);
+ touchEvent.setC(GENERAL_TOUCHCOORD_LIST);
GENERAL_TOUCHEVENT_LIST.add(touchEvent);
// TextField List Setup
@@ -219,13 +288,12 @@ public class Test {
imageResolution.setResolutionHeight(GENERAL_INT);
imageResolution.setResolutionWidth(GENERAL_INT);
- List<FileType> fileTypes = new ArrayList<FileType>();
- fileTypes.add(GENERAL_FILETYPE);
+ GENERAL_FILETYPE_LIST.add(GENERAL_FILETYPE);
ImageField imageField = new ImageField();
imageField.setImageResolution(imageResolution);
imageField.setName(ImageFieldName.graphic);
- imageField.setImageTypeSupported(fileTypes);
+ imageField.setImageTypeSupported(GENERAL_FILETYPE_LIST);
GENERAL_IMAGEFIELD_LIST.add(imageField);
// ScreenParams Setup
@@ -394,21 +462,32 @@ public class Test {
GENERAL_VRCAPABILITIES_LIST.add(VrCapabilities.TEXT);
// PermissionItem List Setup
- HMIPermissions hmiPermissions = new HMIPermissions();
- hmiPermissions.setAllowed(Arrays.asList(new HMILevel[]{HMILevel.HMI_FULL, HMILevel.HMI_BACKGROUND}));
- hmiPermissions.setUserDisallowed(Arrays.asList(new HMILevel[]{HMILevel.HMI_LIMITED, HMILevel.HMI_NONE}));
+ GENERAL_HMIPERMISSIONS.setAllowed(GENERAL_HMILEVEL_LIST);
+ GENERAL_HMIPERMISSIONS.setUserDisallowed(GENERAL_HMILEVEL_LIST);
- ParameterPermissions paramPermissions = new ParameterPermissions();
- paramPermissions.setAllowed(GENERAL_STRING_LIST);
- paramPermissions.setUserDisallowed(GENERAL_STRING_LIST);
+ GENERAL_PARAMETERPERMISSIONS.setAllowed(GENERAL_STRING_LIST);
+ GENERAL_PARAMETERPERMISSIONS.setUserDisallowed(GENERAL_STRING_LIST);
PermissionItem permissionItem = new PermissionItem();
permissionItem.setRpcName(GENERAL_STRING);
- permissionItem.setHMIPermissions(hmiPermissions);
- permissionItem.setParameterPermissions(paramPermissions);
+ permissionItem.setHMIPermissions(GENERAL_HMIPERMISSIONS);
+ permissionItem.setParameterPermissions(GENERAL_PARAMETERPERMISSIONS);
GENERAL_PERMISSIONITEM_LIST.add(permissionItem);
try {
+ // Json HMIPermissions Setup
+ JSON_HMIPERMISSIONS.put(HMIPermissions.KEY_ALLOWED, GENERAL_HMILEVEL_LIST);
+ JSON_HMIPERMISSIONS.put(HMIPermissions.KEY_USER_DISALLOWED, GENERAL_HMILEVEL_LIST);
+
+ // Json TouchEventCapabilities Setup
+ JSON_TOUCHEVENTCAPABILITIES.put(TouchEventCapabilities.KEY_DOUBLE_PRESS_AVAILABLE, GENERAL_BOOLEAN);
+ JSON_TOUCHEVENTCAPABILITIES.put(TouchEventCapabilities.KEY_MULTI_TOUCH_AVAILABLE, GENERAL_BOOLEAN);
+ JSON_TOUCHEVENTCAPABILITIES.put(TouchEventCapabilities.KEY_PRESS_AVAILABLE, GENERAL_BOOLEAN);
+
+ // Json ImageResolution Setup
+ JSON_IMAGERESOLUTION.put(ImageResolution.KEY_RESOLUTION_HEIGHT, GENERAL_INT);
+ JSON_IMAGERESOLUTION.put(ImageResolution.KEY_RESOLUTION_WIDTH, GENERAL_INT);
+
// Json Choice Setup
JSON_CHOICE.put(Choice.KEY_MENU_NAME, GENERAL_STRING);
JSON_CHOICE.put(Choice.KEY_SECONDARY_TEXT, GENERAL_STRING);
@@ -419,17 +498,19 @@ public class Test {
JSON_CHOICE.put(Choice.KEY_VR_COMMANDS, JsonUtils.createJsonArray(GENERAL_STRING_LIST));
// Json PermissionItem List Setup
+ JSON_HMILEVELS.put(HMILevel.HMI_FULL);
+ JSON_HMILEVELS.put(HMILevel.HMI_BACKGROUND);
+
JSONObject jsonHmiPerm = new JSONObject();
- jsonHmiPerm.put(HMIPermissions.KEY_ALLOWED, JsonUtils.createJsonArray(Arrays.asList(new HMILevel[]{HMILevel.HMI_FULL, HMILevel.HMI_BACKGROUND})));
- jsonHmiPerm.put(HMIPermissions.KEY_USER_DISALLOWED, JsonUtils.createJsonArray(Arrays.asList(new HMILevel[]{HMILevel.HMI_LIMITED, HMILevel.HMI_NONE})));
+ jsonHmiPerm.put(HMIPermissions.KEY_ALLOWED, JSON_HMILEVELS);
+ jsonHmiPerm.put(HMIPermissions.KEY_USER_DISALLOWED, JSON_HMILEVELS);
- JSONObject jsonParamPerm = new JSONObject();
- jsonParamPerm.put(ParameterPermissions.KEY_ALLOWED, JsonUtils.createJsonArray(GENERAL_STRING_LIST));
- jsonParamPerm.put(ParameterPermissions.KEY_USER_DISALLOWED, JsonUtils.createJsonArray(GENERAL_STRING_LIST));
+ JSON_PARAMETERPERMISSIONS.put(ParameterPermissions.KEY_ALLOWED, JsonUtils.createJsonArray(GENERAL_STRING_LIST));
+ JSON_PARAMETERPERMISSIONS.put(ParameterPermissions.KEY_USER_DISALLOWED, JsonUtils.createJsonArray(GENERAL_STRING_LIST));
JSONObject jsonPermItem = new JSONObject();
jsonPermItem.put(PermissionItem.KEY_HMI_PERMISSIONS, jsonHmiPerm);
- jsonPermItem.put(PermissionItem.KEY_PARAMETER_PERMISSIONS, jsonParamPerm);
+ jsonPermItem.put(PermissionItem.KEY_PARAMETER_PERMISSIONS, JSON_PARAMETERPERMISSIONS);
jsonPermItem.put(PermissionItem.KEY_RPC_NAME, GENERAL_STRING);
JSON_PERMISSIONITEMS.put(jsonPermItem);
@@ -558,7 +639,7 @@ public class Test {
jsonItem = new JSONObject();
jsonItem.put(ImageField.KEY_IMAGE_RESOLUTION, jsonImageResolution);
- jsonItem.put(ImageField.KEY_IMAGE_TYPE_SUPPORTED, JsonUtils.createJsonArray(fileTypes));
+ jsonItem.put(ImageField.KEY_IMAGE_TYPE_SUPPORTED, JsonUtils.createJsonArray(Test.GENERAL_FILETYPE_LIST));
jsonItem.put(ImageField.KEY_NAME, ImageFieldName.graphic);
JSON_IMAGEFIELDS.put(jsonItem);
@@ -585,11 +666,10 @@ public class Test {
JSONObject jsonTouchCoord = new JSONObject();
jsonTouchCoord.put(TouchCoord.KEY_X, GENERAL_INT);
jsonTouchCoord.put(TouchCoord.KEY_Y, GENERAL_INT);
- JSONArray jsonCoordList = new JSONArray();
- jsonCoordList.put(jsonTouchCoord);
+ JSON_TOUCHCOORDS.put(jsonTouchCoord);
JSONObject jsonTouchEvent = new JSONObject();
- jsonTouchEvent.put(TouchEvent.KEY_C, jsonCoordList);
+ jsonTouchEvent.put(TouchEvent.KEY_C, JSON_TOUCHCOORDS);
jsonTouchEvent.put(TouchEvent.KEY_ID, GENERAL_INT);
jsonTouchEvent.put(TouchEvent.KEY_TS, JsonUtils.createJsonArray(GENERAL_INTEGER_LIST));
JSON_TOUCHEVENTS.put(jsonTouchEvent);
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/AirbagStatusTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/AirbagStatusTests.java
index 43765f0b8..d65e68760 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/AirbagStatusTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/AirbagStatusTests.java
@@ -10,130 +10,93 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.AirbagStatus;
import com.smartdevicelink.proxy.rpc.enums.VehicleDataEventStatus;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.AirbagStatus}
+ */
public class AirbagStatusTests extends TestCase{
- private static final VehicleDataEventStatus DRIVER_STATUS = VehicleDataEventStatus.YES;
- private static final VehicleDataEventStatus DRIVER_CURTAIN_STATUS = VehicleDataEventStatus.NO;
- private static final VehicleDataEventStatus DRIVER_KNEE_STATUS = VehicleDataEventStatus.YES;
- private static final VehicleDataEventStatus DRIVER_SIDE_STATUS = VehicleDataEventStatus.NO;
- private static final VehicleDataEventStatus PASSENGER_STATUS = VehicleDataEventStatus.YES;
- private static final VehicleDataEventStatus PASSENGER_CURTAIN_STATUS = VehicleDataEventStatus.YES;
- private static final VehicleDataEventStatus PASSENGER_KNEE_STATUS = VehicleDataEventStatus.NO;
- private static final VehicleDataEventStatus PASSENGER_SIDE_STATUS = VehicleDataEventStatus.YES;
-
- private AirbagStatus msg;
+ private AirbagStatus msg;
@Override
public void setUp(){
msg = new AirbagStatus();
+ assertNotNull(Test.NOT_NULL, msg);
- msg.setDriverAirbagDeployed(DRIVER_STATUS);
- msg.setDriverCurtainAirbagDeployed(DRIVER_CURTAIN_STATUS);
- msg.setDriverKneeAirbagDeployed(DRIVER_KNEE_STATUS);
- msg.setDriverSideAirbagDeployed(DRIVER_SIDE_STATUS);
- msg.setPassengerAirbagDeployed(PASSENGER_STATUS);
- msg.setPassengerCurtainAirbagDeployed(PASSENGER_CURTAIN_STATUS);
- msg.setPassengerKneeAirbagDeployed(PASSENGER_KNEE_STATUS);
- msg.setPassengerSideAirbagDeployed(PASSENGER_SIDE_STATUS);
+ msg.setDriverAirbagDeployed(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setDriverCurtainAirbagDeployed(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setDriverKneeAirbagDeployed(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setDriverSideAirbagDeployed(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setPassengerAirbagDeployed(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setPassengerCurtainAirbagDeployed(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setPassengerKneeAirbagDeployed(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setPassengerSideAirbagDeployed(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
}
-
- public void testCreation(){
- assertNotNull("Object creation failed.", msg);
- }
-
- public void testDriverAirbag(){
- VehicleDataEventStatus status = msg.getDriverAirbagDeployed();
- assertEquals("Read status didn't match expected status.", DRIVER_STATUS, status);
- }
-
- public void testDriverCurtainAirbag(){
- VehicleDataEventStatus status = msg.getDriverCurtainAirbagDeployed();
- assertEquals("Read status didn't match expected status.", DRIVER_CURTAIN_STATUS, status);
- }
-
- public void testDriverKneeAirbag(){
- VehicleDataEventStatus status = msg.getDriverKneeAirbagDeployed();
- assertEquals("Read status didn't match expected status.", DRIVER_KNEE_STATUS, status);
- }
-
- public void testDriverSideAirbag(){
- VehicleDataEventStatus status = msg.getDriverSideAirbagDeployed();
- assertEquals("Read status didn't match expected status.", DRIVER_SIDE_STATUS, status);
- }
-
- public void testPassengerAirbag(){
- VehicleDataEventStatus status = msg.getPassengerAirbagDeployed();
- assertEquals("Read status didn't match expected status.", PASSENGER_STATUS, status);
- }
-
- public void testPassengerCurtainAirbag(){
- VehicleDataEventStatus status = msg.getPassengerCurtainAirbagDeployed();
- assertEquals("Read status didn't match expected status.", PASSENGER_CURTAIN_STATUS, status);
- }
-
- public void testPassengerKneeAirbag(){
- VehicleDataEventStatus status = msg.getPassengerKneeAirbagDeployed();
- assertEquals("Read status didn't match expected status.", PASSENGER_KNEE_STATUS, status);
- }
-
- public void testPassengerSideAirbag(){
- VehicleDataEventStatus status = msg.getPassengerSideAirbagDeployed();
- assertEquals("Read status didn't match expected status.", PASSENGER_SIDE_STATUS, status);
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ VehicleDataEventStatus airbagStatus = msg.getDriverAirbagDeployed();
+ VehicleDataEventStatus curtainStatus = msg.getDriverCurtainAirbagDeployed();
+ VehicleDataEventStatus kneeStatus = msg.getDriverKneeAirbagDeployed();
+ VehicleDataEventStatus sideStatus = msg.getDriverSideAirbagDeployed();
+ VehicleDataEventStatus passengerStatus = msg.getPassengerAirbagDeployed();
+ VehicleDataEventStatus passengerCurtainStatus = msg.getPassengerCurtainAirbagDeployed();
+ VehicleDataEventStatus passengerKneeStatus = msg.getPassengerKneeAirbagDeployed();
+ VehicleDataEventStatus passengerSideStatus = msg.getPassengerSideAirbagDeployed();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, airbagStatus);
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, curtainStatus);
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, kneeStatus);
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, sideStatus);
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, passengerStatus);
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, passengerCurtainStatus);
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, passengerKneeStatus);
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, passengerSideStatus);
+
+ // Invalid/Null Tests
+ AirbagStatus msg = new AirbagStatus();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getDriverAirbagDeployed());
+ assertNull(Test.NULL, msg.getDriverSideAirbagDeployed());
+ assertNull(Test.NULL, msg.getDriverCurtainAirbagDeployed());
+ assertNull(Test.NULL, msg.getPassengerAirbagDeployed());
+ assertNull(Test.NULL, msg.getPassengerCurtainAirbagDeployed());
+ assertNull(Test.NULL, msg.getDriverKneeAirbagDeployed());
+ assertNull(Test.NULL, msg.getPassengerSideAirbagDeployed());
+ assertNull(Test.NULL, msg.getPassengerKneeAirbagDeployed());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(AirbagStatus.KEY_DRIVER_AIRBAG_DEPLOYED, DRIVER_STATUS);
- reference.put(AirbagStatus.KEY_DRIVER_CURTAIN_AIRBAG_DEPLOYED, DRIVER_CURTAIN_STATUS);
- reference.put(AirbagStatus.KEY_DRIVER_KNEE_AIRBAG_DEPLOYED, DRIVER_KNEE_STATUS);
- reference.put(AirbagStatus.KEY_DRIVER_SIDE_AIRBAG_DEPLOYED, DRIVER_SIDE_STATUS);
- reference.put(AirbagStatus.KEY_PASSENGER_AIRBAG_DEPLOYED, PASSENGER_STATUS);
- reference.put(AirbagStatus.KEY_PASSENGER_CURTAIN_AIRBAG_DEPLOYED, PASSENGER_CURTAIN_STATUS);
- reference.put(AirbagStatus.KEY_PASSENGER_KNEE_AIRBAG_DEPLOYED, PASSENGER_KNEE_STATUS);
- reference.put(AirbagStatus.KEY_PASSENGER_SIDE_AIRBAG_DEPLOYED, PASSENGER_SIDE_STATUS);
+ reference.put(AirbagStatus.KEY_DRIVER_AIRBAG_DEPLOYED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(AirbagStatus.KEY_DRIVER_CURTAIN_AIRBAG_DEPLOYED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(AirbagStatus.KEY_DRIVER_KNEE_AIRBAG_DEPLOYED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(AirbagStatus.KEY_DRIVER_SIDE_AIRBAG_DEPLOYED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(AirbagStatus.KEY_PASSENGER_AIRBAG_DEPLOYED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(AirbagStatus.KEY_PASSENGER_CURTAIN_AIRBAG_DEPLOYED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(AirbagStatus.KEY_PASSENGER_KNEE_AIRBAG_DEPLOYED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(AirbagStatus.KEY_PASSENGER_SIDE_AIRBAG_DEPLOYED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertEquals("JSON object didn't match reference for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
- }catch(JSONException e){
- /* do nothing */
- }
- }
-
- public void testNull(){
- AirbagStatus msg = new AirbagStatus();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Zone wasn't set for driver airbag but getter method returned an object.", msg.getDriverAirbagDeployed());
- assertNull("Zone wasn't set for driver side airbag but getter method returned an object.", msg.getDriverSideAirbagDeployed());
- assertNull("Zone wasn't set for driver curtain airbag but getter method returned an object.", msg.getDriverCurtainAirbagDeployed());
- assertNull("Zone wasn't set for passenger airbag but getter method returned an object.", msg.getPassengerAirbagDeployed());
- assertNull("Zone wasn't set for passenger curtain airbag but getter method returned an object.", msg.getPassengerCurtainAirbagDeployed());
- assertNull("Zone wasn't set for driver knee airbag but getter method returned an object.", msg.getDriverKneeAirbagDeployed());
- assertNull("Zone wasn't set for passenger side airbag but getter method returned an object.", msg.getPassengerSideAirbagDeployed());
- assertNull("Zone wasn't set for passenger knee airbag but getter method returned an object.", msg.getPassengerKneeAirbagDeployed());
- }
- //TODO: remove this method?
- /*
- public void testCopy(){
- AirbagStatus copy = new AirbagStatus(msg);
-
- assertNotSame("Object was not copied.", copy, msg);
- for(AirbagZone zone : EnumSet.allOf(AirbagZone.class)){
- assertEquals("Object data was not copied correctly.", copy.getAirbagStatus(zone), msg.getAirbagStatus(zone));
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
}
}
- */
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/AudioPassThruCapabilitiesTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/AudioPassThruCapabilitiesTest.java
index c714cf765..476898685 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/AudioPassThruCapabilitiesTest.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/AudioPassThruCapabilitiesTest.java
@@ -12,85 +12,67 @@ import com.smartdevicelink.proxy.rpc.enums.AudioType;
import com.smartdevicelink.proxy.rpc.enums.BitsPerSample;
import com.smartdevicelink.proxy.rpc.enums.SamplingRate;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.AudioPassThruCapabilities}
+ */
public class AudioPassThruCapabilitiesTest extends TestCase{
- private static final AudioType AUDIO_TYPE = AudioType.PCM;
- private static final BitsPerSample BITS_PER_SAMPLE = BitsPerSample._8_BIT;
- private static final SamplingRate SAMPLING_RATE = SamplingRate._16KHZ;
-
private AudioPassThruCapabilities msg;
@Override
public void setUp(){
msg = new AudioPassThruCapabilities();
- msg.setAudioType(AUDIO_TYPE);
- msg.setBitsPerSample(BITS_PER_SAMPLE);
- msg.setSamplingRate(SAMPLING_RATE);
- }
-
- public void testCreation(){
- assertNotNull("Object creation failed.", msg);
- }
-
- public void testAudioType(){
- AudioType copy = msg.getAudioType();
- assertEquals("Audio type didn't match expected audio type.", AUDIO_TYPE, copy);
+ assertNotNull(Test.NOT_NULL, msg);
+
+ msg.setAudioType(Test.GENERAL_AUDIOTYPE);
+ msg.setBitsPerSample(Test.GENERAL_BITSPERSAMPLE);
+ msg.setSamplingRate(Test.GENERAL_SAMPLINGRATE);
}
- public void testBitsPerSample(){
- BitsPerSample copy = msg.getBitsPerSample();
- assertEquals("Bits per sample didn't match expected bits per sample.", BITS_PER_SAMPLE, copy);
- }
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ SamplingRate samplingRate = msg.getSamplingRate();
+ BitsPerSample bitsPerSample = msg.getBitsPerSample();
+ AudioType audioType = msg.getAudioType();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_SAMPLINGRATE, samplingRate);
+ assertEquals(Test.MATCH, Test.GENERAL_BITSPERSAMPLE, bitsPerSample);
+ assertEquals(Test.MATCH, Test.GENERAL_AUDIOTYPE, audioType);
+
+ // Invalid/Null Tests
+ AudioPassThruCapabilities msg = new AudioPassThruCapabilities();
+ assertNotNull(Test.NOT_NULL, msg);
- public void testSamplingRate(){
- SamplingRate copy = msg.getSamplingRate();
- assertEquals("Sampling rate didn't match expected sampling rate.", SAMPLING_RATE, copy);
+ assertNull(Test.NULL, msg.getAudioType());
+ assertNull(Test.NULL, msg.getBitsPerSample());
+ assertNull(Test.NULL, msg.getSamplingRate());
}
-
+
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(AudioPassThruCapabilities.KEY_AUDIO_TYPE, AUDIO_TYPE);
- reference.put(AudioPassThruCapabilities.KEY_BITS_PER_SAMPLE, BITS_PER_SAMPLE);
- reference.put(AudioPassThruCapabilities.KEY_SAMPLING_RATE, SAMPLING_RATE);
+ reference.put(AudioPassThruCapabilities.KEY_AUDIO_TYPE, Test.GENERAL_AUDIOTYPE);
+ reference.put(AudioPassThruCapabilities.KEY_BITS_PER_SAMPLE, Test.GENERAL_BITSPERSAMPLE);
+ reference.put(AudioPassThruCapabilities.KEY_SAMPLING_RATE, Test.GENERAL_SAMPLINGRATE);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertEquals("", JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
- }catch(JSONException e){
- /* do nothing */
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- AudioPassThruCapabilities msg = new AudioPassThruCapabilities();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Audio type wasn't set, but getter method returned an object.", msg.getAudioType());
- assertNull("Bits per sample wasn't set, but getter method returned an object.", msg.getBitsPerSample());
- assertNull("Sampling rate wasn't set, but getter method returned an object.", msg.getSamplingRate());
- }
-
- //remove this method?
- /*
- public void testCopy(){
- AudioPassThruCapabilities copy = new AudioPassThruCapabilities(msg);
-
- assertNotSame("Object was not copied.", copy, msg);
-
- String error = "Object data was not copied correctly.";
- assertEquals(error, copy.getAudioType(), msg.getAudioType());
- assertEquals(error, copy.getBitsPerSample(), msg.getBitsPerSample());
- assertEquals(error, copy.getSamplingRate(), msg.getSamplingRate());
- }
- */
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/BeltStatusTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/BeltStatusTests.java
index 7ff72906c..5fb53ef3d 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/BeltStatusTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/BeltStatusTests.java
@@ -10,182 +10,128 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.BeltStatus;
import com.smartdevicelink.proxy.rpc.enums.VehicleDataEventStatus;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.BeltStatus}
+ */
public class BeltStatusTests extends TestCase{
-
- private static final VehicleDataEventStatus LEFT_REAR_INFLATABLE_BELTED = VehicleDataEventStatus.YES;
- private static final VehicleDataEventStatus RIGHT_REAR_INFLATABLE_BELTED = VehicleDataEventStatus.YES;
- private static final VehicleDataEventStatus PASSENGER_CHILD_DETECTED = VehicleDataEventStatus.NO;
- private static final VehicleDataEventStatus DRIVER_STATUS = VehicleDataEventStatus.YES;
- private static final VehicleDataEventStatus PASSENGER_STATUS = VehicleDataEventStatus.YES;
- private static final VehicleDataEventStatus ROW2_RIGHT_STATUS = VehicleDataEventStatus.FAULT;
- private static final VehicleDataEventStatus ROW1_MIDDLE_STATUS = VehicleDataEventStatus.FAULT;
- private static final VehicleDataEventStatus OTHER_STATUS = VehicleDataEventStatus.NO;
-
- private static final String STATUS_ASSERT_FAILED_MSG = "Input status did not match expected status.";
-
+
private BeltStatus msg;
@Override
protected void setUp() throws Exception{
msg = new BeltStatus();
- msg.setLeftRearInflatableBelted(LEFT_REAR_INFLATABLE_BELTED);
- msg.setPassengerChildDetected(PASSENGER_CHILD_DETECTED);
- msg.setRightRearInflatableBelted(RIGHT_REAR_INFLATABLE_BELTED);
-
- msg.setDriverBuckleBelted(DRIVER_STATUS);
- msg.setPassengerBuckleBelted(PASSENGER_STATUS);
- msg.setRightRow2BuckleBelted(ROW2_RIGHT_STATUS);
- msg.setDriverBeltDeployed(DRIVER_STATUS);
- msg.setPassengerBeltDeployed(PASSENGER_STATUS);
+ assertNotNull(Test.NOT_NULL, msg);
- //TODO: closest set method found for row 2 belt deployed
- msg.setMiddleRow1BuckleBelted(ROW1_MIDDLE_STATUS);
- msg.setMiddleRow1BeltDeployed(ROW1_MIDDLE_STATUS);
-
- msg.setLeftRow2BuckleBelted(OTHER_STATUS);
- msg.setMiddleRow2BuckleBelted(OTHER_STATUS);
- msg.setMiddleRow3BuckleBelted(OTHER_STATUS);
- msg.setLeftRow3BuckleBelted(OTHER_STATUS);
- msg.setRightRow3BuckleBelted(OTHER_STATUS);
- }
-
- public void testCreation(){
- assertNotNull("Object creation failed.", msg);
- }
-
- public void testLeftRearInflatableBelted(){
- VehicleDataEventStatus copy = msg.getLeftRearInflatableBelted();
- assertEquals(STATUS_ASSERT_FAILED_MSG, LEFT_REAR_INFLATABLE_BELTED, copy);
- }
-
- public void testRightRearInflatableBelted(){
- VehicleDataEventStatus copy = msg.getRightRearInflatableBelted();
- assertEquals(STATUS_ASSERT_FAILED_MSG, RIGHT_REAR_INFLATABLE_BELTED, copy);
- }
-
- public void testPassengerChildDetected(){
- VehicleDataEventStatus copy = msg.getPassengerChildDetected();
- assertEquals(STATUS_ASSERT_FAILED_MSG, PASSENGER_CHILD_DETECTED, copy);
- }
-
- public void testZoneBeltBuckleStatus(){
- VehicleDataEventStatus copy = msg.getDriverBuckleBelted();
- assertEquals(STATUS_ASSERT_FAILED_MSG, DRIVER_STATUS, copy);
- copy = msg.getPassengerBuckleBelted();
- assertEquals(STATUS_ASSERT_FAILED_MSG, PASSENGER_STATUS, copy);
- copy = msg.getRightRow2BuckleBelted();
- assertEquals(STATUS_ASSERT_FAILED_MSG, ROW2_RIGHT_STATUS, copy);
- copy = msg.getMiddleRow1BuckleBelted();
- assertEquals(STATUS_ASSERT_FAILED_MSG, ROW1_MIDDLE_STATUS, copy);
- copy = msg.getLeftRow2BuckleBelted();
- assertEquals(STATUS_ASSERT_FAILED_MSG, OTHER_STATUS, copy);
- copy = msg.getMiddleRow2BuckleBelted();
- assertEquals(STATUS_ASSERT_FAILED_MSG, OTHER_STATUS, copy);
- copy = msg.getMiddleRow3BuckleBelted();
- assertEquals(STATUS_ASSERT_FAILED_MSG, OTHER_STATUS, copy);
- copy = msg.getLeftRow3BuckleBelted();
- assertEquals(STATUS_ASSERT_FAILED_MSG, OTHER_STATUS, copy);
- copy = msg.getRightRow3BuckleBelted();
- assertEquals(STATUS_ASSERT_FAILED_MSG, OTHER_STATUS, copy);
+ msg.setLeftRearInflatableBelted(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setPassengerChildDetected(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setRightRearInflatableBelted(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setDriverBuckleBelted(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setPassengerBuckleBelted(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setRightRow2BuckleBelted(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setDriverBeltDeployed(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setPassengerBeltDeployed(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setMiddleRow1BuckleBelted(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setMiddleRow1BeltDeployed(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setLeftRow2BuckleBelted(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setMiddleRow2BuckleBelted(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setMiddleRow3BuckleBelted(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setLeftRow3BuckleBelted(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setRightRow3BuckleBelted(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
}
- public void testZoneBeltDeployStatus(){
- VehicleDataEventStatus copy = msg.getDriverBeltDeployed();
- assertEquals(STATUS_ASSERT_FAILED_MSG, DRIVER_STATUS, copy);
- copy = msg.getPassengerBeltDeployed();
- assertEquals(STATUS_ASSERT_FAILED_MSG, PASSENGER_STATUS, copy);
- copy = msg.getMiddleRow1BeltDeployed();
- assertEquals(STATUS_ASSERT_FAILED_MSG, ROW1_MIDDLE_STATUS, copy);
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Valid Tests
+ VehicleDataEventStatus leftRearInflatable = msg.getLeftRearInflatableBelted();
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, leftRearInflatable);
+
+ VehicleDataEventStatus rightRearInflatable = msg.getRightRearInflatableBelted();
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, rightRearInflatable);
+
+ VehicleDataEventStatus passengerChild = msg.getPassengerChildDetected();
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, passengerChild);
+
+ VehicleDataEventStatus driverBuckled = msg.getDriverBuckleBelted();
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, driverBuckled);
+ driverBuckled = msg.getPassengerBuckleBelted();
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, driverBuckled);
+ driverBuckled = msg.getRightRow2BuckleBelted();
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, driverBuckled);
+ driverBuckled = msg.getMiddleRow1BuckleBelted();
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, driverBuckled);
+ driverBuckled = msg.getLeftRow2BuckleBelted();
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, driverBuckled);
+ driverBuckled = msg.getMiddleRow2BuckleBelted();
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, driverBuckled);
+ driverBuckled = msg.getMiddleRow3BuckleBelted();
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, driverBuckled);
+ driverBuckled = msg.getLeftRow3BuckleBelted();
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, driverBuckled);
+ driverBuckled = msg.getRightRow3BuckleBelted();
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, driverBuckled);
+
+ VehicleDataEventStatus driverBeltDeployed = msg.getDriverBeltDeployed();
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, driverBeltDeployed);
+ driverBeltDeployed = msg.getPassengerBeltDeployed();
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, driverBeltDeployed);
+ driverBeltDeployed = msg.getMiddleRow1BeltDeployed();
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, driverBeltDeployed);
+
+ // Invalid/Null Tests
+ BeltStatus msg = new BeltStatus();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getLeftRearInflatableBelted());
+ assertNull(Test.NULL, msg.getRightRearInflatableBelted());
+ assertNull(Test.NULL, msg.getPassengerChildDetected());
+ assertNull(Test.NULL, msg.getDriverBuckleBelted());
+ assertNull(Test.NULL, msg.getPassengerBuckleBelted());
+ assertNull(Test.NULL, msg.getRightRow2BuckleBelted());
+ assertNull(Test.NULL, msg.getMiddleRow1BuckleBelted());
+ assertNull(Test.NULL, msg.getLeftRow2BuckleBelted());
+ assertNull(Test.NULL, msg.getMiddleRow2BuckleBelted());
+ assertNull(Test.NULL, msg.getMiddleRow3BuckleBelted());
+ assertNull(Test.NULL, msg.getLeftRow3BuckleBelted());
+ assertNull(Test.NULL, msg.getRightRow3BuckleBelted());
+ assertNull(Test.NULL, msg.getPassengerBeltDeployed());
+ assertNull(Test.NULL, msg.getMiddleRow1BeltDeployed());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(BeltStatus.KEY_PASSENGER_CHILD_DETECTED, PASSENGER_CHILD_DETECTED);
- reference.put(BeltStatus.KEY_REAR_INFLATABLE_BELTED, LEFT_REAR_INFLATABLE_BELTED);
- reference.put(BeltStatus.KEY_RIGHT_REAR_INFLATABLE_BELTED, RIGHT_REAR_INFLATABLE_BELTED);
-
- reference.put(BeltStatus.KEY_DRIVER_BELT_DEPLOYED, DRIVER_STATUS);
- reference.put(BeltStatus.KEY_DRIVER_BUCKLE_BELTED, DRIVER_STATUS);
- reference.put(BeltStatus.KEY_PASSENGER_BELT_DEPLOYED, PASSENGER_STATUS);
- reference.put(BeltStatus.KEY_PASSENGER_BUCKLE_BELTED, PASSENGER_STATUS);
- reference.put(BeltStatus.KEY_LEFT_ROW_2_BUCKLE_BELTED, OTHER_STATUS);
- reference.put(BeltStatus.KEY_RIGHT_ROW_2_BUCKLE_BELTED, ROW2_RIGHT_STATUS);
- reference.put(BeltStatus.KEY_MIDDLE_ROW_2_BUCKLE_BELTED, OTHER_STATUS);
- reference.put(BeltStatus.KEY_MIDDLE_ROW_3_BUCKLE_BELTED, OTHER_STATUS);
- reference.put(BeltStatus.KEY_LEFT_ROW_3_BUCKLE_BELTED, OTHER_STATUS);
- reference.put(BeltStatus.KEY_RIGHT_ROW_3_BUCKLE_BELTED, OTHER_STATUS);
- reference.put(BeltStatus.KEY_MIDDLE_ROW_1_BELT_DEPLOYED, ROW1_MIDDLE_STATUS);
- reference.put(BeltStatus.KEY_MIDDLE_ROW_1_BUCKLE_BELTED, ROW1_MIDDLE_STATUS);
-
- JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ reference.put(BeltStatus.KEY_PASSENGER_CHILD_DETECTED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(BeltStatus.KEY_REAR_INFLATABLE_BELTED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(BeltStatus.KEY_RIGHT_REAR_INFLATABLE_BELTED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(BeltStatus.KEY_DRIVER_BELT_DEPLOYED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(BeltStatus.KEY_DRIVER_BUCKLE_BELTED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(BeltStatus.KEY_PASSENGER_BELT_DEPLOYED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(BeltStatus.KEY_PASSENGER_BUCKLE_BELTED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(BeltStatus.KEY_LEFT_ROW_2_BUCKLE_BELTED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(BeltStatus.KEY_RIGHT_ROW_2_BUCKLE_BELTED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(BeltStatus.KEY_MIDDLE_ROW_2_BUCKLE_BELTED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(BeltStatus.KEY_MIDDLE_ROW_3_BUCKLE_BELTED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(BeltStatus.KEY_LEFT_ROW_3_BUCKLE_BELTED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(BeltStatus.KEY_RIGHT_ROW_3_BUCKLE_BELTED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(BeltStatus.KEY_MIDDLE_ROW_1_BELT_DEPLOYED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(BeltStatus.KEY_MIDDLE_ROW_1_BUCKLE_BELTED, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertEquals("JSON value didn't match reference for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}catch(JSONException e){
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- BeltStatus msg = new BeltStatus();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Left-rear inflatable belted wasn't set, but getter method returned an object.",
- msg.getLeftRearInflatableBelted());
- assertNull("Right-rear inflatable belted wasn't set, but getter method returned an object.",
- msg.getRightRearInflatableBelted());
- assertNull("Passenger child detected wasn't set, but getter method returned an object.",
- msg.getPassengerChildDetected());
- assertNull("Driver belt buckle status wasn't set, but getter method returned an object.",
- msg.getDriverBuckleBelted());
- assertNull("Passenger belt buckle status wasn't set, but getter method returned an object.",
- msg.getPassengerBuckleBelted());
- assertNull("Right row 2 belt buckle status wasn't set, but getter method returned an object.",
- msg.getRightRow2BuckleBelted());
- assertNull("Middle row 1 belt buckle status wasn't set, but getter method returned an object.",
- msg.getMiddleRow1BuckleBelted());
- assertNull("Left row 2 belt buckle status wasn't set, but getter method returned an object.",
- msg.getLeftRow2BuckleBelted());
- assertNull("Middle row 2 belt buckle status wasn't set, but getter method returned an object.",
- msg.getMiddleRow2BuckleBelted());
- assertNull("Middle row 3 belt buckle status wasn't set, but getter method returned an object.",
- msg.getMiddleRow3BuckleBelted());
- assertNull("Left row 3 belt buckle status wasn't set, but getter method returned an object.",
- msg.getLeftRow3BuckleBelted());
- assertNull("Right row 3 belt buckle status wasn't set, but getter method returned an object.",
- msg.getRightRow3BuckleBelted());
- assertNull("Passenger belt buckle deployed wasn't set, but getter method returned an object.",
- msg.getPassengerBeltDeployed());
- assertNull("Middle row 1 belt buckle deployed wasn't set, but getter method returned an object.",
- msg.getMiddleRow1BeltDeployed());
- }
-
- //TODO: remove this method?
- /*
- public void testCopy(){
- BeltStatus copy = new BeltStatus(msg);
-
- assertNotSame("Object was not copied.", copy, msg);
-
- String error = "Object data was not copied correctly.";
- for(SeatZone zone : EnumSet.allOf(SeatZone.class)){
- assertEquals(error, copy.getZoneBeltBuckleStatus(zone), msg.getZoneBeltBuckleStatus(zone));
- assertEquals(error, copy.getZoneBeltDeployedStatus(zone), msg.getZoneBeltDeployedStatus(zone));
- }
-
- assertEquals(error, copy.getLeftRearInflatableBelted(), msg.getLeftRearInflatableBelted());
- assertEquals(error, copy.getRightRearInflatableBelted(), msg.getRightRearInflatableBelted());
- assertEquals(error, copy.getPassengerChildDetected(), msg.getPassengerChildDetected());
- }
- */
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/BodyInformationTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/BodyInformationTests.java
index f042cb498..245ee7ec8 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/BodyInformationTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/BodyInformationTests.java
@@ -11,110 +11,83 @@ import com.smartdevicelink.proxy.rpc.BodyInformation;
import com.smartdevicelink.proxy.rpc.enums.IgnitionStableStatus;
import com.smartdevicelink.proxy.rpc.enums.IgnitionStatus;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.BodyInformation}
+ */
public class BodyInformationTests extends TestCase{
-
- private static final boolean PARK_BRAKE_ACTIVE = true;
- private static final IgnitionStatus IGNITION_STATUS = IgnitionStatus.RUN;
- private static final IgnitionStableStatus IGNITION_STABLE_STATUS = IgnitionStableStatus.IGNITION_SWITCH_STABLE;
- private static final boolean DRIVER_DOOR_AJAR_STATUS = true;
- private static final boolean OTHER_DOOR_AJAR_STATUS = false;
- private static final String STATUS_ASSERT_FAILED_MSG = "Input status did not match expected status.";
-
+
private BodyInformation msg;
@Override
public void setUp(){
msg = new BodyInformation();
- msg.setParkBrakeActive(PARK_BRAKE_ACTIVE);
- msg.setIgnitionStatus(IGNITION_STATUS);
- msg.setIgnitionStableStatus(IGNITION_STABLE_STATUS);
-
- msg.setDriverDoorAjar(DRIVER_DOOR_AJAR_STATUS);
- msg.setPassengerDoorAjar(OTHER_DOOR_AJAR_STATUS);
- msg.setRearLeftDoorAjar(OTHER_DOOR_AJAR_STATUS);
- msg.setRearRightDoorAjar(OTHER_DOOR_AJAR_STATUS);
- }
-
- public void testParkBrakeActive(){
- boolean copy = msg.getParkBrakeActive();
- assertEquals("Input value didn't match expected value.", PARK_BRAKE_ACTIVE, copy);
- }
-
- public void testIgnitionStatus(){
- IgnitionStatus copy = msg.getIgnitionStatus();
- assertEquals("Input status didn't match expected status.", IGNITION_STATUS, copy);
- }
-
- public void testIgnitionStableStatus(){
- IgnitionStableStatus copy = msg.getIgnitionStableStatus();
- assertEquals("Input status didn't match expected status.", IGNITION_STABLE_STATUS, copy);
+ msg.setParkBrakeActive(Test.GENERAL_BOOLEAN);
+ msg.setIgnitionStatus(Test.GENERAL_IGNITIONSTATUS);
+ msg.setIgnitionStableStatus(Test.GENERAL_IGNITIONSTABLESTATUS);
+
+ msg.setDriverDoorAjar(Test.GENERAL_BOOLEAN);
+ msg.setPassengerDoorAjar(Test.GENERAL_BOOLEAN);
+ msg.setRearLeftDoorAjar(Test.GENERAL_BOOLEAN);
+ msg.setRearRightDoorAjar(Test.GENERAL_BOOLEAN);
}
- public void testDoorAjar(){
- assertEquals(STATUS_ASSERT_FAILED_MSG, DRIVER_DOOR_AJAR_STATUS, (boolean) msg.getDriverDoorAjar());
- assertEquals(STATUS_ASSERT_FAILED_MSG, OTHER_DOOR_AJAR_STATUS, (boolean) msg.getPassengerDoorAjar());
- assertEquals(STATUS_ASSERT_FAILED_MSG, OTHER_DOOR_AJAR_STATUS, (boolean) msg.getRearLeftDoorAjar());
- assertEquals(STATUS_ASSERT_FAILED_MSG, OTHER_DOOR_AJAR_STATUS, (boolean) msg.getRearRightDoorAjar());
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ boolean parkBrake = msg.getParkBrakeActive();
+ IgnitionStatus ignitionStatus = msg.getIgnitionStatus();
+ IgnitionStableStatus ignitionStable = msg.getIgnitionStableStatus();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, parkBrake);
+ assertEquals(Test.MATCH, Test.GENERAL_IGNITIONSTATUS, ignitionStatus);
+ assertEquals(Test.MATCH, Test.GENERAL_IGNITIONSTABLESTATUS, ignitionStable);
+
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, (boolean) msg.getDriverDoorAjar());
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, (boolean) msg.getPassengerDoorAjar());
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, (boolean) msg.getRearLeftDoorAjar());
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, (boolean) msg.getRearRightDoorAjar());
+
+ // Invalid/Null Tests
+ BodyInformation msg = new BodyInformation();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getParkBrakeActive());
+ assertNull(Test.NULL, msg.getIgnitionStatus());
+ assertNull(Test.NULL, msg.getIgnitionStatus());
+ assertNull(Test.NULL, msg.getDriverDoorAjar());
+ assertNull(Test.NULL, msg.getPassengerDoorAjar());
+ assertNull(Test.NULL, msg.getRearLeftDoorAjar());
+ assertNull(Test.NULL, msg.getRearRightDoorAjar());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(BodyInformation.KEY_PARK_BRAKE_ACTIVE, PARK_BRAKE_ACTIVE);
- reference.put(BodyInformation.KEY_IGNITION_STATUS, IGNITION_STATUS);
- reference.put(BodyInformation.KEY_IGNITION_STABLE_STATUS, IGNITION_STABLE_STATUS);
- reference.put(BodyInformation.KEY_DRIVER_DOOR_AJAR, DRIVER_DOOR_AJAR_STATUS);
- reference.put(BodyInformation.KEY_PASSENGER_DOOR_AJAR, OTHER_DOOR_AJAR_STATUS);
- reference.put(BodyInformation.KEY_REAR_LEFT_DOOR_AJAR, OTHER_DOOR_AJAR_STATUS);
- reference.put(BodyInformation.KEY_REAR_RIGHT_DOOR_AJAR, OTHER_DOOR_AJAR_STATUS);
+ reference.put(BodyInformation.KEY_PARK_BRAKE_ACTIVE, Test.GENERAL_BOOLEAN);
+ reference.put(BodyInformation.KEY_IGNITION_STATUS, Test.GENERAL_IGNITIONSTATUS);
+ reference.put(BodyInformation.KEY_IGNITION_STABLE_STATUS, Test.GENERAL_IGNITIONSTABLESTATUS);
+ reference.put(BodyInformation.KEY_DRIVER_DOOR_AJAR, Test.GENERAL_BOOLEAN);
+ reference.put(BodyInformation.KEY_PASSENGER_DOOR_AJAR, Test.GENERAL_BOOLEAN);
+ reference.put(BodyInformation.KEY_REAR_LEFT_DOOR_AJAR, Test.GENERAL_BOOLEAN);
+ reference.put(BodyInformation.KEY_REAR_RIGHT_DOOR_AJAR, Test.GENERAL_BOOLEAN);
- JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}catch(JSONException e){
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- BodyInformation msg = new BodyInformation();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Park brake active wasn't set, but getter method returned an object.", msg.getParkBrakeActive());
- assertNull("Ignition status wasn't set, but getter method returned an object.", msg.getIgnitionStatus());
- assertNull("Ignition stable status wasn't set, but getter method returned an object.", msg.getIgnitionStatus());
-
- assertNull("Driver door ajar wasn't set, but getter method returned an object.", msg.getDriverDoorAjar());
- assertNull("Passenger door ajar wasn't set, but getter method returned an object.", msg.getPassengerDoorAjar());
- assertNull("Rear left door ajar wasn't set, but getter method returned an object.", msg.getRearLeftDoorAjar());
- assertNull("Rear right door ajar wasn't set, but getter method returned an object.", msg.getRearRightDoorAjar());
-
- }
- //TODO: remove this method?
- /*
- public void testCopy(){
- BodyInformation copy = new BodyInformation(msg);
-
- assertNotSame("Object was not copied.", copy, msg);
-
- String error = "Object data was not copied correctly.";
- for(DoorZone zone : EnumSet.allOf(DoorZone.class)){
- assertEquals(error, copy.getDoorAjar(zone), msg.getDoorAjar(zone));
- }
-
- assertEquals(error, copy.getParkBrakeActive(), msg.getParkBrakeActive());
- assertEquals(error, copy.getIgnitionStatus(), msg.getIgnitionStatus());
- assertEquals(error, copy.getIgnitionStableStatus(), msg.getIgnitionStableStatus());
- }
- */
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ButtonCapabilitiesTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ButtonCapabilitiesTests.java
index a03336809..b8001dc2c 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ButtonCapabilitiesTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ButtonCapabilitiesTests.java
@@ -10,95 +10,73 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.ButtonCapabilities;
import com.smartdevicelink.proxy.rpc.enums.ButtonName;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.ButtonCapabilities}
+ */
public class ButtonCapabilitiesTests extends TestCase{
- private static final boolean SHORT_PRESS_AVAILABLE = true;
- private static final boolean LONG_PRESS_AVAILABLE = true;
- private static final boolean UP_DOWN_AVAILABLE = true;
- private static final ButtonName BUTTON_NAME = ButtonName.OK;
-
- private ButtonCapabilities msg;
+ private ButtonCapabilities msg;
@Override
public void setUp(){
msg = new ButtonCapabilities();
- msg.setLongPressAvailable(LONG_PRESS_AVAILABLE);
- msg.setName(BUTTON_NAME);
- msg.setShortPressAvailable(SHORT_PRESS_AVAILABLE);
- msg.setUpDownAvailable(UP_DOWN_AVAILABLE);
- }
-
- public void testShortPressAvailable(){
- boolean copy = msg.getShortPressAvailable();
- assertEquals("Input value didn't match expected value.", SHORT_PRESS_AVAILABLE, copy);
+ msg.setLongPressAvailable(Test.GENERAL_BOOLEAN);
+ msg.setName(Test.GENERAL_BUTTONNAME);
+ msg.setShortPressAvailable(Test.GENERAL_BOOLEAN);
+ msg.setUpDownAvailable(Test.GENERAL_BOOLEAN);
}
- public void testLongPressAvailable(){
- boolean copy = msg.getLongPressAvailable();
- assertEquals("Input value didn't match expected value.", LONG_PRESS_AVAILABLE, copy);
- }
- public void testUpDownAvailable(){
- boolean copy = msg.getUpDownAvailable();
- assertEquals("Input value didn't match expected value.", UP_DOWN_AVAILABLE, copy);
- }
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ boolean shortPress = msg.getShortPressAvailable();
+ boolean longPress = msg.getLongPressAvailable();
+ boolean upDown = msg.getUpDownAvailable();
+ ButtonName buttonName = msg.getName();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, shortPress);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, longPress);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, upDown);
+ assertEquals(Test.MATCH, Test.GENERAL_BUTTONNAME, buttonName);
+
+ // Invalid/Null Tests
+ ButtonCapabilities msg = new ButtonCapabilities();
+ assertNotNull(Test.NOT_NULL, msg);
- public void testButtonName(){
- ButtonName copy = msg.getName();
- assertEquals("Input value didn't match expected value.", BUTTON_NAME, copy);
+ assertNull(Test.NULL, msg.getShortPressAvailable());
+ assertNull(Test.NULL, msg.getLongPressAvailable());
+ assertNull(Test.NULL, msg.getUpDownAvailable());
+ assertNull(Test.NULL, msg.getName());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(ButtonCapabilities.KEY_SHORT_PRESS_AVAILABLE, SHORT_PRESS_AVAILABLE);
- reference.put(ButtonCapabilities.KEY_LONG_PRESS_AVAILABLE, LONG_PRESS_AVAILABLE);
- reference.put(ButtonCapabilities.KEY_UP_DOWN_AVAILABLE, UP_DOWN_AVAILABLE);
- reference.put(ButtonCapabilities.KEY_NAME, BUTTON_NAME);
+ reference.put(ButtonCapabilities.KEY_SHORT_PRESS_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(ButtonCapabilities.KEY_LONG_PRESS_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(ButtonCapabilities.KEY_UP_DOWN_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(ButtonCapabilities.KEY_NAME, Test.GENERAL_BUTTONNAME);
JSONObject underTest = msg.serializeJSON();
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
- }catch(JSONException e){
- /* do nothing */
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
}
- }
-
- public void testNull(){
- ButtonCapabilities msg = new ButtonCapabilities();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Short press available wasn't set, but getter method returned an object.",
- msg.getShortPressAvailable());
- assertNull("Long press available wasn't set, but getter method returned an object.",
- msg.getLongPressAvailable());
- assertNull("Up/down available wasn't set, but getter method returned an object.", msg.getUpDownAvailable());
- assertNull("Button name wasn't set, but getter method returned an object.", msg.getName());
- }
-
- //TODO: remove testCopy()?
- /*
- public void testCopy(){
- ButtonCapabilities copy = new ButtonCapabilities(msg);
-
- assertNotSame("Object was not copied.", copy, msg);
-
- String error = "Object data was not copied correctly.";
- assertEquals(error, copy.getShortPressAvailable(), msg.getShortPressAvailable());
- assertEquals(error, copy.getLongPressAvailable(), msg.getLongPressAvailable());
- assertEquals(error, copy.getUpDownAvailable(), msg.getUpDownAvailable());
- assertEquals(error, copy.getName(), msg.getName());
- }
- */
-}
+ }
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ChoiceTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ChoiceTests.java
index 41339a7fc..7bb236da0 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ChoiceTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ChoiceTests.java
@@ -1,6 +1,5 @@
package com.smartdevicelink.test.rpc.datatypes;
-import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
@@ -13,159 +12,102 @@ import org.json.JSONObject;
import com.smartdevicelink.marshal.JsonRPCMarshaller;
import com.smartdevicelink.proxy.rpc.Choice;
import com.smartdevicelink.proxy.rpc.Image;
-import com.smartdevicelink.proxy.rpc.enums.ImageType;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
import com.smartdevicelink.test.Validator;
-
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.Choice}
+ */
public class ChoiceTests extends TestCase{
-
- //private static final String TAG = "ChoiceTests";
-
- private static final ImageType IMAGE_TYPE = ImageType.DYNAMIC;
- private static final String IMAGE_NAME = "image1.png";
- private static final ImageType IMAGE2_TYPE = ImageType.DYNAMIC;
- private static final String IMAGE2_NAME = "image2.png";
- private static final String VR_COMMAND1 = "Say a command";
- private static final String VR_COMMAND2 = "Voice Rec";
- private static final String VR_COMMAND3 = "PERFORM COMMAND";
- private static final int CHOICE_ID = 16135;
- private static final String MENU_NAME = "Choice Line #1";
- private static final String SECONDARY_TEXT = "Choice Line #2";
- private static final String TERTIARY_TEXT = "Choice Line #3";
-
- private Choice msg;
-
- private Image image1, image2;
- private List<String> vrCommands;
+
+ private Choice msg;
@Override
public void setUp(){
msg = new Choice();
- image1 = new Image();
- image1.setImageType(IMAGE_TYPE);
- image1.setValue(IMAGE_NAME);
-
- image2 = new Image();
- image2.setImageType(IMAGE2_TYPE);
- image2.setValue(IMAGE2_NAME);
-
- vrCommands = new ArrayList<String>(3);
- vrCommands.add(VR_COMMAND1);
- vrCommands.add(VR_COMMAND2);
- vrCommands.add(VR_COMMAND3);
-
- msg.setChoiceID(CHOICE_ID);
- msg.setMenuName(MENU_NAME);
- msg.setImage(image1);
- msg.setSecondaryImage(image2);
- msg.setSecondaryText(SECONDARY_TEXT);
- msg.setTertiaryText(TERTIARY_TEXT);
- msg.setVrCommands(vrCommands);
+ msg.setChoiceID(Test.GENERAL_INT);
+ msg.setMenuName(Test.GENERAL_STRING);
+ msg.setImage(Test.GENERAL_IMAGE);
+ msg.setSecondaryImage(Test.GENERAL_IMAGE);
+ msg.setSecondaryText(Test.GENERAL_STRING);
+ msg.setTertiaryText(Test.GENERAL_STRING);
+ msg.setVrCommands(Test.GENERAL_STRING_LIST);
}
- public void testImage1(){
- Image copy = msg.getImage();
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ String text3 = msg.getTertiaryText();
+ String text2 = msg.getSecondaryText();
+ String menuName = msg.getMenuName();
+ int choiceId = msg.getChoiceID();
+ List<String> vrCommands = msg.getVrCommands();
+ Image image2 = msg.getSecondaryImage();
+ Image image = msg.getImage();
- assertTrue("Input value didn't match expected value.", Validator.validateImage(image1, copy));
- }
-
- public void testImage2(){
- Image copy = msg.getSecondaryImage();
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, text3);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, text2);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, menuName);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, choiceId);
+ assertTrue(Test.TRUE, Validator.validateStringList(vrCommands, vrCommands));
+ assertTrue(Test.TRUE, Validator.validateImage(image2, image2));
+ assertTrue(Test.TRUE, Validator.validateImage(image, image));
- assertTrue("Input value didn't match expected value.", Validator.validateImage(image2, copy));
- }
-
- public void testVrCommands(){
- List<String> copy = msg.getVrCommands();
- assertTrue("Input value didn't match expected value.", Validator.validateStringList(vrCommands, copy));
- }
-
- public void testChoiceID(){
- int copy = msg.getChoiceID();
- assertEquals("Input value didn't match expected value.", CHOICE_ID, copy);
- }
-
- public void testMenuName(){
- String copy = msg.getMenuName();
- assertEquals("Input value didn't match expected value.", MENU_NAME, copy);
- }
-
- public void testSecondaryText(){
- String copy = msg.getSecondaryText();
- assertEquals("Input value didn't match expected value.", SECONDARY_TEXT, copy);
- }
-
- public void testTertiaryText(){
- String copy = msg.getTertiaryText();
- assertEquals("Input value didn't match expected value.", TERTIARY_TEXT, copy);
+ // Invalid/Null Tests
+ Choice msg = new Choice();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getChoiceID());
+ assertNull(Test.NULL, msg.getImage());
+ assertNull(Test.NULL, msg.getSecondaryImage());
+ assertNull(Test.NULL, msg.getMenuName());
+ assertNull(Test.NULL, msg.getSecondaryText());
+ assertNull(Test.NULL, msg.getTertiaryText());
+ assertNull(Test.NULL, msg.getVrCommands());
}
public void testJson(){
JSONObject reference = new JSONObject();
- JSONObject image1 = new JSONObject(), image2 = new JSONObject();
try{
- image1.put(Image.KEY_IMAGE_TYPE, IMAGE_TYPE);
- image1.put(Image.KEY_VALUE, IMAGE_NAME);
-
- image2.put(Image.KEY_IMAGE_TYPE, IMAGE2_TYPE);
- image2.put(Image.KEY_VALUE, IMAGE2_NAME);
-
- reference.put(Choice.KEY_CHOICE_ID, CHOICE_ID);
- reference.put(Choice.KEY_MENU_NAME, MENU_NAME);
- reference.put(Choice.KEY_SECONDARY_TEXT, SECONDARY_TEXT);
- reference.put(Choice.KEY_TERTIARY_TEXT, TERTIARY_TEXT);
- reference.put(Choice.KEY_IMAGE, image1);
- reference.put(Choice.KEY_SECONDARY_IMAGE, image2);
- reference.put(Choice.KEY_VR_COMMANDS, JsonUtils.createJsonArray(vrCommands));
+ reference.put(Choice.KEY_CHOICE_ID, Test.GENERAL_INT);
+ reference.put(Choice.KEY_MENU_NAME, Test.GENERAL_STRING);
+ reference.put(Choice.KEY_SECONDARY_TEXT, Test.GENERAL_STRING);
+ reference.put(Choice.KEY_TERTIARY_TEXT, Test.GENERAL_STRING);
+ reference.put(Choice.KEY_IMAGE, Test.JSON_IMAGE);
+ reference.put(Choice.KEY_SECONDARY_IMAGE, Test.JSON_IMAGE);
+ reference.put(Choice.KEY_VR_COMMANDS, JsonUtils.createJsonArray(Test.GENERAL_STRING_LIST));
- //log("reference object created: " + reference.toString());
-
JSONObject underTest = msg.serializeJSON();
- //log("object under test created: " + underTest.toString());
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
if(key.equals(Choice.KEY_VR_COMMANDS)){
- assertTrue("JSON value didn't match expected value for key \"" + key + "\"",
+ assertTrue(Test.TRUE,
Validator.validateStringList(JsonUtils.readStringListFromJsonObject(reference, key),
JsonUtils.readStringListFromJsonObject(underTest, key)));
- }
- else if(key.equals(Choice.KEY_IMAGE) || key.equals(Choice.KEY_SECONDARY_IMAGE)){
+ } else if(key.equals(Choice.KEY_IMAGE) || key.equals(Choice.KEY_SECONDARY_IMAGE)){
JSONObject objectEquals = JsonUtils.readJsonObjectFromJsonObject(reference, key);
JSONObject testEquals = JsonUtils.readJsonObjectFromJsonObject(underTest, key);
Hashtable<String, Object> hashReference = JsonRPCMarshaller.deserializeJSONObject(objectEquals);
Hashtable<String, Object> hashTest = JsonRPCMarshaller.deserializeJSONObject(testEquals);
- assertTrue("JSON value didn't match expected value for key \"" + key + "\"",
- Validator.validateImage(new Image(hashReference), new Image(hashTest)));
- }
- else{
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertTrue(Test.TRUE, Validator.validateImage(new Image(hashReference), new Image(hashTest)));
+ } else{
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}
- }catch(JSONException e){
- /* do nothing */
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- Choice msg = new Choice();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Choice ID wasn't set, but getter method returned an object.", msg.getChoiceID());
- assertNull("Image wasn't set, but getter method returned an object.", msg.getImage());
- assertNull("Secondary image wasn't set, but getter method returned an object.", msg.getSecondaryImage());
- assertNull("Menu name wasn't set, but getter method returned an object.", msg.getMenuName());
- assertNull("Secondary text wasn't set, but getter method returned an object.", msg.getSecondaryText());
- assertNull("Tertiary text wasn't set, but getter method returned an object.", msg.getTertiaryText());
- assertNull("VR commands weren't set, but getter method returned an object.", msg.getVrCommands());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ClusterModeStatusTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ClusterModeStatusTests.java
index defa6166b..883b456fa 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ClusterModeStatusTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ClusterModeStatusTests.java
@@ -12,94 +12,71 @@ import com.smartdevicelink.proxy.rpc.enums.CarModeStatus;
import com.smartdevicelink.proxy.rpc.enums.PowerModeQualificationStatus;
import com.smartdevicelink.proxy.rpc.enums.PowerModeStatus;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.ClusterModeStatus}
+ */
public class ClusterModeStatusTests extends TestCase{
- private static final boolean POWER_MODE_ACTIVE = true;
- private static final PowerModeQualificationStatus POWER_MODE_QUALIFICATION_STATUS = PowerModeQualificationStatus.POWER_MODE_OK;
- private static final CarModeStatus CAR_MODE_STATUS = CarModeStatus.NORMAL;
- private static final PowerModeStatus POWER_MODE_STATUS = PowerModeStatus.RUNNING_2;
-
private ClusterModeStatus msg;
@Override
public void setUp(){
msg = new ClusterModeStatus();
- msg.setPowerModeActive(POWER_MODE_ACTIVE);
- msg.setCarModeStatus(CAR_MODE_STATUS);
- msg.setPowerModeQualificationStatus(POWER_MODE_QUALIFICATION_STATUS);
- msg.setPowerModeStatus(POWER_MODE_STATUS);
- }
-
- public void testPowerModeActive(){
- boolean copy = msg.getPowerModeActive();
- assertEquals("Input value didn't match expected value.", POWER_MODE_ACTIVE, copy);
- }
-
- public void testPowerModeQualificationStatus(){
- PowerModeQualificationStatus copy = msg.getPowerModeQualificationStatus();
- assertEquals("Input value didn't match expected value.", POWER_MODE_QUALIFICATION_STATUS, copy);
+ msg.setPowerModeActive(Test.GENERAL_BOOLEAN);
+ msg.setCarModeStatus(Test.GENERAL_CARMODESTATUS);
+ msg.setPowerModeQualificationStatus(Test.GENERAL_POWERMODEQUALIFICATIONSTATUS);
+ msg.setPowerModeStatus(Test.GENERAL_POWERMODESTATUS);
}
- public void testPowerModeStatus(){
- PowerModeStatus copy = msg.getPowerModeStatus();
- assertEquals("Input value didn't match expected value.", POWER_MODE_STATUS, copy);
- }
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ boolean powerMode = msg.getPowerModeActive();
+ PowerModeQualificationStatus qualification = msg.getPowerModeQualificationStatus();
+ PowerModeStatus status = msg.getPowerModeStatus();
+ CarModeStatus carStatus = msg.getCarModeStatus();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, powerMode);
+ assertEquals(Test.MATCH, Test.GENERAL_POWERMODEQUALIFICATIONSTATUS, qualification);
+ assertEquals(Test.MATCH, Test.GENERAL_POWERMODESTATUS, status);
+ assertEquals(Test.MATCH, Test.GENERAL_CARMODESTATUS, carStatus);
+
+ // Invalid/Null Tests
+ ClusterModeStatus msg = new ClusterModeStatus();
+ assertNotNull(Test.NOT_NULL, msg);
- public void testCarModeStatus(){
- CarModeStatus copy = msg.getCarModeStatus();
- assertEquals("Input value didn't match expected value.", CAR_MODE_STATUS, copy);
+ assertNull(Test.NULL, msg.getPowerModeActive());
+ assertNull(Test.NULL, msg.getPowerModeStatus());
+ assertNull(Test.NULL, msg.getPowerModeQualificationStatus());
+ assertNull(Test.NULL, msg.getCarModeStatus());
}
-
+
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(ClusterModeStatus.KEY_POWER_MODE_ACTIVE, POWER_MODE_ACTIVE);
- reference.put(ClusterModeStatus.KEY_POWER_MODE_STATUS, POWER_MODE_STATUS);
- reference.put(ClusterModeStatus.KEY_POWER_MODE_QUALIFICATION_STATUS,
- POWER_MODE_QUALIFICATION_STATUS);
- reference.put(ClusterModeStatus.KEY_CAR_MODE_STATUS, CAR_MODE_STATUS);
+ reference.put(ClusterModeStatus.KEY_POWER_MODE_ACTIVE, Test.GENERAL_BOOLEAN);
+ reference.put(ClusterModeStatus.KEY_POWER_MODE_STATUS, Test.GENERAL_POWERMODESTATUS);
+ reference.put(ClusterModeStatus.KEY_POWER_MODE_QUALIFICATION_STATUS, Test.GENERAL_POWERMODEQUALIFICATIONSTATUS);
+ reference.put(ClusterModeStatus.KEY_CAR_MODE_STATUS, Test.GENERAL_CARMODESTATUS);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
- }catch(JSONException e){
- /* do nothing */
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- ClusterModeStatus msg = new ClusterModeStatus();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Power mode active wasn't set, but getter method returned an object.", msg.getPowerModeActive());
- assertNull("Power mode status wasn't set, but getter method returned an object.", msg.getPowerModeStatus());
- assertNull("Power mode qualification status wasn't set, but getter method returned an object.",
- msg.getPowerModeQualificationStatus());
- assertNull("Car mode status wasn't set, but getter method returned an object.", msg.getCarModeStatus());
- }
- //TODO: remove testCopy()?
- /*
- public void testCopy(){
- ClusterModeStatus copy = new ClusterModeStatus(msg);
-
- assertNotSame("Object was not copied.", copy, msg);
-
- String error = "Object data was not copied correctly.";
- assertEquals(error, copy.getPowerModeActive(), msg.getPowerModeActive());
- assertEquals(error, copy.getPowerModeStatus(), msg.getPowerModeStatus());
- assertEquals(error, copy.getPowerModeQualificationStatus(), msg.getPowerModeQualificationStatus());
- assertEquals(error, copy.getCarModeStatus(), msg.getCarModeStatus());
- }
- */
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DIDResultTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DIDResultTests.java
index f9be94347..b929f2f80 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DIDResultTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DIDResultTests.java
@@ -10,72 +10,61 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.DIDResult;
import com.smartdevicelink.proxy.rpc.enums.VehicleDataResultCode;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
-public class DIDResultTests extends TestCase{
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.DIDResult}
+ */
+public class DIDResultTests extends TestCase {
- public static final VehicleDataResultCode RESULT_CODE = VehicleDataResultCode.SUCCESS;
- public static final String DATA = "aglghelgb3l2389hgal3tb34l";
-
- private DIDResult msg;
+ private DIDResult msg;
@Override
public void setUp(){
msg = new DIDResult();
- msg.setData(DATA);
- msg.setResultCode(RESULT_CODE);
+ msg.setData(Test.GENERAL_STRING);
+ msg.setResultCode(Test.GENERAL_VEHICLEDATARESULTCODE);
}
- public void testData(){
- String copy = msg.getData();
- assertEquals("Input value didn't match expected value.", DATA, copy);
- }
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ String data = msg.getData();
+ VehicleDataResultCode resultCode = msg.getResultCode();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, data);
+ assertEquals(Test.MATCH, Test.GENERAL_VEHICLEDATARESULTCODE, resultCode);
+
+ // Invalid/Null Tests
+ DIDResult msg = new DIDResult();
+ assertNotNull(Test.NOT_NULL, msg);
- public void testResultCode(){
- VehicleDataResultCode copy = msg.getResultCode();
- assertEquals("Input value didn't match expected value.", RESULT_CODE, copy);
+ assertNull(Test.NULL, msg.getData());
+ assertNull(Test.NULL, msg.getResultCode());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(DIDResult.KEY_DATA, DATA);
- reference.put(DIDResult.KEY_RESULT_CODE, RESULT_CODE);
+ reference.put(DIDResult.KEY_DATA, Test.GENERAL_STRING);
+ reference.put(DIDResult.KEY_RESULT_CODE, Test.GENERAL_VEHICLEDATARESULTCODE);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
- }catch(JSONException e){
- /* do nothing */
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- DIDResult msg = new DIDResult();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Data wasn't set, but getter method returned an object.", msg.getData());
- assertNull("Result code wasn't set, but getter method returned an object.", msg.getResultCode());
- }
- //TODO: remove testCopy()?
- /*
- public void testCopy(){
- DIDResult copy = new DIDResult(msg);
-
- assertNotSame("Object was not copied.", copy, msg);
-
- String error = "Object data was not copied correctly.";
- assertEquals(error, copy.getData(), msg.getData());
- assertEquals(error, copy.getResultCode(), msg.getResultCode());
- }
- */
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DTCTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DTCTests.java
index 5c50706a7..3079d2003 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DTCTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DTCTests.java
@@ -9,60 +9,61 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.DTC;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.DTC}
+ */
public class DTCTests extends TestCase{
- private static final String ECU_ID = "511";
- private static final String STATUS = "0x00";
-
- private DTC msg;
+ private DTC msg;
@Override
public void setUp(){
msg = new DTC();
- msg.setIdentifier(ECU_ID);
- msg.setStatusByte(STATUS);
+ msg.setIdentifier(Test.GENERAL_STRING);
+ msg.setStatusByte(Test.GENERAL_STRING);
}
- public void testIdentifier(){
- String copy = msg.getIdentifier();
- assertEquals("Input value didn't match expected value.", ECU_ID, copy);
- }
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ String identifier = msg.getIdentifier();
+ String statusByte = msg.getStatusByte();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, identifier);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, statusByte);
+
+ // Invalid/Null Tests
+ DTC msg = new DTC();
+ assertNotNull(Test.NOT_NULL, msg);
- public void testStatusByte(){
- String copy = msg.getStatusByte();
- assertEquals("Input value didn't match expected value.", STATUS, copy);
+ assertNull(Test.NULL, msg.getIdentifier());
+ assertNull(Test.NULL, msg.getStatusByte());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(DTC.KEY_IDENTIFIER, ECU_ID);
- reference.put(DTC.KEY_STATUS_BYTE, STATUS);
+ reference.put(DTC.KEY_IDENTIFIER, Test.GENERAL_STRING);
+ reference.put(DTC.KEY_STATUS_BYTE, Test.GENERAL_STRING);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}catch(JSONException e){
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- DTC msg = new DTC();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Identifier wasn't set, but getter method returned an object.", msg.getIdentifier());
- assertNull("Status wasn't set, but getter method returned an object.", msg.getStatusByte());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DeviceInfoTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DeviceInfoTests.java
index ef7c0e5fc..cbd432cc2 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DeviceInfoTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DeviceInfoTests.java
@@ -9,113 +9,81 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.DeviceInfo;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.DeviceInfo}
+ */
public class DeviceInfoTests extends TestCase{
- private static final String HARDWARE = "aljg238";
- private static final String FIRMWARE_REV = "2.4.3";
- private static final String OS = "Android";
- private static final String OS_VERSION = "4.4.4";
- private static final String CARRIER = "Verizon";
- private static final int RFCOMM_PORTS = 3;
-
private DeviceInfo msg;
@Override
public void setUp(){
msg = new DeviceInfo();
- msg.setCarrier(CARRIER);
- msg.setFirmwareRev(FIRMWARE_REV);
- msg.setHardware(HARDWARE);
- msg.setMaxNumberRFCOMMPorts(RFCOMM_PORTS);
- msg.setOs(OS);
- msg.setOsVersion(OS_VERSION);
- }
-
- public void testCarrier(){
- String copy = msg.getCarrier();
- assertEquals("Input value didn't match expected value.", CARRIER, copy);
- }
-
- public void testHardware(){
- String copy = msg.getHardware();
- assertEquals("Input value didn't match expected value.", HARDWARE, copy);
- }
-
- public void testFirmwareRev(){
- String copy = msg.getFirmwareRev();
- assertEquals("Input value didn't match expected value.", FIRMWARE_REV, copy);
- }
-
- public void testOs(){
- String copy = msg.getOs();
- assertEquals("Input value didn't match expected value.", OS, copy);
- }
-
- public void testOsVersion(){
- String copy = msg.getOsVersion();
- assertEquals("Input value didn't match expected value.", OS_VERSION, copy);
+ msg.setCarrier(Test.GENERAL_STRING);
+ msg.setFirmwareRev(Test.GENERAL_STRING);
+ msg.setHardware(Test.GENERAL_STRING);
+ msg.setMaxNumberRFCOMMPorts(Test.GENERAL_INT);
+ msg.setOs(Test.GENERAL_STRING);
+ msg.setOsVersion(Test.GENERAL_STRING);
}
- public void testMaxNumberRFCOMMPorts(){
- int copy = msg.getMaxNumberRFCOMMPorts();
- assertEquals("Input value didn't match expected value.", RFCOMM_PORTS, copy);
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ String carrier = msg.getCarrier();
+ String hardware = msg.getHardware();
+ String firmwareRev = msg.getFirmwareRev();
+ String os = msg.getOs();
+ String osVer = msg.getOsVersion();
+ int maxNum = msg.getMaxNumberRFCOMMPorts();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_INT, maxNum);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, osVer);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, os);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, firmwareRev);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, hardware);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, carrier);
+
+ // Invalid/Null Tests
+ DeviceInfo msg = new DeviceInfo();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getCarrier());
+ assertNull(Test.NULL, msg.getHardware());
+ assertNull(Test.NULL, msg.getFirmwareRev());
+ assertNull(Test.NULL, msg.getOs());
+ assertNull(Test.NULL, msg.getOsVersion());
+ assertNull(Test.NULL, msg.getMaxNumberRFCOMMPorts());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(DeviceInfo.KEY_CARRIER, CARRIER);
- reference.put(DeviceInfo.KEY_HARDWARE, HARDWARE);
- reference.put(DeviceInfo.KEY_FIRMWARE_REV, FIRMWARE_REV);
- reference.put(DeviceInfo.KEY_OS, OS);
- reference.put(DeviceInfo.KEY_OS_VERSION, OS_VERSION);
- reference.put(DeviceInfo.KEY_MAX_NUMBER_RFCOMM_PORTS, RFCOMM_PORTS);
+ reference.put(DeviceInfo.KEY_CARRIER, Test.GENERAL_STRING);
+ reference.put(DeviceInfo.KEY_HARDWARE, Test.GENERAL_STRING);
+ reference.put(DeviceInfo.KEY_FIRMWARE_REV, Test.GENERAL_STRING);
+ reference.put(DeviceInfo.KEY_OS, Test.GENERAL_STRING);
+ reference.put(DeviceInfo.KEY_OS_VERSION, Test.GENERAL_STRING);
+ reference.put(DeviceInfo.KEY_MAX_NUMBER_RFCOMM_PORTS, Test.GENERAL_INT);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
- }catch(JSONException e){
- /* do nothing */
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- DeviceInfo msg = new DeviceInfo();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Carrier wasn't set, but getter method returned an object.", msg.getCarrier());
- assertNull("Hardware wasn't set, but getter method returned an object.", msg.getHardware());
- assertNull("Firmware rev wasn't set, but getter method returned an object.", msg.getFirmwareRev());
- assertNull("OS wasn't set, but getter method returned an object.", msg.getOs());
- assertNull("OS version wasn't set, but getter method returned an object.", msg.getOsVersion());
- assertNull("Max number RFCOMM ports wasn't set, but getter method returned an object.",
- msg.getMaxNumberRFCOMMPorts());
- }
- //TODO: remove testCopy()?
- /*
- public void testCopy(){
- DeviceInfo copy = new DeviceInfo(msg);
-
- assertNotSame("Object was not copied.", copy, msg);
-
- String error = "Object data was not copied correctly.";
- assertEquals(error, copy.getCarrier(), msg.getCarrier());
- assertEquals(error, copy.getHardware(), msg.getHardware());
- assertEquals(error, copy.getFirmwareRev(), msg.getFirmwareRev());
- assertEquals(error, copy.getOs(), msg.getOs());
- assertEquals(error, copy.getOsVersion(), msg.getOsVersion());
- assertEquals(error, copy.getMaxNumberRFCOMMPorts(), msg.getMaxNumberRFCOMMPorts());
- }
- */
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DeviceStatusTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DeviceStatusTests.java
index 90339c218..4c966f06e 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DeviceStatusTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DeviceStatusTests.java
@@ -11,165 +11,106 @@ import com.smartdevicelink.proxy.rpc.DeviceStatus;
import com.smartdevicelink.proxy.rpc.enums.DeviceLevelStatus;
import com.smartdevicelink.proxy.rpc.enums.PrimaryAudioSource;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
-public class DeviceStatusTests extends TestCase{
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.DeviceStatus}
+ */
+public class DeviceStatusTests extends TestCase {
- private static final boolean VOICE_REC_ON = true;
- private static final boolean BT_ICON_ON = true;
- private static final boolean CALL_ACTIVE = false;
- private static final boolean PHONE_ROAMING = false;
- private static final boolean TEXT_MSG_AVAILABLE = true;
- private static final boolean STEREO_AUDIO_MUTED = false;
- private static final boolean MONO_AUDIO_MUTED = false;
- private static final boolean E_CALL_EVENT_ACTIVE = false;
- private static final DeviceLevelStatus BATT_LEVEL_STATUS = DeviceLevelStatus.FOUR_LEVEL_BARS;
- private static final DeviceLevelStatus SIGNAL_LEVEL_STATUS = DeviceLevelStatus.TWO_LEVEL_BARS;
- private static final PrimaryAudioSource PRIMARY_AUDIO_SOURCE = PrimaryAudioSource.BLUETOOTH_STEREO_BTST;
-
- private DeviceStatus msg;
+ private DeviceStatus msg;
@Override
public void setUp(){
msg = new DeviceStatus();
- msg.setBattLevelStatus(BATT_LEVEL_STATUS);
- msg.setBtIconOn(BT_ICON_ON);
- msg.setCallActive(CALL_ACTIVE);
- msg.setECallEventActive(E_CALL_EVENT_ACTIVE);
- msg.setMonoAudioOutputMuted(MONO_AUDIO_MUTED);
- msg.setPhoneRoaming(PHONE_ROAMING);
- msg.setPrimaryAudioSource(PRIMARY_AUDIO_SOURCE);
- msg.setSignalLevelStatus(SIGNAL_LEVEL_STATUS);
- msg.setStereoAudioOutputMuted(STEREO_AUDIO_MUTED);
- msg.setTextMsgAvailable(TEXT_MSG_AVAILABLE);
- msg.setVoiceRecOn(VOICE_REC_ON);
- }
-
- public void testBattLevelStatus(){
- DeviceLevelStatus copy = msg.getBattLevelStatus();
- assertEquals("Input value didn't match expected value.", BATT_LEVEL_STATUS, copy);
- }
-
- public void testBtIconOn(){
- boolean copy = msg.getBtIconOn();
- assertEquals("Input value didn't match expected value.", BT_ICON_ON, copy);
- }
-
- public void testCallActive(){
- boolean copy = msg.getCallActive();
- assertEquals("Input value didn't match expected value.", CALL_ACTIVE, copy);
- }
-
- public void testECallEventActive(){
- boolean copy = msg.getECallEventActive();
- assertEquals("Input value didn't match expected value.", E_CALL_EVENT_ACTIVE, copy);
- }
-
- public void testMonoAudioOutputMuted(){
- boolean copy = msg.getMonoAudioOutputMuted();
- assertEquals("Input value didn't match expected value.", MONO_AUDIO_MUTED, copy);
- }
-
- public void testPhoneRoaming(){
- boolean copy = msg.getPhoneRoaming();
- assertEquals("Input value didn't match expected value.", PHONE_ROAMING, copy);
- }
-
- public void testPrimaryAudioSource(){
- PrimaryAudioSource copy = msg.getPrimaryAudioSource();
- assertEquals("Input value didn't match expected value.", PRIMARY_AUDIO_SOURCE, copy);
+ msg.setBattLevelStatus(Test.GENERAL_DEVICELEVELSTATUS);
+ msg.setBtIconOn(Test.GENERAL_BOOLEAN);
+ msg.setCallActive(Test.GENERAL_BOOLEAN);
+ msg.setECallEventActive(Test.GENERAL_BOOLEAN);
+ msg.setMonoAudioOutputMuted(Test.GENERAL_BOOLEAN);
+ msg.setPhoneRoaming(Test.GENERAL_BOOLEAN);
+ msg.setPrimaryAudioSource(Test.GENERAL_PRIMARYAUDIOSOURCE);
+ msg.setSignalLevelStatus(Test.GENERAL_DEVICELEVELSTATUS);
+ msg.setStereoAudioOutputMuted(Test.GENERAL_BOOLEAN);
+ msg.setTextMsgAvailable(Test.GENERAL_BOOLEAN);
+ msg.setVoiceRecOn(Test.GENERAL_BOOLEAN);
}
- public void testSignalLevelStatus(){
- DeviceLevelStatus copy = msg.getSignalLevelStatus();
- assertEquals("Input value didn't match expected value.", SIGNAL_LEVEL_STATUS, copy);
- }
-
- public void testStereoAudioOutputMuted(){
- boolean copy = msg.getStereoAudioOutputMuted();
- assertEquals("Input value didn't match expected value.", STEREO_AUDIO_MUTED, copy);
- }
-
- public void testTextMsgAvailable(){
- boolean copy = msg.getTextMsgAvailable();
- assertEquals("Input value didn't match expected value.", TEXT_MSG_AVAILABLE, copy);
- }
-
- public void testVoiceRecOn(){
- boolean copy = msg.getVoiceRecOn();
- assertEquals("Input value didn't match expected value.", VOICE_REC_ON, copy);
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ DeviceLevelStatus battLevel = msg.getBattLevelStatus();
+ boolean btIcon = msg.getBtIconOn();
+ boolean callActive = msg.getCallActive();
+ boolean ecall = msg.getECallEventActive();
+ boolean monoAudio = msg.getMonoAudioOutputMuted();
+ boolean phoneRoaming = msg.getPhoneRoaming();
+ PrimaryAudioSource primaryAudio = msg.getPrimaryAudioSource();
+ DeviceLevelStatus signalLevel = msg.getSignalLevelStatus();
+ boolean stereoAudio = msg.getStereoAudioOutputMuted();
+ boolean textAvailable = msg.getTextMsgAvailable();
+ boolean voiceRec = msg.getVoiceRecOn();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_DEVICELEVELSTATUS, battLevel);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, btIcon);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, callActive);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, ecall);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, monoAudio);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, phoneRoaming);
+ assertEquals(Test.MATCH, Test.GENERAL_PRIMARYAUDIOSOURCE, primaryAudio);
+ assertEquals(Test.MATCH, Test.GENERAL_DEVICELEVELSTATUS, signalLevel);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, stereoAudio);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, textAvailable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, voiceRec);
+
+ // Invalid/Null Tests
+ DeviceStatus msg = new DeviceStatus();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getBattLevelStatus());
+ assertNull(Test.NULL, msg.getBtIconOn());
+ assertNull(Test.NULL, msg.getCallActive());
+ assertNull(Test.NULL, msg.getECallEventActive());
+ assertNull(Test.NULL, msg.getMonoAudioOutputMuted());
+ assertNull(Test.NULL, msg.getPhoneRoaming());
+ assertNull(Test.NULL, msg.getPrimaryAudioSource());
+ assertNull(Test.NULL, msg.getSignalLevelStatus());
+ assertNull(Test.NULL, msg.getStereoAudioOutputMuted());
+ assertNull(Test.NULL, msg.getTextMsgAvailable());
+ assertNull(Test.NULL, msg.getVoiceRecOn());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(DeviceStatus.KEY_BATT_LEVEL_STATUS, BATT_LEVEL_STATUS);
- reference.put(DeviceStatus.KEY_SIGNAL_LEVEL_STATUS, SIGNAL_LEVEL_STATUS);
- reference.put(DeviceStatus.KEY_PRIMARY_AUDIO_SOURCE, PRIMARY_AUDIO_SOURCE);
- reference.put(DeviceStatus.KEY_BT_ICON_ON, BT_ICON_ON);
- reference.put(DeviceStatus.KEY_CALL_ACTIVE, CALL_ACTIVE);
- reference.put(DeviceStatus.KEY_E_CALL_EVENT_ACTIVE, E_CALL_EVENT_ACTIVE);
- reference.put(DeviceStatus.KEY_MONO_AUDIO_OUTPUT_MUTED, MONO_AUDIO_MUTED);
- reference.put(DeviceStatus.KEY_STEREO_AUDIO_OUTPUT_MUTED, STEREO_AUDIO_MUTED);
- reference.put(DeviceStatus.KEY_TEXT_MSG_AVAILABLE, TEXT_MSG_AVAILABLE);
- reference.put(DeviceStatus.KEY_PHONE_ROAMING, PHONE_ROAMING);
- reference.put(DeviceStatus.KEY_VOICE_REC_ON, VOICE_REC_ON);
+ reference.put(DeviceStatus.KEY_BATT_LEVEL_STATUS, Test.GENERAL_DEVICELEVELSTATUS);
+ reference.put(DeviceStatus.KEY_SIGNAL_LEVEL_STATUS, Test.GENERAL_DEVICELEVELSTATUS);
+ reference.put(DeviceStatus.KEY_PRIMARY_AUDIO_SOURCE, Test.GENERAL_PRIMARYAUDIOSOURCE);
+ reference.put(DeviceStatus.KEY_BT_ICON_ON, Test.GENERAL_BOOLEAN);
+ reference.put(DeviceStatus.KEY_CALL_ACTIVE, Test.GENERAL_BOOLEAN);
+ reference.put(DeviceStatus.KEY_E_CALL_EVENT_ACTIVE, Test.GENERAL_BOOLEAN);
+ reference.put(DeviceStatus.KEY_MONO_AUDIO_OUTPUT_MUTED, Test.GENERAL_BOOLEAN);
+ reference.put(DeviceStatus.KEY_STEREO_AUDIO_OUTPUT_MUTED, Test.GENERAL_BOOLEAN);
+ reference.put(DeviceStatus.KEY_TEXT_MSG_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(DeviceStatus.KEY_PHONE_ROAMING, Test.GENERAL_BOOLEAN);
+ reference.put(DeviceStatus.KEY_VOICE_REC_ON, Test.GENERAL_BOOLEAN);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
- }catch(JSONException e){
- /* do nothing */
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- DeviceStatus msg = new DeviceStatus();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Batt level status wasn't set, but getter method returned an object.", msg.getBattLevelStatus());
- assertNull("BT icon on wasn't set, but getter method returned an object.", msg.getBtIconOn());
- assertNull("Call active wasn't set, but getter method returned an object.", msg.getCallActive());
- assertNull("E-call event active wasn't set, but getter method returned an object.", msg.getECallEventActive());
- assertNull("Mono audio output muted wasn't set, but getter method returned an object.",
- msg.getMonoAudioOutputMuted());
- assertNull("Phone roaming wasn't set, but getter method returned an object.", msg.getPhoneRoaming());
- assertNull("Primary audio source wasn't set, but getter method returned an object.",
- msg.getPrimaryAudioSource());
- assertNull("Signal level status wasn't set, but getter method returned an object.", msg.getSignalLevelStatus());
- assertNull("Stereo audio output muted wasn't set, but getter method returned an object.",
- msg.getStereoAudioOutputMuted());
- assertNull("Text msg available wasn't set, but getter method returned an object.", msg.getTextMsgAvailable());
- assertNull("Voice rec on wasn't set, but getter method returned an object.", msg.getVoiceRecOn());
- }
- //TODO: remove testCopy()?
- /*
- public void testCopy(){
- DeviceStatus copy = new DeviceStatus(msg);
-
- assertNotSame("Object was not copied.", copy, msg);
-
- String error = "Object data was not copied correctly.";
- assertEquals(error, copy.getBattLevelStatus(), msg.getBattLevelStatus());
- assertEquals(error, copy.getBtIconOn(), msg.getBtIconOn());
- assertEquals(error, copy.getCallActive(), msg.getCallActive());
- assertEquals(error, copy.getECallEventActive(), msg.getECallEventActive());
- assertEquals(error, copy.getMonoAudioOutputMuted(), msg.getMonoAudioOutputMuted());
- assertEquals(error, copy.getPhoneRoaming(), msg.getPhoneRoaming());
- assertEquals(error, copy.getPrimaryAudioSource(), msg.getPrimaryAudioSource());
- assertEquals(error, copy.getSignalLevelStatus(), msg.getSignalLevelStatus());
- assertEquals(error, copy.getStereoAudioOutputMuted(), msg.getStereoAudioOutputMuted());
- assertEquals(error, copy.getTextMsgAvailable(), msg.getTextMsgAvailable());
- assertEquals(error, copy.getVoiceRecOn(), msg.getVoiceRecOn());
- }
- */
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DisplayCapabilitiesTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DisplayCapabilitiesTests.java
index 5f564c72f..def880ae5 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DisplayCapabilitiesTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/DisplayCapabilitiesTests.java
@@ -1,7 +1,5 @@
package com.smartdevicelink.test.rpc.datatypes;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
@@ -19,192 +17,86 @@ import com.smartdevicelink.proxy.rpc.ImageResolution;
import com.smartdevicelink.proxy.rpc.ScreenParams;
import com.smartdevicelink.proxy.rpc.TextField;
import com.smartdevicelink.proxy.rpc.TouchEventCapabilities;
-import com.smartdevicelink.proxy.rpc.enums.CharacterSet;
import com.smartdevicelink.proxy.rpc.enums.DisplayType;
-import com.smartdevicelink.proxy.rpc.enums.FileType;
-import com.smartdevicelink.proxy.rpc.enums.ImageFieldName;
import com.smartdevicelink.proxy.rpc.enums.MediaClockFormat;
-import com.smartdevicelink.proxy.rpc.enums.TextFieldName;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
import com.smartdevicelink.test.Validator;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.DisplayCapabilities}
+ */
public class DisplayCapabilitiesTests extends TestCase{
-
- private static final boolean GRAPHIC_SUPPORTED = true;
- private static final int CUSTOM_PRESETS_AVAILABLE = 5;
- private static final DisplayType DISPLAY_TYPE = DisplayType.NGN;
-
- // screen params constants
- private static final int SCREEN_IMAGE_RESOLUTION_WIDTH = 1250;
- private static final int SCREEN_IMAGE_RESOLUTION_HEIGHT = 1080;
- private static final boolean TOUCH_AVAILABLE = true;
- private static final boolean MULTI_TOUCH_AVAILABLE = false;
- private static final boolean DOUBLE_PRESS_AVAILABLE = false;
-
- // textFields constants
- private static final TextFieldName[] TEXT_FIELD_NAMES = new TextFieldName[] {
- TextFieldName.alertText1, TextFieldName.alertText2, TextFieldName.mainField1 };
- private static final int[] TEXT_FIELD_WIDTHS = new int[] { 25, 25, 30 };
- private static final int TEXT_FIELD_ROWS = 1;
- private static final CharacterSet CHARACTER_SET = CharacterSet.TYPE2SET;
-
-
- // imageFields constants
- private static final ImageFieldName[] IMAGE_FIELD_NAMES = new ImageFieldName[] {
- ImageFieldName.appIcon, ImageFieldName.graphic, ImageFieldName.softButtonImage };
- private static final FileType[] IMAGE_FILE_TYPES = new FileType[] { FileType.GRAPHIC_PNG,
- FileType.GRAPHIC_JPEG, FileType.GRAPHIC_BMP };
- private static final ImageResolution[] IMAGE_RESOLUTIONS = new ImageResolution[3];
- private static final Integer IMAGE_RESOLUTION_ITEM_1_WIDTH = 20;
- private static final Integer IMAGE_RESOLUTION_ITEM_1_HEIGHT = 20;
- private static final Integer IMAGE_RESOLUTION_ITEM_2_WIDTH = 30;
- private static final Integer IMAGE_RESOLUTION_ITEM_2_HEIGHT = 30;
- private static final Integer IMAGE_RESOLUTION_ITEM_3_WIDTH = 40;
- private static final Integer IMAGE_RESOLUTION_ITEM_3_HEIGHT = 40;
-
-
- private final List<String> TEMPLATES_AVAILABLE = Arrays.asList(new String[] { "Media",
- "Navigation", "Productivity" });
-
- private final List<MediaClockFormat> MEDIA_CLOCK_FORMATS = Arrays.asList(new MediaClockFormat[] { MediaClockFormat.CLOCK1 });
-
- private DisplayCapabilities msg;
-
- private ScreenParams screenParams;
- private List<TextField> textFields;
- private List<ImageField> imageFields;
- private ImageResolution imageResolution;
- private TouchEventCapabilities touchEventCapabilities;
+
+ private DisplayCapabilities msg;
@Override
public void setUp(){
msg = new DisplayCapabilities();
- createCustomObjects();
-
- msg.setGraphicSupported(GRAPHIC_SUPPORTED);
- msg.setNumCustomPresetsAvailable(CUSTOM_PRESETS_AVAILABLE);
- msg.setDisplayType(DISPLAY_TYPE);
- msg.setImageFields(imageFields);
- msg.setTextFields(textFields);
- msg.setMediaClockFormats(MEDIA_CLOCK_FORMATS);
- msg.setScreenParams(screenParams);
- msg.setTemplatesAvailable(TEMPLATES_AVAILABLE);
+ msg.setGraphicSupported(Test.GENERAL_BOOLEAN);
+ msg.setNumCustomPresetsAvailable(Test.GENERAL_INT);
+ msg.setDisplayType(Test.GENERAL_DISPLAYTYPE);
+ msg.setImageFields(Test.GENERAL_IMAGEFIELD_LIST);
+ msg.setTextFields(Test.GENERAL_TEXTFIELD_LIST);
+ msg.setMediaClockFormats(Test.GENERAL_MEDIACLOCKFORMAT_LIST);
+ msg.setScreenParams(Test.GENERAL_SCREENPARAMS);
+ msg.setTemplatesAvailable(Test.GENERAL_STRING_LIST);
}
- private void createCustomObjects(){
- IMAGE_RESOLUTIONS[0] = new ImageResolution();
- IMAGE_RESOLUTIONS[0].setResolutionWidth(IMAGE_RESOLUTION_ITEM_1_WIDTH);
- IMAGE_RESOLUTIONS[0].setResolutionHeight(IMAGE_RESOLUTION_ITEM_1_HEIGHT);
-
- IMAGE_RESOLUTIONS[1] = new ImageResolution();
- IMAGE_RESOLUTIONS[1].setResolutionWidth(IMAGE_RESOLUTION_ITEM_2_WIDTH);
- IMAGE_RESOLUTIONS[1].setResolutionHeight(IMAGE_RESOLUTION_ITEM_2_HEIGHT);
-
- IMAGE_RESOLUTIONS[2] = new ImageResolution();
- IMAGE_RESOLUTIONS[2].setResolutionWidth(IMAGE_RESOLUTION_ITEM_3_WIDTH);
- IMAGE_RESOLUTIONS[2].setResolutionHeight(IMAGE_RESOLUTION_ITEM_3_HEIGHT);
-
- imageResolution = new ImageResolution();
- imageResolution.setResolutionWidth(SCREEN_IMAGE_RESOLUTION_WIDTH);
- imageResolution.setResolutionHeight(SCREEN_IMAGE_RESOLUTION_HEIGHT);
-
- touchEventCapabilities = new TouchEventCapabilities();
- touchEventCapabilities.setPressAvailable(TOUCH_AVAILABLE);
- touchEventCapabilities.setMultiTouchAvailable(MULTI_TOUCH_AVAILABLE);
- touchEventCapabilities.setDoublePressAvailable(DOUBLE_PRESS_AVAILABLE);
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ boolean graphicSupported = msg.getGraphicSupported();
+ int numPresets = msg.getNumCustomPresetsAvailable();
+ DisplayType displayType = msg.getDisplayType();
+ ScreenParams screenParams = msg.getScreenParams();
+ List<String> templatesAvailable = msg.getTemplatesAvailable();
+ List<MediaClockFormat> mediaClock = msg.getMediaClockFormats();
+ List<TextField> textFields = msg.getTextFields();
+ List<ImageField> imageFields = msg.getImageFields();
- screenParams = new ScreenParams();
- screenParams.setImageResolution(imageResolution);
- screenParams.setTouchEventAvailable(touchEventCapabilities);
-
- textFields = new ArrayList<TextField>(TEXT_FIELD_NAMES.length);
- for(int i = 0; i < TEXT_FIELD_NAMES.length; i++){
- TextField textField = new TextField();
- textField.setName(TEXT_FIELD_NAMES[i]);
- textField.setCharacterSet(CHARACTER_SET);
- textField.setWidth(TEXT_FIELD_WIDTHS[i]);
- textField.setRows(TEXT_FIELD_ROWS);
- textFields.add(textField);
- }
-
- imageFields = new ArrayList<ImageField>(IMAGE_FIELD_NAMES.length);
- for(int i = 0; i < IMAGE_FIELD_NAMES.length; i++){
- ImageField imageField = new ImageField();
- imageField.setName(IMAGE_FIELD_NAMES[i]);
-
- List<FileType> fileList = new ArrayList<FileType>();
- for(int j = 0; j < IMAGE_FILE_TYPES.length; j++){
- fileList.add(IMAGE_FILE_TYPES[j]);
- }
- imageField.setImageTypeSupported(fileList);
- imageField.setImageResolution(IMAGE_RESOLUTIONS[i]);
-
- imageFields.add(imageField);
- }
- }
-
- public void testGraphicSupported(){
- boolean copy = msg.getGraphicSupported();
- assertEquals("Input value didn't match expected value.", GRAPHIC_SUPPORTED, copy);
- }
-
- public void testNumPresetsAvailable(){
- int copy = msg.getNumCustomPresetsAvailable();
- assertEquals("Input value didn't match expected value.", CUSTOM_PRESETS_AVAILABLE, copy);
- }
-
- public void testDisplayType(){
- DisplayType copy = msg.getDisplayType();
- assertEquals("Input value didn't match expected value.", DISPLAY_TYPE, copy);
- }
-
- public void testScreenParams(){
- ScreenParams copy = msg.getScreenParams();
-
- assertTrue("Input value didn't match expected value.", Validator.validateScreenParams(screenParams, copy));
- }
-
- public void testTemplatesAvailable(){
- List<String> copy = msg.getTemplatesAvailable();
-
- assertEquals("Templates available size didn't match expected size.", TEMPLATES_AVAILABLE.size(), copy.size());
-
- for(int i = 0; i < TEMPLATES_AVAILABLE.size(); i++){
- assertEquals("Template data at index " + i + " didn't match expected data.", TEMPLATES_AVAILABLE.get(i),
- copy.get(i));
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, graphicSupported);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, numPresets);
+ assertEquals(Test.MATCH, Test.GENERAL_DISPLAYTYPE, displayType);
+ assertTrue(Test.TRUE, Validator.validateScreenParams(Test.GENERAL_SCREENPARAMS, screenParams));
+ assertEquals(Test.MATCH, Test.GENERAL_STRING_LIST.size(), templatesAvailable.size());
+ 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());
+
+ for(int i = 0; i < Test.GENERAL_STRING_LIST.size(); i++){
+ assertEquals(Test.MATCH, Test.GENERAL_STRING_LIST.get(i), templatesAvailable.get(i));
}
- }
-
- public void testMediaClockFormats(){
- List<MediaClockFormat> copy = msg.getMediaClockFormats();
-
- assertEquals("Media clock formats size didn't match expected size.", MEDIA_CLOCK_FORMATS.size(), copy.size());
-
- for(int i = 0; i < MEDIA_CLOCK_FORMATS.size(); i++){
- assertEquals("Media clock format data at index " + i + " didn't match expected data.",
- MEDIA_CLOCK_FORMATS.get(i), copy.get(i));
+
+ for(int i = 0; i < Test.GENERAL_MEDIACLOCKFORMAT_LIST.size(); i++){
+ assertEquals(Test.MATCH, Test.GENERAL_MEDIACLOCKFORMAT_LIST.get(i), mediaClock.get(i));
}
- }
-
- public void testTextFields(){
- List<TextField> copy = msg.getTextFields();
- assertEquals("Text fields size didn't match expected size.", textFields.size(), copy.size());
- for(int i = 0; i < textFields.size(); i++){
- assertTrue("Text field data at index " + i + " didn't match expected data.",
- Validator.validateTextFields(textFields.get(i), copy.get(i)));
+ 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)));
}
- }
- public void testImageFields(){
- List<ImageField> copy = msg.getImageFields();
- assertEquals("Text fields size didn't match expected size.", imageFields.size(), copy.size());
-
- for(int i = 0; i < imageFields.size(); i++){
- assertTrue("Text field data at index " + i + " didn't match expected data.",
- Validator.validateImageFields(imageFields.get(i), copy.get(i)));
+ for(int i = 0; i < Test.GENERAL_IMAGEFIELD_LIST.size(); i++){
+ assertTrue(Test.TRUE, Validator.validateImageFields(Test.GENERAL_IMAGEFIELD_LIST.get(i), imageFields.get(i)));
}
+
+ // Invalid/Null Tests
+ DisplayCapabilities msg = new DisplayCapabilities();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getDisplayType());
+ assertNull(Test.NULL, msg.getGraphicSupported());
+ assertNull(Test.NULL, msg.getImageFields());
+ assertNull(Test.NULL, msg.getMediaClockFormats());
+ assertNull(Test.NULL, msg.getNumCustomPresetsAvailable());
+ assertNull(Test.NULL, msg.getScreenParams());
+ assertNull(Test.NULL, msg.getTemplatesAvailable());
+ assertNull(Test.NULL, msg.getTextFields());
}
public void testJson(){
@@ -213,19 +105,18 @@ public class DisplayCapabilitiesTests extends TestCase{
JSONArray mediaClockFormats = new JSONArray(), textFields = new JSONArray(), imageFields = new JSONArray();
try{
- reference.put(DisplayCapabilities.KEY_NUM_CUSTOM_PRESETS_AVAILABLE, CUSTOM_PRESETS_AVAILABLE);
- reference.put(DisplayCapabilities.KEY_GRAPHIC_SUPPORTED, GRAPHIC_SUPPORTED);
- reference.put(DisplayCapabilities.KEY_DISPLAY_TYPE, DISPLAY_TYPE);
- reference.put(DisplayCapabilities.KEY_TEMPLATES_AVAILABLE,
- JsonUtils.createJsonArray(TEMPLATES_AVAILABLE));
+ reference.put(DisplayCapabilities.KEY_NUM_CUSTOM_PRESETS_AVAILABLE, Test.GENERAL_INT);
+ reference.put(DisplayCapabilities.KEY_GRAPHIC_SUPPORTED, Test.GENERAL_BOOLEAN);
+ reference.put(DisplayCapabilities.KEY_DISPLAY_TYPE, Test.GENERAL_DISPLAYTYPE);
+ reference.put(DisplayCapabilities.KEY_TEMPLATES_AVAILABLE, JsonUtils.createJsonArray(Test.GENERAL_STRING_LIST));
- for(MediaClockFormat format : MEDIA_CLOCK_FORMATS){
+ for(MediaClockFormat format : Test.GENERAL_MEDIACLOCKFORMAT_LIST){
mediaClockFormats.put(format);
}
reference.put(DisplayCapabilities.KEY_MEDIA_CLOCK_FORMATS, mediaClockFormats);
// text fields
- for(TextField textField : this.textFields){
+ for(TextField textField : Test.GENERAL_TEXTFIELD_LIST){
JSONObject textFieldJson = new JSONObject();
textFieldJson.put(TextField.KEY_CHARACTER_SET, textField.getCharacterSet());
textFieldJson.put(TextField.KEY_NAME, textField.getName());
@@ -236,7 +127,7 @@ public class DisplayCapabilitiesTests extends TestCase{
reference.put(DisplayCapabilities.KEY_TEXT_FIELDS, textFields);
// image fields
- for(ImageField imageField : this.imageFields){
+ for(ImageField imageField : Test.GENERAL_IMAGEFIELD_LIST){
JSONObject imageFieldJson = new JSONObject();
imageFieldJson.put(ImageField.KEY_IMAGE_TYPE_SUPPORTED, imageField.getImageTypeSupported());
imageFieldJson.put(ImageField.KEY_NAME, imageField.getName());
@@ -252,12 +143,12 @@ public class DisplayCapabilitiesTests extends TestCase{
reference.put(DisplayCapabilities.KEY_IMAGE_FIELDS, imageFields);
// screen params
- ImageResolution resolution = this.screenParams.getImageResolution();
+ ImageResolution resolution = Test.GENERAL_SCREENPARAMS.getImageResolution();
imageResolution.put(ImageResolution.KEY_RESOLUTION_HEIGHT, resolution.getResolutionHeight());
imageResolution.put(ImageResolution.KEY_RESOLUTION_WIDTH, resolution.getResolutionWidth());
screenParams.put(ScreenParams.KEY_RESOLUTION, imageResolution);
- TouchEventCapabilities touchCapabilities = this.touchEventCapabilities;
+ TouchEventCapabilities touchCapabilities = Test.GENERAL_TOUCHEVENTCAPABILITIES;
touchEventCapabilities.put(TouchEventCapabilities.KEY_PRESS_AVAILABLE,
touchCapabilities.getPressAvailable());
touchEventCapabilities.put(TouchEventCapabilities.KEY_DOUBLE_PRESS_AVAILABLE,
@@ -268,8 +159,7 @@ public class DisplayCapabilitiesTests extends TestCase{
reference.put(DisplayCapabilities.KEY_SCREEN_PARAMS, screenParams);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
@@ -277,87 +167,52 @@ public class DisplayCapabilitiesTests extends TestCase{
if(key.equals(DisplayCapabilities.KEY_IMAGE_FIELDS)){
JSONArray referenceArray = JsonUtils.readJsonArrayFromJsonObject(reference, key);
JSONArray underTestArray = JsonUtils.readJsonArrayFromJsonObject(underTest, key);
- assertEquals("Image field size didn't match expected size.", referenceArray.length(),
- underTestArray.length());
+ assertEquals(Test.MATCH, referenceArray.length(), underTestArray.length());
for(int i = 0; i < referenceArray.length(); i++){
Hashtable<String, Object> hashReference = JsonRPCMarshaller.deserializeJSONObject(referenceArray.getJSONObject(i));
Hashtable<String, Object> hashTest= JsonRPCMarshaller.deserializeJSONObject(underTestArray.getJSONObject(i));
-
- assertTrue("Image field at index " + i + " didn't match expected value.",
- Validator.validateImageFields(new ImageField(hashReference), new ImageField(hashTest)));
+ assertTrue(Test.TRUE, Validator.validateImageFields(new ImageField(hashReference), new ImageField(hashTest)));
}
- }
- else if(key.equals(DisplayCapabilities.KEY_TEXT_FIELDS)){
+ } else if(key.equals(DisplayCapabilities.KEY_TEXT_FIELDS)){
JSONArray referenceArray = JsonUtils.readJsonArrayFromJsonObject(reference, key);
JSONArray underTestArray = JsonUtils.readJsonArrayFromJsonObject(underTest, key);
- assertEquals("Text field size didn't match expected size.", referenceArray.length(),
- underTestArray.length());
+ assertEquals(Test.MATCH, referenceArray.length(), underTestArray.length());
for(int i = 0; i < referenceArray.length(); i++){
Hashtable<String, Object> hashReference = JsonRPCMarshaller.deserializeJSONObject(referenceArray.getJSONObject(i));
Hashtable<String, Object> hashTest= JsonRPCMarshaller.deserializeJSONObject(underTestArray.getJSONObject(i));
-
- assertTrue("Text field at index " + i + " didn't match expected value.",
- Validator.validateTextFields(new TextField(hashReference), new TextField(hashTest)));
+ assertTrue(Test.TRUE, Validator.validateTextFields(new TextField(hashReference), new TextField(hashTest)));
}
- }
- else if(key.equals(DisplayCapabilities.KEY_TEMPLATES_AVAILABLE)){
+ } else if(key.equals(DisplayCapabilities.KEY_TEMPLATES_AVAILABLE)){
JSONArray referenceArray = JsonUtils.readJsonArrayFromJsonObject(reference, key);
JSONArray underTestArray = JsonUtils.readJsonArrayFromJsonObject(underTest, key);
- assertEquals("Template list size didn't match expected size.", referenceArray.length(),
- underTestArray.length());
+ assertEquals(Test.MATCH, referenceArray.length(), underTestArray.length());
for(int i = 0; i < referenceArray.length(); i++){
- assertTrue("Template field at index " + i + " didn't match expected value.",
- Validator.validateText(referenceArray.getString(i), underTestArray.getString(i)));
+ assertTrue(Test.TRUE, Validator.validateText(referenceArray.getString(i), underTestArray.getString(i)));
}
- }
- else if(key.equals(DisplayCapabilities.KEY_SCREEN_PARAMS)){
+ } else if(key.equals(DisplayCapabilities.KEY_SCREEN_PARAMS)){
JSONObject referenceArray = JsonUtils.readJsonObjectFromJsonObject(reference, key);
JSONObject underTestArray = JsonUtils.readJsonObjectFromJsonObject(underTest, key);
Hashtable<String, Object> hashReference = JsonRPCMarshaller.deserializeJSONObject(referenceArray);
Hashtable<String, Object> hashTest= JsonRPCMarshaller.deserializeJSONObject(underTestArray);
- assertTrue("Screen params value didn't match expected value.", Validator.validateScreenParams(
- new ScreenParams(hashReference), new ScreenParams(hashTest)));
- }
- else if(key.equals(DisplayCapabilities.KEY_MEDIA_CLOCK_FORMATS)){
+ assertTrue(Test.TRUE, Validator.validateScreenParams(new ScreenParams(hashReference), new ScreenParams(hashTest)));
+ } else if(key.equals(DisplayCapabilities.KEY_MEDIA_CLOCK_FORMATS)){
JSONArray referenceArray = JsonUtils.readJsonArrayFromJsonObject(reference, key);
JSONArray underTestArray = JsonUtils.readJsonArrayFromJsonObject(underTest, key);
- assertEquals("Media clock format list size didn't match expected size.", referenceArray.length(),
- underTestArray.length());
+ assertEquals(Test.MATCH, referenceArray.length(), underTestArray.length());
for(int i = 0; i < referenceArray.length(); i++){
- assertTrue("Media clock format at index " + i + " didn't match expected value.",
- Validator.validateText(referenceArray.getString(i), underTestArray.getString(i)));
+ assertTrue(Test.TRUE, Validator.validateText(referenceArray.getString(i), underTestArray.getString(i)));
}
- }
- else{
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ } else{
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}
}catch(JSONException e){
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- DisplayCapabilities msg = new DisplayCapabilities();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Display type wasn't set, but getter method returned an object.", msg.getDisplayType());
- assertNull("Graphic supported wasn't set, but getter method returned an object.", msg.getGraphicSupported());
- assertNull("Image field list wasn't set, but getter method returned an object.", msg.getImageFields());
- assertNull("Media clock format list wasn't set, but getter method returned an object.",
- msg.getMediaClockFormats());
- assertNull("Num of custom presets wasn't set, but getter method returned an object.",
- msg.getNumCustomPresetsAvailable());
- assertNull("Screen params wasn't set, but getter method returned an object.", msg.getScreenParams());
- assertNull("Templates available list wasn't set, but getter method returned an object.",
- msg.getTemplatesAvailable());
- assertNull("Text fields list wasn't set, but getter method returned an object.", msg.getTextFields());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ECallInfoTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ECallInfoTests.java
index e817ebb88..82a57869a 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ECallInfoTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ECallInfoTests.java
@@ -11,72 +11,66 @@ import com.smartdevicelink.proxy.rpc.ECallInfo;
import com.smartdevicelink.proxy.rpc.enums.ECallConfirmationStatus;
import com.smartdevicelink.proxy.rpc.enums.VehicleDataNotificationStatus;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.ECallInfo}
+ */
public class ECallInfoTests extends TestCase{
- private static final ECallConfirmationStatus CONFIRMATION_STATUS = ECallConfirmationStatus.CALL_IN_PROGRESS;
- private static final VehicleDataNotificationStatus AUX_NOTIFICATION_STATUS = VehicleDataNotificationStatus.NORMAL;
- private static final VehicleDataNotificationStatus NOTIFICATION_STATUS = VehicleDataNotificationStatus.ACTIVE;
-
- private ECallInfo msg;
+ private ECallInfo msg;
@Override
public void setUp(){
msg = new ECallInfo();
- msg.setAuxECallNotificationStatus(AUX_NOTIFICATION_STATUS);
- msg.setECallConfirmationStatus(CONFIRMATION_STATUS);
- msg.setECallNotificationStatus(NOTIFICATION_STATUS);
- }
-
- public void testAuxECallNotificationStatus(){
- VehicleDataNotificationStatus copy = msg.getAuxECallNotificationStatus();
- assertEquals("Input value didn't match expected value.", AUX_NOTIFICATION_STATUS, copy);
+ msg.setAuxECallNotificationStatus(Test.GENERAL_VEHICLEDATANOTIFICATIONSTATUS);
+ msg.setECallConfirmationStatus(Test.GENERAL_ECALLCONFIRMATIONSTATUS);
+ msg.setECallNotificationStatus(Test.GENERAL_VEHICLEDATANOTIFICATIONSTATUS);
}
- public void testECallNotificationStatus(){
- VehicleDataNotificationStatus copy = msg.getECallNotificationStatus();
- assertEquals("Input value didn't match expected value.", NOTIFICATION_STATUS, copy);
- }
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ VehicleDataNotificationStatus auxEcall = msg.getAuxECallNotificationStatus();
+ VehicleDataNotificationStatus ecallNotify = msg.getECallNotificationStatus();
+ ECallConfirmationStatus ecallConfirm = msg.getECallConfirmationStatus();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_VEHICLEDATANOTIFICATIONSTATUS, auxEcall);
+ assertEquals(Test.MATCH, Test.GENERAL_VEHICLEDATANOTIFICATIONSTATUS, ecallNotify);
+ assertEquals(Test.MATCH, Test.GENERAL_ECALLCONFIRMATIONSTATUS, ecallConfirm);
+
+ // Invalid/Null Tests
+ ECallInfo msg = new ECallInfo();
+ assertNotNull(Test.NOT_NULL, msg);
- public void testECallConfirmationStatus(){
- ECallConfirmationStatus copy = msg.getECallConfirmationStatus();
- assertEquals("Input value didn't match expected value.", CONFIRMATION_STATUS, copy);
+ assertNull(Test.NULL, msg.getECallConfirmationStatus());
+ assertNull(Test.NULL, msg.getECallNotificationStatus());
+ assertNull(Test.NULL, msg.getAuxECallNotificationStatus());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(ECallInfo.KEY_AUX_E_CALL_NOTIFICATION_STATUS, AUX_NOTIFICATION_STATUS);
- reference.put(ECallInfo.KEY_E_CALL_NOTIFICATION_STATUS, NOTIFICATION_STATUS);
- reference.put(ECallInfo.KEY_E_CALL_CONFIRMATION_STATUS, CONFIRMATION_STATUS);
+ reference.put(ECallInfo.KEY_AUX_E_CALL_NOTIFICATION_STATUS, Test.GENERAL_VEHICLEDATANOTIFICATIONSTATUS);
+ reference.put(ECallInfo.KEY_E_CALL_NOTIFICATION_STATUS, Test.GENERAL_VEHICLEDATANOTIFICATIONSTATUS);
+ reference.put(ECallInfo.KEY_E_CALL_CONFIRMATION_STATUS, Test.GENERAL_ECALLCONFIRMATIONSTATUS);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}catch(JSONException e){
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- ECallInfo msg = new ECallInfo();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("ECall confirmation status wasn't set, but getter method returned an object.",
- msg.getECallConfirmationStatus());
- assertNull("ECall notification status wasn't set, but getter method returned an object.",
- msg.getECallNotificationStatus());
- assertNull("Aux ECall notification status wasn't set, but getter method returned an object.",
- msg.getAuxECallNotificationStatus());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/EmergencyEventTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/EmergencyEventTests.java
index 61f2e60fc..6d72e440f 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/EmergencyEventTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/EmergencyEventTests.java
@@ -12,92 +12,76 @@ import com.smartdevicelink.proxy.rpc.enums.EmergencyEventType;
import com.smartdevicelink.proxy.rpc.enums.FuelCutoffStatus;
import com.smartdevicelink.proxy.rpc.enums.VehicleDataEventStatus;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.EmergencyEvent}
+ */
public class EmergencyEventTests extends TestCase{
- // public EmergencyEvent(EmergencyEventType type, FuelCutoffStatus fuelCutoffStatus,
- // VehicleDataEventStatus rolloverEvent, VehicleDataEventStatus multipleEvents, Integer maxChangeVelocity){
-
- private static final EmergencyEventType TYPE = EmergencyEventType.NO_EVENT;
- private static final FuelCutoffStatus FUEL_CUTOFF_STATUS = FuelCutoffStatus.NORMAL_OPERATION;
- private static final VehicleDataEventStatus ROLLOVER_EVENT = VehicleDataEventStatus.NO_EVENT;
- private static final VehicleDataEventStatus MULTIPLE_EVENTS = VehicleDataEventStatus.NO;
- private static final int MAX_CHANGE_VELOCITY = 50;
-
- private EmergencyEvent msg;
+ private EmergencyEvent msg;
@Override
public void setUp(){
msg = new EmergencyEvent();
- msg.setEmergencyEventType(TYPE);
- msg.setFuelCutoffStatus(FUEL_CUTOFF_STATUS);
- msg.setMaximumChangeVelocity(MAX_CHANGE_VELOCITY);
- msg.setMultipleEvents(MULTIPLE_EVENTS);
- msg.setRolloverEvent(ROLLOVER_EVENT);
- }
-
- public void testEmergencyEventType(){
- EmergencyEventType copy = msg.getEmergencyEventType();
- assertEquals("Input value didn't match expected value.", TYPE, copy);
- }
-
- public void testFuelCutoffStatus(){
- FuelCutoffStatus copy = msg.getFuelCutoffStatus();
- assertEquals("Input value didn't match expected value.", FUEL_CUTOFF_STATUS, copy);
- }
-
- public void testMaximumChangeVelocity(){
- int copy = msg.getMaximumChangeVelocity();
- assertEquals("Input value didn't match expected value.", MAX_CHANGE_VELOCITY, copy);
+ msg.setEmergencyEventType(Test.GENERAL_EMERGENCYEVENTTYPE);
+ msg.setFuelCutoffStatus(Test.GENERAL_FUELCUTOFFSTATUS);
+ msg.setMaximumChangeVelocity(Test.GENERAL_INT);
+ msg.setMultipleEvents(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ msg.setRolloverEvent(Test.GENERAL_VEHCILEDATAEVENTSTATUS);
}
- public void testMultipleEvents(){
- VehicleDataEventStatus copy = msg.getMultipleEvents();
- assertEquals("Input value didn't match expected value.", MULTIPLE_EVENTS, copy);
- }
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ EmergencyEventType type = msg.getEmergencyEventType();
+ FuelCutoffStatus cutoffStatus = msg.getFuelCutoffStatus();
+ VehicleDataEventStatus multipleEvents = msg.getMultipleEvents();
+ int changeVelocity = msg.getMaximumChangeVelocity();
+ VehicleDataEventStatus rollover = msg.getRolloverEvent();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_EMERGENCYEVENTTYPE, type);
+ assertEquals(Test.MATCH, Test.GENERAL_FUELCUTOFFSTATUS, cutoffStatus);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, changeVelocity);
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, multipleEvents);
+ assertEquals(Test.MATCH, Test.GENERAL_VEHCILEDATAEVENTSTATUS, rollover);
+
+ // Invalid/Null Tests
+ EmergencyEvent msg = new EmergencyEvent();
+ assertNotNull(Test.NOT_NULL, msg);
- public void testRolloverEvent(){
- VehicleDataEventStatus copy = msg.getRolloverEvent();
- assertEquals("Input value didn't match expected value.", ROLLOVER_EVENT, copy);
+ assertNull(Test.NULL, msg.getEmergencyEventType());
+ assertNull(Test.NULL, msg.getFuelCutoffStatus());
+ assertNull(Test.NULL, msg.getMaximumChangeVelocity());
+ assertNull(Test.NULL, msg.getMultipleEvents());
+ assertNull(Test.NULL, msg.getRolloverEvent());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(EmergencyEvent.KEY_FUEL_CUTOFF_STATUS, FUEL_CUTOFF_STATUS);
- reference.put(EmergencyEvent.KEY_MULTIPLE_EVENTS, MULTIPLE_EVENTS);
- reference.put(EmergencyEvent.KEY_ROLLOVER_EVENT, ROLLOVER_EVENT);
- reference.put(EmergencyEvent.KEY_EMERGENCY_EVENT_TYPE, TYPE);
- reference.put(EmergencyEvent.KEY_MAXIMUM_CHANGE_VELOCITY, MAX_CHANGE_VELOCITY);
+ reference.put(EmergencyEvent.KEY_FUEL_CUTOFF_STATUS, Test.GENERAL_FUELCUTOFFSTATUS);
+ reference.put(EmergencyEvent.KEY_MULTIPLE_EVENTS, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(EmergencyEvent.KEY_ROLLOVER_EVENT, Test.GENERAL_VEHCILEDATAEVENTSTATUS);
+ reference.put(EmergencyEvent.KEY_EMERGENCY_EVENT_TYPE, Test.GENERAL_EMERGENCYEVENTTYPE);
+ reference.put(EmergencyEvent.KEY_MAXIMUM_CHANGE_VELOCITY, Test.GENERAL_INT);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}catch(JSONException e){
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- EmergencyEvent msg = new EmergencyEvent();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Emergency event type wasn't set, but getter method returned an object.",
- msg.getEmergencyEventType());
- assertNull("Fuel cutoff status wasn't set, but getter method returned an object.", msg.getFuelCutoffStatus());
- assertNull("Maximum change velocity wasn't set, but getter method returned an object.",
- msg.getMaximumChangeVelocity());
- assertNull("Multiple events wasn't set, but getter method returned an object.", msg.getMultipleEvents());
- assertNull("Rollover event wasn't set, but getter method returned an object.", msg.getRolloverEvent());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/GPSDataTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/GPSDataTests.java
index 0784d6076..0c6800ea5 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/GPSDataTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/GPSDataTests.java
@@ -11,205 +11,141 @@ import com.smartdevicelink.proxy.rpc.GPSData;
import com.smartdevicelink.proxy.rpc.enums.CompassDirection;
import com.smartdevicelink.proxy.rpc.enums.Dimension;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.GPSData}
+ */
public class GPSDataTests extends TestCase{
- private static final double LATITUDE = 81.823;
- private static final double LONGITUDE = -104.219;
- private static final double ALTITUDE = 1.461;
- private static final double HEADING = 52.739;
- private static final double SPEED = 73.41;
- private static final double PDOP = 1.433;
- private static final double HDOP = 0.137;
- private static final double VDOP = 3.935;
- private static final int UTC_YEAR = 2014;
- private static final int UTC_MONTH = 7;
- private static final int UTC_DAY = 24;
- private static final int UTC_HOURS = 15;
- private static final int UTC_MINUTES = 38;
- private static final int UTC_SECONDS = 42;
- private static final int SATELLITES = 3;
- private static final Dimension DIMENSION = Dimension._2D;
- private static final CompassDirection DIRECTION = CompassDirection.NORTHEAST;
- private static final boolean ACTUAL = true;
-
- private GPSData msg;
+ private GPSData msg;
@Override
public void setUp(){
msg = new GPSData();
- msg.setActual(ACTUAL);
- msg.setAltitude(ALTITUDE);
- msg.setCompassDirection(DIRECTION);
- msg.setDimension(DIMENSION);
- msg.setHdop(HDOP);
- msg.setHeading(HEADING);
- msg.setLatitudeDegrees(LATITUDE);
- msg.setLongitudeDegrees(LONGITUDE);
- msg.setPdop(PDOP);
- msg.setSatellites(SATELLITES);
- msg.setSpeed(SPEED);
- msg.setUtcDay(UTC_DAY);
- msg.setUtcHours(UTC_HOURS);
- msg.setUtcMinutes(UTC_MINUTES);
- msg.setUtcMonth(UTC_MONTH);
- msg.setUtcSeconds(UTC_SECONDS);
- msg.setUtcYear(UTC_YEAR);
- msg.setVdop(VDOP);
-
- }
-
- public void testActual(){
- boolean copy = msg.getActual();
- assertEquals("Input value didn't match expected value.", ACTUAL, copy);
- }
-
- public void testLatitudeDegrees(){
- double copy = msg.getLatitudeDegrees();
- assertEquals("Input value didn't match expected value.", LATITUDE, copy);
- }
-
- public void testLongitudeDegrees(){
- double copy = msg.getLongitudeDegrees();
- assertEquals("Input value didn't match expected value.", LONGITUDE, copy);
- }
-
- public void testAltitude(){
- double copy = msg.getAltitude();
- assertEquals("Input value didn't match expected value.", ALTITUDE, copy);
- }
-
- public void testHeading(){
- double copy = msg.getHeading();
- assertEquals("Input value didn't match expected value.", HEADING, copy);
- }
-
- public void testSpeed(){
- double copy = msg.getSpeed();
- assertEquals("Input value didn't match expected value.", SPEED, copy);
- }
-
- public void testPdop(){
- double copy = msg.getPdop();
- assertEquals("Input value didn't match expected value.", PDOP, copy);
- }
-
- public void testHdop(){
- double copy = msg.getHdop();
- assertEquals("Input value didn't match expected value.", HDOP, copy);
- }
-
- public void testVdop(){
- double copy = msg.getVdop();
- assertEquals("Input value didn't match expected value.", VDOP, copy);
- }
-
- public void testUtcYear(){
- int copy = msg.getUtcYear();
- assertEquals("Input value didn't match expected value.", UTC_YEAR, copy);
- }
-
- public void testUtcMinutes(){
- int copy = msg.getUtcMinutes();
- assertEquals("Input value didn't match expected value.", UTC_MINUTES, copy);
- }
-
- public void testUtcMonths(){
- int copy = msg.getUtcMonth();
- assertEquals("Input value didn't match expected value.", UTC_MONTH, copy);
- }
-
- public void testUtcDay(){
- int copy = msg.getUtcDay();
- assertEquals("Input value didn't match expected value.", UTC_DAY, copy);
- }
-
- public void testUtcHours(){
- int copy = msg.getUtcHours();
- assertEquals("Input value didn't match expected value.", UTC_HOURS, copy);
- }
-
- public void testUtcSeconds(){
- int copy = msg.getUtcSeconds();
- assertEquals("Input value didn't match expected value.", UTC_SECONDS, copy);
- }
-
- public void testSatellites(){
- int copy = msg.getSatellites();
- assertEquals("Input value didn't match expected value.", SATELLITES, copy);
- }
-
- public void testDimension(){
- Dimension copy = msg.getDimension();
- assertEquals("Input value didn't match expected value.", DIMENSION, copy);
- }
-
- public void testCompassDirection(){
- CompassDirection copy = msg.getCompassDirection();
- assertEquals("Input value didn't match expected value.", DIRECTION, copy);
+ msg.setActual(Test.GENERAL_BOOLEAN);
+ msg.setAltitude(Test.GENERAL_DOUBLE);
+ msg.setCompassDirection(Test.GENERAL_COMPASSDIRECTION);
+ msg.setDimension(Test.GENERAL_DIMENSION);
+ msg.setHdop(Test.GENERAL_DOUBLE);
+ msg.setHeading(Test.GENERAL_DOUBLE);
+ msg.setLatitudeDegrees(Test.GENERAL_DOUBLE);
+ msg.setLongitudeDegrees(Test.GENERAL_DOUBLE);
+ msg.setPdop(Test.GENERAL_DOUBLE);
+ msg.setSatellites(Test.GENERAL_INT);
+ msg.setSpeed(Test.GENERAL_DOUBLE);
+ msg.setUtcDay(Test.GENERAL_INT);
+ msg.setUtcHours(Test.GENERAL_INT);
+ msg.setUtcMinutes(Test.GENERAL_INT);
+ msg.setUtcMonth(Test.GENERAL_INT);
+ msg.setUtcSeconds(Test.GENERAL_INT);
+ msg.setUtcYear(Test.GENERAL_INT);
+ msg.setVdop(Test.GENERAL_DOUBLE);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ boolean actual = msg.getActual();
+ double latitude = msg.getLatitudeDegrees();
+ double longitude = msg.getLongitudeDegrees();
+ double altitude = msg.getAltitude();
+ double heading = msg.getHeading();
+ double speed = msg.getSpeed();
+ double pdop = msg.getPdop();
+ double hdop = msg.getHdop();
+ double vdop = msg.getVdop();
+ int utcYear = msg.getUtcYear();
+ int utcMin = msg.getUtcMinutes();
+ int utcMonths = msg.getUtcMonth();
+ int utcDay = msg.getUtcDay();
+ int utcHours = msg.getUtcHours();
+ int utcSec = msg.getUtcSeconds();
+ int satellites = msg.getSatellites();
+ Dimension dimension = msg.getDimension();
+ CompassDirection direction = msg.getCompassDirection();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, actual);
+ assertEquals(Test.MATCH, Test.GENERAL_DOUBLE, latitude);
+ assertEquals(Test.MATCH, Test.GENERAL_DOUBLE, longitude);
+ assertEquals(Test.MATCH, Test.GENERAL_DOUBLE, altitude);
+ assertEquals(Test.MATCH, Test.GENERAL_DOUBLE, heading);
+ assertEquals(Test.MATCH, Test.GENERAL_DOUBLE, speed);
+ assertEquals(Test.MATCH, Test.GENERAL_DOUBLE, pdop);
+ assertEquals(Test.MATCH, Test.GENERAL_DOUBLE, hdop);
+ assertEquals(Test.MATCH, Test.GENERAL_DOUBLE, vdop);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, utcYear);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, utcMin);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, utcMonths);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, utcDay);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, utcHours);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, utcSec);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, satellites);
+ assertEquals(Test.MATCH, Test.GENERAL_DIMENSION, dimension);
+ assertEquals(Test.MATCH, Test.GENERAL_COMPASSDIRECTION, direction);
+
+ // Invalid/Null Tests
+ GPSData msg = new GPSData();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getActual());
+ assertNull(Test.NULL, msg.getAltitude());
+ assertNull(Test.NULL, msg.getCompassDirection());
+ assertNull(Test.NULL, msg.getDimension());
+ assertNull(Test.NULL, msg.getHdop());
+ assertNull(Test.NULL, msg.getHeading());
+ assertNull(Test.NULL, msg.getLatitudeDegrees());
+ assertNull(Test.NULL, msg.getLongitudeDegrees());
+ assertNull(Test.NULL, msg.getPdop());
+ assertNull(Test.NULL, msg.getSatellites());
+ assertNull(Test.NULL, msg.getSpeed());
+ assertNull(Test.NULL, msg.getUtcDay());
+ assertNull(Test.NULL, msg.getUtcHours());
+ assertNull(Test.NULL, msg.getUtcMinutes());
+ assertNull(Test.NULL, msg.getUtcMonth());
+ assertNull(Test.NULL, msg.getUtcSeconds());
+ assertNull(Test.NULL, msg.getUtcYear());
+ assertNull(Test.NULL, msg.getVdop());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(GPSData.KEY_ACTUAL, ACTUAL);
- reference.put(GPSData.KEY_LATITUDE_DEGREES, LATITUDE);
- reference.put(GPSData.KEY_LONGITUDE_DEGREES, LONGITUDE);
- reference.put(GPSData.KEY_ALTITUDE, ALTITUDE);
- reference.put(GPSData.KEY_HEADING, HEADING);
- reference.put(GPSData.KEY_SPEED, SPEED);
- reference.put(GPSData.KEY_PDOP, PDOP);
- reference.put(GPSData.KEY_HDOP, HDOP);
- reference.put(GPSData.KEY_VDOP, VDOP);
- reference.put(GPSData.KEY_UTC_YEAR, UTC_YEAR);
- reference.put(GPSData.KEY_UTC_MONTH, UTC_MONTH);
- reference.put(GPSData.KEY_UTC_HOURS, UTC_HOURS);
- reference.put(GPSData.KEY_UTC_DAY, UTC_DAY);
- reference.put(GPSData.KEY_UTC_MINUTES, UTC_MINUTES);
- reference.put(GPSData.KEY_UTC_SECONDS, UTC_SECONDS);
- reference.put(GPSData.KEY_SATELLITES, SATELLITES);
- reference.put(GPSData.KEY_DIMENSION, DIMENSION);
- reference.put(GPSData.KEY_COMPASS_DIRECTION, DIRECTION);
+ reference.put(GPSData.KEY_ACTUAL, Test.GENERAL_BOOLEAN);
+ reference.put(GPSData.KEY_LATITUDE_DEGREES, Test.GENERAL_DOUBLE);
+ reference.put(GPSData.KEY_LONGITUDE_DEGREES, Test.GENERAL_DOUBLE);
+ reference.put(GPSData.KEY_ALTITUDE, Test.GENERAL_DOUBLE);
+ reference.put(GPSData.KEY_HEADING, Test.GENERAL_DOUBLE);
+ reference.put(GPSData.KEY_SPEED, Test.GENERAL_DOUBLE);
+ reference.put(GPSData.KEY_PDOP, Test.GENERAL_DOUBLE);
+ reference.put(GPSData.KEY_HDOP, Test.GENERAL_DOUBLE);
+ reference.put(GPSData.KEY_VDOP, Test.GENERAL_DOUBLE);
+ reference.put(GPSData.KEY_UTC_YEAR, Test.GENERAL_INT);
+ reference.put(GPSData.KEY_UTC_MONTH, Test.GENERAL_INT);
+ reference.put(GPSData.KEY_UTC_HOURS, Test.GENERAL_INT);
+ reference.put(GPSData.KEY_UTC_DAY, Test.GENERAL_INT);
+ reference.put(GPSData.KEY_UTC_MINUTES, Test.GENERAL_INT);
+ reference.put(GPSData.KEY_UTC_SECONDS, Test.GENERAL_INT);
+ reference.put(GPSData.KEY_SATELLITES, Test.GENERAL_INT);
+ reference.put(GPSData.KEY_DIMENSION, Test.GENERAL_DIMENSION);
+ reference.put(GPSData.KEY_COMPASS_DIRECTION, Test.GENERAL_COMPASSDIRECTION);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}catch(JSONException e){
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- GPSData msg = new GPSData();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Actual wasn't set, but getter method returned an object.", msg.getActual());
- assertNull("Altitude wasn't set, but getter method returned an object.", msg.getAltitude());
- assertNull("Compass direction wasn't set, but getter method returned an object.", msg.getCompassDirection());
- assertNull("Dimension wasn't set, but getter method returned an object.", msg.getDimension());
- assertNull("Hdop wasn't set, but getter method returned an object.", msg.getHdop());
- assertNull("Heading wasn't set, but getter method returned an object.", msg.getHeading());
- assertNull("Latitude degrees wasn't set, but getter method returned an object.", msg.getLatitudeDegrees());
- assertNull("Longitude degrees wasn't set, but getter method returned an object.", msg.getLongitudeDegrees());
- assertNull("Pdop wasn't set, but getter method returned an object.", msg.getPdop());
- assertNull("Satellites wasn't set, but getter method returned an object.", msg.getSatellites());
- assertNull("Speed wasn't set, but getter method returned an object.", msg.getSpeed());
- assertNull("UTC day wasn't set, but getter method returned an object.", msg.getUtcDay());
- assertNull("UTC hours wasn't set, but getter method returned an object.", msg.getUtcHours());
- assertNull("UTC minutes wasn't set, but getter method returned an object.", msg.getUtcMinutes());
- assertNull("UTC month wasn't set, but getter method returned an object.", msg.getUtcMonth());
- assertNull("UTC seconds wasn't set, but getter method returned an object.", msg.getUtcSeconds());
- assertNull("UTC year wasn't set, but getter method returned an object.", msg.getUtcYear());
- assertNull("Vdop wasn't set, but getter method returned an object.", msg.getVdop());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/HMIPermissionsTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/HMIPermissionsTests.java
index 626547a8a..fd82505f2 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/HMIPermissionsTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/HMIPermissionsTests.java
@@ -1,6 +1,5 @@
package com.smartdevicelink.test.rpc.datatypes;
-import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
@@ -12,55 +11,60 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.HMIPermissions;
import com.smartdevicelink.proxy.rpc.enums.HMILevel;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.HMIPermissions}
+ */
public class HMIPermissionsTests extends TestCase{
- private final List<HMILevel> ALLOWED_LIST = Arrays.asList(new HMILevel[] { HMILevel.HMI_FULL,
- HMILevel.HMI_BACKGROUND });
-
- private final List<HMILevel> USER_DISALLOWED_LIST = Arrays.asList(new HMILevel[] { HMILevel.HMI_LIMITED,
- HMILevel.HMI_NONE });
-
- private HMIPermissions msg;
+ private HMIPermissions msg;
@Override
public void setUp(){
msg = new HMIPermissions();
- msg.setAllowed(ALLOWED_LIST);
- msg.setUserDisallowed(USER_DISALLOWED_LIST);
+ msg.setAllowed(Test.GENERAL_HMILEVEL_LIST);
+ msg.setUserDisallowed(Test.GENERAL_HMILEVEL_LIST);
}
- public void testAllowed(){
- List<HMILevel> copy = msg.getAllowed();
-
- assertEquals("List size didn't match expected size.", ALLOWED_LIST.size(), copy.size());
-
- for(int i = 0; i < ALLOWED_LIST.size(); i++){
- assertEquals("Input value didn't match expected value.", ALLOWED_LIST.get(i), copy.get(i));
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ List<HMILevel> allowed = msg.getAllowed();
+ List<HMILevel> disallowed = msg.getUserDisallowed();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_HMILEVEL_LIST.size(), allowed.size());
+ assertEquals(Test.MATCH, Test.GENERAL_HMILEVEL_LIST.size(), disallowed.size());
+
+ for(int i = 0; i < Test.GENERAL_HMILEVEL_LIST.size(); i++){
+ assertEquals(Test.MATCH, Test.GENERAL_HMILEVEL_LIST.get(i), allowed.get(i));
}
- }
-
- public void testUserDisallowed(){
- List<HMILevel> copy = msg.getUserDisallowed();
-
- assertEquals("List size didn't match expected size.", USER_DISALLOWED_LIST.size(), copy.size());
-
- for(int i = 0; i < USER_DISALLOWED_LIST.size(); i++){
- assertEquals("Input value didn't match expected value.", USER_DISALLOWED_LIST.get(i), copy.get(i));
+ for(int i = 0; i < Test.GENERAL_HMILEVEL_LIST.size(); i++){
+ assertEquals(Test.MATCH, Test.GENERAL_HMILEVEL_LIST.get(i), disallowed.get(i));
}
+
+ // Invalid/Null Tests
+ HMIPermissions msg = new HMIPermissions();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getAllowed());
+ assertNull(Test.NULL, msg.getUserDisallowed());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(HMIPermissions.KEY_ALLOWED, JsonUtils.createJsonArray(ALLOWED_LIST));
- reference.put(HMIPermissions.KEY_USER_DISALLOWED, JsonUtils.createJsonArray(USER_DISALLOWED_LIST));
+ reference.put(HMIPermissions.KEY_ALLOWED, Test.JSON_HMILEVELS);
+ reference.put(HMIPermissions.KEY_USER_DISALLOWED, Test.JSON_HMILEVELS);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
@@ -68,22 +72,13 @@ public class HMIPermissionsTests extends TestCase{
List<String> referenceList = JsonUtils.readStringListFromJsonObject(reference, key);
List<String> underTestList = JsonUtils.readStringListFromJsonObject(underTest, key);
- assertEquals("JSON list size didn't match expected size.", referenceList.size(), underTestList.size());
+ assertEquals(Test.MATCH, referenceList.size(), underTestList.size());
for(int i = 0; i < referenceList.size(); i++){
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- referenceList.get(i), underTestList.get(i));
+ assertEquals(Test.MATCH, referenceList.get(i), underTestList.get(i));
}
}
- }catch(JSONException e){
- /* do nothing */
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- HMIPermissions msg = new HMIPermissions();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Allowed list wasn't set, but getter method returned an object.", msg.getAllowed());
- assertNull("User disallowed list wasn't set, but getter method returned an object.", msg.getUserDisallowed());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/HeadLampStatusTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/HeadLampStatusTests.java
index 16c5151da..277786344 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/HeadLampStatusTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/HeadLampStatusTests.java
@@ -10,70 +10,66 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.HeadLampStatus;
import com.smartdevicelink.proxy.rpc.enums.AmbientLightStatus;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.HeadLampStatus}
+ */
public class HeadLampStatusTests extends TestCase{
-
- private static final boolean LOW_BEAMS_ON = false;
- private static final boolean HIGH_BEAMS_ON = true;
- private static final AmbientLightStatus AMBIENT_LIGHT_STATUS = AmbientLightStatus.NIGHT;
-
- private HeadLampStatus msg;
+
+ private HeadLampStatus msg;
@Override
public void setUp(){
msg = new HeadLampStatus();
- msg.setAmbientLightStatus(AMBIENT_LIGHT_STATUS);
- msg.setLowBeamsOn(LOW_BEAMS_ON);
- msg.setHighBeamsOn(HIGH_BEAMS_ON);
- }
-
- public void testLowBeamsOn(){
- boolean copy = msg.getLowBeamsOn();
- assertEquals("Input value didn't match expected value.", LOW_BEAMS_ON, copy);
+ msg.setAmbientLightStatus(Test.GENERAL_AMBIENTLIGHTSTATUS);
+ msg.setLowBeamsOn(Test.GENERAL_BOOLEAN);
+ msg.setHighBeamsOn(Test.GENERAL_BOOLEAN);
}
- public void testHighBeamsOn(){
- boolean copy = msg.getHighBeamsOn();
- assertEquals("Input value didn't match expected value.", HIGH_BEAMS_ON, copy);
- }
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ boolean lowBeams = msg.getLowBeamsOn();
+ boolean highBeams = msg.getHighBeamsOn();
+ AmbientLightStatus ambientLights = msg.getAmbientLightStatus();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_AMBIENTLIGHTSTATUS, ambientLights);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, highBeams);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, lowBeams);
+
+ // Invalid/Null Tests
+ HeadLampStatus msg = new HeadLampStatus();
+ assertNotNull(Test.NOT_NULL, msg);
- public void testAmbientLightStatus(){
- AmbientLightStatus copy = msg.getAmbientLightStatus();
- assertEquals("Input value didn't match expected value.", AMBIENT_LIGHT_STATUS, copy);
+ assertNull(Test.NULL, msg.getLowBeamsOn());
+ assertNull(Test.NULL, msg.getHighBeamsOn());
+ assertNull(Test.NULL, msg.getAmbientLightStatus());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(HeadLampStatus.KEY_HIGH_BEAMS_ON, HIGH_BEAMS_ON);
- reference.put(HeadLampStatus.KEY_LOW_BEAMS_ON, LOW_BEAMS_ON);
- reference.put(HeadLampStatus.KEY_AMBIENT_LIGHT_SENSOR_STATUS, AMBIENT_LIGHT_STATUS);
+ reference.put(HeadLampStatus.KEY_HIGH_BEAMS_ON, Test.GENERAL_BOOLEAN);
+ reference.put(HeadLampStatus.KEY_LOW_BEAMS_ON, Test.GENERAL_BOOLEAN);
+ reference.put(HeadLampStatus.KEY_AMBIENT_LIGHT_SENSOR_STATUS, Test.GENERAL_AMBIENTLIGHTSTATUS);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
- }catch(JSONException e){
- /* do nothing */
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- HeadLampStatus msg = new HeadLampStatus();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Low beams on wasn't set, but getter method returned an object.", msg.getLowBeamsOn());
- assertNull("High beams on wasn't set, but getter method returned an object.", msg.getHighBeamsOn());
- assertNull("Ambient light status wasn't set, but getter method returned an object.",
- msg.getAmbientLightStatus());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/HeadersTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/HeadersTests.java
index ac4492bdb..09c69022f 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/HeadersTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/HeadersTests.java
@@ -9,132 +9,101 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.Headers;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.Headers}
+ */
public class HeadersTests extends TestCase{
- private static final String CONTENT_TYPE = "text/html";
- private static final String REQUEST_METHOD = "GET";
- private static final String CHARSET = "ISO-8859-4";
- private static final int CONNECTION_TIMEOUT = 200;
- private static final int READ_TIMEOUT = 100;
- private static final int CONTENT_LENGTH = 5029;
- private static final boolean DO_OUTPUT = true;
- private static final boolean DO_INPUT = false;
- private static final boolean USES_CACHES = false;
- private static final boolean INSTANCE_FOLLOW_REDIRECTS = true;
-
- private Headers msg;
+ private Headers msg;
@Override
public void setUp(){
msg = new Headers();
- msg.setCharset(CHARSET);
- msg.setConnectTimeout(CONNECTION_TIMEOUT);
- msg.setContentLength(CONTENT_LENGTH);
- msg.setContentType(CONTENT_TYPE);
- msg.setDoInput(DO_INPUT);
- msg.setDoOutput(DO_OUTPUT);
- msg.setInstanceFollowRedirects(INSTANCE_FOLLOW_REDIRECTS);
- msg.setReadTimeout(READ_TIMEOUT);
- msg.setRequestMethod(REQUEST_METHOD);
- msg.setUseCaches(USES_CACHES);
- }
-
- public void testCharset(){
- String copy = msg.getCharset();
- assertEquals("Input value didn't match expected value.", CHARSET, copy);
- }
-
- public void testContentType(){
- String copy = msg.getContentType();
- assertEquals("Input value didn't match expected value.", CONTENT_TYPE, copy);
- }
-
- public void testRequestMethod(){
- String copy = msg.getRequestMethod();
- assertEquals("Input value didn't match expected value.", REQUEST_METHOD, copy);
- }
-
- public void testConnectTimeout(){
- int copy = msg.getConnectTimeout();
- assertEquals("Input value didn't match expected value.", CONNECTION_TIMEOUT, copy);
- }
-
- public void testReadTimeout(){
- int copy = msg.getReadTimeout();
- assertEquals("Input value didn't match expected value.", READ_TIMEOUT, copy);
- }
-
- public void testContentLength(){
- int copy = msg.getContentLength();
- assertEquals("Input value didn't match expected value.", CONTENT_LENGTH, copy);
+ msg.setCharset(Test.GENERAL_STRING);
+ msg.setConnectTimeout(Test.GENERAL_INT);
+ msg.setContentLength(Test.GENERAL_INT);
+ msg.setContentType(Test.GENERAL_STRING);
+ msg.setDoInput(Test.GENERAL_BOOLEAN);
+ msg.setDoOutput(Test.GENERAL_BOOLEAN);
+ msg.setInstanceFollowRedirects(Test.GENERAL_BOOLEAN);
+ msg.setReadTimeout(Test.GENERAL_INT);
+ msg.setRequestMethod(Test.GENERAL_STRING);
+ msg.setUseCaches(Test.GENERAL_BOOLEAN);
}
- public void testDoOutput(){
- boolean copy = msg.getDoOutput();
- assertEquals("Input value didn't match expected value.", DO_OUTPUT, copy);
- }
-
- public void testDoInput(){
- boolean copy = msg.getDoInput();
- assertEquals("Input value didn't match expected value.", DO_INPUT, copy);
- }
-
- public void testUseCache(){
- boolean copy = msg.getUseCaches();
- assertEquals("Input value didn't match expected value.", USES_CACHES, copy);
- }
-
- public void testInstanceFollowRedirects(){
- boolean copy = msg.getInstanceFollowRedirects();
- assertEquals("Input value didn't match expected value.", INSTANCE_FOLLOW_REDIRECTS, copy);
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ String charset = msg.getCharset();
+ String contentType = msg.getContentType();
+ String requestMode = msg.getRequestMethod();
+ int connectTimeout = msg.getConnectTimeout();
+ int readTimeout = msg.getReadTimeout();
+ int contentLength = msg.getContentLength();
+ boolean doOutput = msg.getDoOutput();
+ boolean doInput = msg.getDoInput();
+ boolean useCache = msg.getUseCaches();
+ boolean instanceFollow = msg.getInstanceFollowRedirects();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, charset);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, contentType);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, requestMode);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, connectTimeout);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, readTimeout);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, contentLength);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, doOutput);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, doInput);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, useCache);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, instanceFollow);
+
+ // Invalid/Null Tests
+ Headers msg = new Headers();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getCharset());
+ assertNull(Test.NULL, msg.getConnectTimeout());
+ assertNull(Test.NULL, msg.getContentLength());
+ assertNull(Test.NULL, msg.getContentType());
+ assertNull(Test.NULL, msg.getDoInput());
+ assertNull(Test.NULL, msg.getDoOutput());
+ assertNull(Test.NULL, msg.getInstanceFollowRedirects());
+ assertNull(Test.NULL, msg.getReadTimeout());
+ assertNull(Test.NULL, msg.getRequestMethod());
+ assertNull(Test.NULL, msg.getUseCaches());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(Headers.KEY_CHARSET, CHARSET);
- reference.put(Headers.KEY_CONTENT_TYPE, CONTENT_TYPE);
- reference.put(Headers.KEY_REQUEST_METHOD, REQUEST_METHOD);
- reference.put(Headers.KEY_CONNECT_TIMEOUT, CONNECTION_TIMEOUT);
- reference.put(Headers.KEY_READ_TIMEOUT, READ_TIMEOUT);
- reference.put(Headers.KEY_CONTENT_LENGTH, CONTENT_LENGTH);
- reference.put(Headers.KEY_DO_OUTPUT, DO_OUTPUT);
- reference.put(Headers.KEY_DO_INPUT, DO_INPUT);
- reference.put(Headers.KEY_USE_CACHES, USES_CACHES);
- reference.put(Headers.KEY_INSTANCE_FOLLOW_REDIRECTS, INSTANCE_FOLLOW_REDIRECTS);
+ reference.put(Headers.KEY_CHARSET, Test.GENERAL_STRING);
+ reference.put(Headers.KEY_CONTENT_TYPE, Test.GENERAL_STRING);
+ reference.put(Headers.KEY_REQUEST_METHOD, Test.GENERAL_STRING);
+ reference.put(Headers.KEY_CONNECT_TIMEOUT, Test.GENERAL_INT);
+ reference.put(Headers.KEY_READ_TIMEOUT, Test.GENERAL_INT);
+ reference.put(Headers.KEY_CONTENT_LENGTH, Test.GENERAL_INT);
+ reference.put(Headers.KEY_DO_OUTPUT, Test.GENERAL_BOOLEAN);
+ reference.put(Headers.KEY_DO_INPUT, Test.GENERAL_BOOLEAN);
+ reference.put(Headers.KEY_USE_CACHES, Test.GENERAL_BOOLEAN);
+ reference.put(Headers.KEY_INSTANCE_FOLLOW_REDIRECTS, Test.GENERAL_BOOLEAN);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}catch(JSONException e){
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- Headers msg = new Headers();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Charset wasn't set, but getter method returned an object.", msg.getCharset());
- assertNull("Connection timeout wasn't set, but getter method returned an object.", msg.getConnectTimeout());
- assertNull("Content length wasn't set, but getter method returned an object.", msg.getContentLength());
- assertNull("Content type wasn't set, but getter method returned an object.", msg.getContentType());
- assertNull("Do input wasn't set, but getter method returned an object.", msg.getDoInput());
- assertNull("Do output wasn't set, but getter method returned an object.", msg.getDoOutput());
- assertNull("Follow wasn't set, but getter method returned an object.", msg.getInstanceFollowRedirects());
- assertNull("Read timeout wasn't set, but getter method returned an object.", msg.getReadTimeout());
- assertNull("Request method wasn't set, but getter method returned an object.", msg.getRequestMethod());
- assertNull("Uses caches wasn't set, but getter method returned an object.", msg.getUseCaches());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ImageFieldTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ImageFieldTests.java
index 25eaaabc7..e1c30aa6e 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ImageFieldTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ImageFieldTests.java
@@ -17,66 +17,59 @@ import com.smartdevicelink.proxy.rpc.ImageResolution;
import com.smartdevicelink.proxy.rpc.enums.FileType;
import com.smartdevicelink.proxy.rpc.enums.ImageFieldName;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
import com.smartdevicelink.test.Validator;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.ImageField}
+ */
public class ImageFieldTests extends TestCase{
- private static final int RESOLUTION_HEIGHT = 1920;
- private static final int RESOLUTION_WIDTH = 1080;
- private static final FileType IMAGE_TYPE_SUPPORTED = FileType.GRAPHIC_PNG;
- private static final ImageFieldName IMAGE_FIELD_NAME = ImageFieldName.choiceImage;
-
- private ImageField msg;
-
- private ImageResolution imageResolution;
+ private ImageField msg;
@Override
public void setUp(){
msg = new ImageField();
- imageResolution = new ImageResolution();
- imageResolution.setResolutionHeight(RESOLUTION_HEIGHT);
- imageResolution.setResolutionWidth(RESOLUTION_WIDTH);
- msg.setImageResolution(imageResolution);
- List<FileType> list = new ArrayList<FileType>();
- list.add(IMAGE_TYPE_SUPPORTED);
- msg.setImageTypeSupported(list);
- msg.setName(IMAGE_FIELD_NAME);
- }
-
- public void testImageResolution(){
- ImageResolution copy = msg.getImageResolution();
- assertTrue("Input value didn't match expected value.", Validator.validateImageResolution(imageResolution, copy));
+ msg.setImageResolution(Test.GENERAL_IMAGERESOLUTION);
+ msg.setImageTypeSupported(Test.GENERAL_FILETYPE_LIST);
+ msg.setName(Test.GENERAL_IMAGEFIELDNAME);
}
- public void testImageTypeSupported(){
- FileType copy = msg.getImageTypeSupported().get(0);
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ ImageResolution imageRes = msg.getImageResolution();
+ FileType imageType = msg.getImageTypeSupported().get(0);
+ ImageFieldName name = msg.getName();
- assertEquals("FileType doesn't match expected FileType.", IMAGE_TYPE_SUPPORTED, copy);
- }
+ // Valid Tests
+ assertTrue(Test.TRUE, Validator.validateImageResolution(Test.GENERAL_IMAGERESOLUTION, imageRes));
+ assertEquals(Test.MATCH, Test.GENERAL_FILETYPE_LIST, imageType);
+ assertEquals(Test.MATCH, Test.GENERAL_IMAGEFIELDNAME, name);
+
+ // Invalid/Null Tests
+ ImageField msg = new ImageField();
+ assertNotNull(Test.NOT_NULL, msg);
- public void testName(){
- ImageFieldName copy = msg.getName();
- assertEquals("Input value didn't match expected value.", IMAGE_FIELD_NAME, copy);
+ assertNull(Test.NULL, msg.getImageResolution());
+ assertNull(Test.NULL, msg.getImageTypeSupported());
+ assertNull(Test.NULL, msg.getName());
}
public void testJson(){
JSONObject reference = new JSONObject();
- JSONObject imageResolutionJson = new JSONObject();
try{
- imageResolutionJson.put(ImageResolution.KEY_RESOLUTION_HEIGHT, RESOLUTION_HEIGHT);
- imageResolutionJson.put(ImageResolution.KEY_RESOLUTION_WIDTH, RESOLUTION_WIDTH);
-
- reference.put(ImageField.KEY_IMAGE_RESOLUTION, imageResolutionJson);
- JSONArray imageTypesArray = new JSONArray();
- imageTypesArray.put(IMAGE_TYPE_SUPPORTED);
- reference.put(ImageField.KEY_IMAGE_TYPE_SUPPORTED, imageTypesArray);
- reference.put(ImageField.KEY_NAME, IMAGE_FIELD_NAME);
+ reference.put(ImageField.KEY_IMAGE_RESOLUTION, Test.JSON_IMAGERESOLUTION);
+ reference.put(ImageField.KEY_IMAGE_TYPE_SUPPORTED, JsonUtils.createJsonArray(Test.GENERAL_FILETYPE_LIST));
+ reference.put(ImageField.KEY_NAME, Test.GENERAL_IMAGEFIELDNAME);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
@@ -86,46 +79,27 @@ public class ImageFieldTests extends TestCase{
JSONObject objectEquals = JsonUtils.readJsonObjectFromJsonObject(reference, key);
JSONObject testEquals = JsonUtils.readJsonObjectFromJsonObject(underTest, key);
Hashtable<String, Object> hashReference = JsonRPCMarshaller.deserializeJSONObject(objectEquals);
- Hashtable<String, Object> hashTest = JsonRPCMarshaller.deserializeJSONObject(testEquals);
-
- assertTrue("Image resolution value didn't match expected value.",
- Validator.validateImageResolution( new ImageResolution(hashReference), new ImageResolution(hashTest)));
- }
- else if(key.equals(ImageField.KEY_IMAGE_TYPE_SUPPORTED)) {
+ Hashtable<String, Object> hashTest = JsonRPCMarshaller.deserializeJSONObject(testEquals);
+ assertTrue(Test.TRUE, Validator.validateImageResolution( new ImageResolution(hashReference), new ImageResolution(hashTest)));
+ } else if(key.equals(ImageField.KEY_IMAGE_TYPE_SUPPORTED)) {
JSONArray imageTypeArrayReference = JsonUtils.readJsonArrayFromJsonObject(reference, key);
JSONArray imageTypeArrayTest = JsonUtils.readJsonArrayFromJsonObject(underTest, key);
List<FileType> imageTypeListReference = new ArrayList<FileType>();
List<FileType> imageTypeListTest = new ArrayList<FileType>();
- assertEquals("Reference and test array sizes not equal", imageTypeArrayReference.length(), imageTypeArrayTest.length());
+ assertEquals(Test.MATCH, imageTypeArrayReference.length(), imageTypeArrayTest.length());
for (int index = 0 ; index < imageTypeArrayReference.length(); index++) {
imageTypeListReference.add( (FileType)imageTypeArrayReference.get(index) );
imageTypeListTest.add( (FileType)imageTypeArrayTest.get(index) );
- }
-
- assertTrue("Image type test list does not match reference list",
- imageTypeListReference.containsAll(imageTypeListTest) && imageTypeListTest.containsAll(imageTypeListReference));
-
- }
- else{
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ }
+ assertTrue(Test.TRUE, imageTypeListReference.containsAll(imageTypeListTest) && imageTypeListTest.containsAll(imageTypeListReference));
+ } else{
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}
}catch(JSONException e){
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- ImageField msg = new ImageField();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Image resolution wasn't set, but getter method returned an object.", msg.getImageResolution());
- assertNull("Image type supported wasn't set, but getter method returned an object.",
- msg.getImageTypeSupported());
- assertNull("Image name wasn't set, but getter method returned an object.", msg.getName());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ImageResolutionTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ImageResolutionTests.java
index 4f2d8d307..83f3126cf 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ImageResolutionTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ImageResolutionTests.java
@@ -9,60 +9,62 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.ImageResolution;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
-public class ImageResolutionTests extends TestCase{
- private static final int HEIGHT = 1920;
- private static final int WIDTH = 1080;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.ImageResolution}
+ */
+public class ImageResolutionTests extends TestCase{
- private ImageResolution msg;
+ private ImageResolution msg;
@Override
public void setUp(){
msg = new ImageResolution();
- msg.setResolutionHeight(HEIGHT);
- msg.setResolutionWidth(WIDTH);
+ msg.setResolutionHeight(Test.GENERAL_INT);
+ msg.setResolutionWidth(Test.GENERAL_INT);
}
- public void testHeight(){
- int copy = msg.getResolutionHeight();
- assertEquals("Input value didn't match expected value.", HEIGHT, copy);
- }
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ int height = msg.getResolutionHeight();
+ int width = msg.getResolutionWidth();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_INT, height);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, width);
+
+ // Invalid/Null Tests
+ ImageResolution msg = new ImageResolution();
+ assertNotNull(Test.NOT_NULL, msg);
- public void testWidth(){
- int copy = msg.getResolutionWidth();
- assertEquals("Input value didn't match expected value.", WIDTH, copy);
+ assertNull(Test.NULL, msg.getResolutionHeight());
+ assertNull(Test.NULL, msg.getResolutionWidth());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(ImageResolution.KEY_RESOLUTION_HEIGHT, HEIGHT);
- reference.put(ImageResolution.KEY_RESOLUTION_WIDTH, WIDTH);
+ reference.put(ImageResolution.KEY_RESOLUTION_HEIGHT, Test.GENERAL_INT);
+ reference.put(ImageResolution.KEY_RESOLUTION_WIDTH, Test.GENERAL_INT);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
- }catch(JSONException e){
- /* do nothing */
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- ImageResolution msg = new ImageResolution();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Height wasn't set, but getter method returned an object.", msg.getResolutionHeight());
- assertNull("Width wasn't set, but getter method returned an object.", msg.getResolutionWidth());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ImageTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ImageTests.java
index fd0ac9735..fdbcc8590 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ImageTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ImageTests.java
@@ -10,70 +10,62 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.Image;
import com.smartdevicelink.proxy.rpc.enums.ImageType;
import com.smartdevicelink.test.JsonUtils;
-import com.smartdevicelink.test.Validator;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.Image}
+ */
public class ImageTests extends TestCase{
- private static final ImageType IMAGE_TYPE = ImageType.DYNAMIC;
- private static final String IMAGE_NAME = "image_name.png";
- private static final byte[] IMAGE_DATA = new byte[] { 4, 7, 1, 8, 14, 10, 0, 0, 3 };
-
- private Image msg;
+ private Image msg;
@Override
public void setUp(){
msg = new Image();
- msg.setImageType(IMAGE_TYPE);
- msg.setValue(IMAGE_NAME);
- msg.setBulkData(IMAGE_DATA);
- }
-
- public void testImageType(){
- ImageType copy = msg.getImageType();
- assertEquals("Input value didn't match expected value.", IMAGE_TYPE, copy);
+ msg.setImageType(Test.GENERAL_IMAGETYPE);
+ msg.setValue(Test.GENERAL_STRING);
}
- public void testValue(){
- String copy = msg.getValue();
- assertEquals("Input value didn't match expected value.", IMAGE_NAME, copy);
- }
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ ImageType imageType = msg.getImageType();
+ String value = msg.getValue();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_IMAGETYPE, imageType);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, value);
+
+ // Invalid/Null Tests
+ Image msg = new Image();
+ assertNotNull(Test.NOT_NULL, msg);
- public void testBulkData(){
- byte[] copy = msg.getBulkData();
- assertEquals("Bulk data size didn't match expected size.", IMAGE_DATA.length, copy.length);
- assertTrue("Input value didn't match expected value.", Validator.validateBulkData(IMAGE_DATA, copy));
+ assertNull(Test.NULL, msg.getImageType());
+ assertNull(Test.NULL, msg.getValue());
+ assertNull(Test.NULL, msg.getBulkData());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(Image.KEY_IMAGE_TYPE, IMAGE_TYPE);
- reference.put(Image.KEY_VALUE, IMAGE_NAME);
+ reference.put(Image.KEY_IMAGE_TYPE, Test.GENERAL_IMAGETYPE);
+ reference.put(Image.KEY_VALUE, Test.GENERAL_STRING);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}catch(JSONException e){
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- Image msg = new Image();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Image type wasn't set, but getter method returned an object.", msg.getImageType());
- assertNull("Value wasn't set, but getter method returned an object.", msg.getValue());
- assertNull("Bulk data wasn't set, but getter method returned an object.", msg.getBulkData());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/KeyboardPropertiesTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/KeyboardPropertiesTests.java
index 8a4d581e7..3eaf88e28 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/KeyboardPropertiesTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/KeyboardPropertiesTests.java
@@ -1,6 +1,5 @@
package com.smartdevicelink.test.rpc.datatypes;
-import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
@@ -14,100 +13,84 @@ import com.smartdevicelink.proxy.rpc.enums.KeyboardLayout;
import com.smartdevicelink.proxy.rpc.enums.KeypressMode;
import com.smartdevicelink.proxy.rpc.enums.Language;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
import com.smartdevicelink.test.Validator;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.KeyboardProperties}
+ */
public class KeyboardPropertiesTests extends TestCase{
- private static final String AUTO_COMPLETE_TEXT = "ducking";
- private static final Language LANGUAGE = Language.AR_SA;
- private static final KeyboardLayout KEYBOARD_LAYOUT = KeyboardLayout.QWERTY;
- private static final KeypressMode KEYPRESS_MODE = KeypressMode.SINGLE_KEYPRESS;
- private final List<String> LIMITED_CHAR_LIST = Arrays.asList(new String[] { "R", "S", "T", "L", "N", "E" });
-
- private KeyboardProperties msg;
+ private KeyboardProperties msg;
@Override
public void setUp(){
msg = new KeyboardProperties();
- msg.setAutoCompleteText(AUTO_COMPLETE_TEXT);
- msg.setKeyboardLayout(KEYBOARD_LAYOUT);
- msg.setKeypressMode(KEYPRESS_MODE);
- msg.setLanguage(LANGUAGE);
- msg.setLimitedCharacterList(LIMITED_CHAR_LIST);
- }
-
- public void testAutoCompleteText(){
- String copy = msg.getAutoCompleteText();
- assertEquals("Input value didn't match expected value.", AUTO_COMPLETE_TEXT, copy);
- }
-
- public void testKeyboardLayout(){
- KeyboardLayout copy = msg.getKeyboardLayout();
- assertEquals("Input value didn't match expected value.", KEYBOARD_LAYOUT, copy);
- }
-
- public void testKeypressMode(){
- KeypressMode copy = msg.getKeypressMode();
- assertEquals("Input value didn't match expected value.", KEYPRESS_MODE, copy);
- }
-
- public void testLanguage(){
- Language copy = msg.getLanguage();
- assertEquals("Input value didn't match expected value.", LANGUAGE, copy);
+ msg.setAutoCompleteText(Test.GENERAL_STRING);
+ msg.setKeyboardLayout(Test.GENERAL_KEYBOARDLAYOUT);
+ msg.setKeypressMode(Test.GENERAL_KEYPRESSMODE);
+ msg.setLanguage(Test.GENERAL_LANGUAGE);
+ msg.setLimitedCharacterList(Test.GENERAL_STRING_LIST);
}
- public void testLimitedCharacterList(){
- List<String> copy = msg.getLimitedCharacterList();
-
- assertEquals("Input value size didn't match expected size.", LIMITED_CHAR_LIST.size(), copy.size());
- assertTrue("Input value didn't match expected value.", Validator.validateStringList(LIMITED_CHAR_LIST, copy));
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ String autoComplete = msg.getAutoCompleteText();
+ KeyboardLayout keyboardLayout = msg.getKeyboardLayout();
+ KeypressMode keypressMode = msg.getKeypressMode();
+ Language language = msg.getLanguage();
+ List<String> limitedChars = msg.getLimitedCharacterList();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, autoComplete);
+ assertEquals(Test.MATCH, Test.GENERAL_KEYBOARDLAYOUT, keyboardLayout);
+ assertEquals(Test.MATCH, Test.GENERAL_KEYPRESSMODE, keypressMode);
+ assertEquals(Test.MATCH, Test.GENERAL_LANGUAGE, language);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING_LIST.size(), limitedChars.size());
+ assertTrue(Test.TRUE, Validator.validateStringList(Test.GENERAL_STRING_LIST, limitedChars));
+
+ // Invalid/Null Tests
+ KeyboardProperties msg = new KeyboardProperties();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ // Keypress mode is created in the object constructor
+ assertNotNull(Test.NOT_NULL, msg.getKeypressMode());
+
+ assertNull(Test.NULL, msg.getAutoCompleteText());
+ assertNull(Test.NULL, msg.getLanguage());
+ assertNull(Test.NULL, msg.getKeyboardLayout());
+ assertNull(Test.NULL, msg.getLimitedCharacterList());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(KeyboardProperties.KEY_AUTO_COMPLETE_TEXT, AUTO_COMPLETE_TEXT);
- reference.put(KeyboardProperties.KEY_KEYBOARD_LAYOUT, KEYBOARD_LAYOUT);
- reference.put(KeyboardProperties.KEY_KEYPRESS_MODE, KEYPRESS_MODE);
- reference.put(KeyboardProperties.KEY_LANGUAGE, LANGUAGE);
- reference.put(KeyboardProperties.KEY_LIMITED_CHARACTER_LIST,
- JsonUtils.createJsonArray(LIMITED_CHAR_LIST));
+ reference.put(KeyboardProperties.KEY_AUTO_COMPLETE_TEXT, Test.GENERAL_STRING);
+ reference.put(KeyboardProperties.KEY_KEYBOARD_LAYOUT, Test.GENERAL_KEYBOARDLAYOUT);
+ reference.put(KeyboardProperties.KEY_KEYPRESS_MODE, Test.GENERAL_KEYPRESSMODE);
+ reference.put(KeyboardProperties.KEY_LANGUAGE, Test.GENERAL_LANGUAGE);
+ reference.put(KeyboardProperties.KEY_LIMITED_CHARACTER_LIST, JsonUtils.createJsonArray(Test.GENERAL_STRING_LIST));
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
if(key.equals(KeyboardProperties.KEY_LIMITED_CHARACTER_LIST)){
- assertTrue("JSON value didn't match expected value for key \"" + key + "\".",
- Validator.validateStringList(JsonUtils.readStringListFromJsonObject(reference, key),
- JsonUtils.readStringListFromJsonObject(underTest, key)));
- }
- else{
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertTrue(Test.TRUE, Validator.validateStringList(JsonUtils.readStringListFromJsonObject(reference, key), JsonUtils.readStringListFromJsonObject(underTest, key)));
+ } else{
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}
- }catch(JSONException e){
- /* do nothing */
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- KeyboardProperties msg = new KeyboardProperties();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("AutoComplete text wasn't set, but getter method returned an object.", msg.getAutoCompleteText());
- assertNull("Language wasn't set, but getter method returned an object.", msg.getLanguage());
- assertNull("Keyboard layout wasn't set, but getter method returned an object.", msg.getKeyboardLayout());
- //KeypressMode is set in the default constructor
- assertNotNull("Keypress mode is set, but getter method didn't return an object.", msg.getKeypressMode());
- assertNull("Limited character set wasn't set, but getter method returned an object.",
- msg.getLimitedCharacterList());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/MenuParamsTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/MenuParamsTests.java
index 08e7342f1..ea823f619 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/MenuParamsTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/MenuParamsTests.java
@@ -9,69 +9,66 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.MenuParams;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.MenuParams}
+ */
public class MenuParamsTests extends TestCase{
- private static final String MENU_NAME = "Favorites Menu";
- private static final int PARENT_ID = 5026;
- private static final int POSITION = 3;
-
- private MenuParams msg;
+ private MenuParams msg;
@Override
public void setUp(){
msg = new MenuParams();
- msg.setMenuName(MENU_NAME);
- msg.setParentID(PARENT_ID);
- msg.setPosition(POSITION);
- }
-
- public void testMenuName(){
- String copy = msg.getMenuName();
- assertEquals("Input value didn't match expected value.", MENU_NAME, copy);
+ msg.setMenuName(Test.GENERAL_STRING);
+ msg.setParentID(Test.GENERAL_INT);
+ msg.setPosition(Test.GENERAL_INT);
}
- public void testParentID(){
- int copy = msg.getParentID();
- assertEquals("Input value didn't match expected value.", PARENT_ID, copy);
- }
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ String menuName = msg.getMenuName();
+ int parentId = msg.getParentID();
+ int position = msg.getPosition();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, menuName);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, parentId);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, position);
+
+ // Invalid/Null Tests
+ MenuParams msg = new MenuParams();
+ assertNotNull(Test.NOT_NULL, msg);
- public void testPosition(){
- int copy = msg.getPosition();
- assertEquals("Input value didn't match expected value.", POSITION, copy);
+ assertNull(Test.NULL, msg.getMenuName());
+ assertNull(Test.NULL, msg.getParentID());
+ assertNull(Test.NULL, msg.getPosition());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(MenuParams.KEY_MENU_NAME, MENU_NAME);
- reference.put(MenuParams.KEY_PARENT_ID, PARENT_ID);
- reference.put(MenuParams.KEY_POSITION, POSITION);
+ reference.put(MenuParams.KEY_MENU_NAME, Test.GENERAL_STRING);
+ reference.put(MenuParams.KEY_PARENT_ID, Test.GENERAL_INT);
+ reference.put(MenuParams.KEY_POSITION, Test.GENERAL_INT);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}catch(JSONException e){
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- MenuParams msg = new MenuParams();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Menu name wasn't set, but getter method returned an object.", msg.getMenuName());
- assertNull("Parent ID wasn't set, but getter method returned an object.", msg.getParentID());
- assertNull("Position wasn't set, but getter method returned an object.", msg.getPosition());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/MyKeyTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/MyKeyTests.java
index 1017c95da..48b0f33ab 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/MyKeyTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/MyKeyTests.java
@@ -10,51 +10,55 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.MyKey;
import com.smartdevicelink.proxy.rpc.enums.VehicleDataStatus;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.MyKey}
+ */
public class MyKeyTests extends TestCase{
- private static final VehicleDataStatus E_911_OVERRIDE = VehicleDataStatus.ON;
-
- private MyKey msg;
+ private MyKey msg;
@Override
public void setUp(){
msg = new MyKey();
-
- msg.setE911Override(E_911_OVERRIDE);
+ msg.setE911Override(Test.GENERAL_VEHICLEDATASTATUS);
}
- public void testE911Override(){
- VehicleDataStatus copy = msg.getE911Override();
- assertEquals("Input value didn't match expected value.", E_911_OVERRIDE, copy);
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ VehicleDataStatus override = msg.getE911Override();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_VEHICLEDATASTATUS, override);
+
+ // Invalid/Null Tests
+ MyKey msg = new MyKey();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getE911Override());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(MyKey.KEY_E_911_OVERRIDE, E_911_OVERRIDE);
+ reference.put(MyKey.KEY_E_911_OVERRIDE, Test.GENERAL_VEHICLEDATASTATUS);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}catch(JSONException e){
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- MyKey msg = new MyKey();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("E 911 override wasn't set, but getter method returned an object.", msg.getE911Override());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ParameterPermissionsTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ParameterPermissionsTests.java
index c2e704e36..a40f6a1b0 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ParameterPermissionsTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ParameterPermissionsTests.java
@@ -1,6 +1,5 @@
package com.smartdevicelink.test.rpc.datatypes;
-import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
@@ -11,12 +10,14 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.ParameterPermissions;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
import com.smartdevicelink.test.Validator;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.ParameterPermissions}
+ */
public class ParameterPermissionsTests extends TestCase{
-
- private final List<String> ALLOWED = Arrays.asList(new String[]{"param1, param3"});
- private final List<String> USER_DISALLOWED = Arrays.asList(new String[]{"param2"});
private ParameterPermissions msg;
@@ -24,50 +25,47 @@ public class ParameterPermissionsTests extends TestCase{
public void setUp(){
msg = new ParameterPermissions();
- msg.setAllowed(ALLOWED);
- msg.setUserDisallowed(USER_DISALLOWED);
+ msg.setAllowed(Test.GENERAL_STRING_LIST);
+ msg.setUserDisallowed(Test.GENERAL_STRING_LIST);
}
- public void testAllowed () {
- List<String> copy = msg.getAllowed();
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ List<String> allowed = msg.getAllowed();
+ List<String> disallowed = msg.getUserDisallowed();
- assertTrue("Input value didn't match expected value.", Validator.validateStringList(ALLOWED, copy));
- }
-
- public void testUserDisallowed () {
- List<String> copy = msg.getUserDisallowed();
+ // Valid Tests
+ assertTrue(Test.TRUE, Validator.validateStringList(Test.GENERAL_STRING_LIST, allowed));
+ assertTrue(Test.TRUE, Validator.validateStringList(Test.GENERAL_STRING_LIST, disallowed));
- assertTrue("Input value didn't match expected value.", Validator.validateStringList(USER_DISALLOWED, copy));
+ // Invalid/Null Tests
+ ParameterPermissions msg = new ParameterPermissions();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getAllowed());
+ assertNull(Test.NULL, msg.getUserDisallowed());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(ParameterPermissions.KEY_ALLOWED, JsonUtils.createJsonArray(ALLOWED));
- reference.put(ParameterPermissions.KEY_USER_DISALLOWED, JsonUtils.createJsonArray(USER_DISALLOWED));
+ reference.put(ParameterPermissions.KEY_ALLOWED, JsonUtils.createJsonArray(Test.GENERAL_STRING_LIST));
+ reference.put(ParameterPermissions.KEY_USER_DISALLOWED, JsonUtils.createJsonArray(Test.GENERAL_STRING_LIST));
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while(iterator.hasNext()){
String key = (String) iterator.next();
- assertTrue("JSON value didn't match expected value for key \"" + key + "\".",
- Validator.validateStringList(JsonUtils.readStringListFromJsonObject(reference, key),
- JsonUtils.readStringListFromJsonObject(underTest, key)));
+ assertTrue(Test.TRUE, Validator.validateStringList(JsonUtils.readStringListFromJsonObject(reference, key), JsonUtils.readStringListFromJsonObject(underTest, key)));
}
- }catch(JSONException e){
- /* do nothing */
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull(){
- ParameterPermissions msg = new ParameterPermissions();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Allowed wasn't set, but getter method returned an oblect.", msg.getAllowed());
- assertNull("User disallowed wasn't set, but getter method returned an object.", msg.getUserDisallowed());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/PermissionItemTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/PermissionItemTest.java
index d5ee8caa0..465783ba2 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/PermissionItemTest.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/PermissionItemTest.java
@@ -1,6 +1,5 @@
package com.smartdevicelink.test.rpc.datatypes;
-import java.util.Arrays;
import java.util.Iterator;
import junit.framework.TestCase;
@@ -11,113 +10,75 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.HMIPermissions;
import com.smartdevicelink.proxy.rpc.ParameterPermissions;
import com.smartdevicelink.proxy.rpc.PermissionItem;
-import com.smartdevicelink.proxy.rpc.enums.HMILevel;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
import com.smartdevicelink.test.Validator;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.PermissionItem}
+ */
public class PermissionItemTest extends TestCase {
- private static final String RPC_NAME = "rpcName";
- private static final HMIPermissions HMI_PERMISSIONS = new HMIPermissions();
- private static final ParameterPermissions PARAMETER_PERMISSIONS = new ParameterPermissions();
- private static final String PARAMETER_ALLOWED_ITEM1 = "param1";
- private static final String PARAMETER_ALLOWED_ITEM2 = "param2";
- private static final String PARAMETER_DISALLOWED_ITEM1 = "no";
- private static final String PARAMETER_DISALLOWED_ITEM2 = "nope";
- private static final HMILevel HMI_ALLOWED_ITEM1 = HMILevel.HMI_NONE;
- private static final HMILevel HMI_ALLOWED_ITEM2 = HMILevel.HMI_FULL;
- private static final HMILevel HMI_DISALLOWED_ITEM1 = HMILevel.HMI_NONE;
- private static final HMILevel HMI_DISALLOWED_ITEM2 = HMILevel.HMI_FULL;
-
-
-
private PermissionItem msg;
@Override
public void setUp() {
- HMI_PERMISSIONS.setAllowed(Arrays.asList(new HMILevel[]{ HMI_ALLOWED_ITEM1, HMI_ALLOWED_ITEM2}));
- HMI_PERMISSIONS.setUserDisallowed(Arrays.asList(new HMILevel[]{ HMI_DISALLOWED_ITEM1, HMI_DISALLOWED_ITEM2}));
- PARAMETER_PERMISSIONS.setAllowed(Arrays.asList(new String[]{ PARAMETER_ALLOWED_ITEM1, PARAMETER_ALLOWED_ITEM2 }));
- PARAMETER_PERMISSIONS.setUserDisallowed(Arrays.asList(new String[]{ PARAMETER_DISALLOWED_ITEM1, PARAMETER_DISALLOWED_ITEM2 }));
-
msg = new PermissionItem();
- msg.setRpcName(RPC_NAME);
- msg.setHMIPermissions(HMI_PERMISSIONS);
- msg.setParameterPermissions(PARAMETER_PERMISSIONS);
-
-
+ msg.setRpcName(Test.GENERAL_STRING);
+ msg.setHMIPermissions(Test.GENERAL_HMIPERMISSIONS);
+ msg.setParameterPermissions(Test.GENERAL_PARAMETERPERMISSIONS);
}
- public void testRPCName() {
- String copy = msg.getRpcName();
-
- assertEquals("Rpc name didn't match expected value.", RPC_NAME, copy);
- }
-
- public void testHmiPermissions() {
- HMIPermissions copy = msg.getHMIPermissions();
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ String rpcName = msg.getRpcName();
+ HMIPermissions hmiPermissions = msg.getHMIPermissions();
+ ParameterPermissions parameterPermissions = msg.getParameterPermissions();
- assertTrue("Input value didn't match expected value.", Validator.validateHmiPermissions(HMI_PERMISSIONS, copy));
- }
-
- public void testParameterPermisisons() {
- ParameterPermissions copy = msg.getParameterPermissions();
-
- assertTrue("Input value didn't match expected value.", Validator.validateParameterPermissions(PARAMETER_PERMISSIONS, copy));
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, rpcName);
+ assertTrue(Test.TRUE, Validator.validateHmiPermissions(Test.GENERAL_HMIPERMISSIONS, hmiPermissions));
+ assertTrue(Test.TRUE, Validator.validateParameterPermissions(Test.GENERAL_PARAMETERPERMISSIONS, parameterPermissions));
+
+ // Invalid/Null Tests
+ PermissionItem msg = new PermissionItem();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getRpcName());
+ assertNull(Test.NULL, msg.getHMIPermissions());
+ assertNull(Test.NULL, msg.getParameterPermissions());
}
public void testJson() {
JSONObject reference = new JSONObject();
- JSONObject hmi = new JSONObject(), parameter = new JSONObject();
try {
- hmi.put(HMIPermissions.KEY_ALLOWED, HMILevel.HMI_NONE);
- hmi.put(HMIPermissions.KEY_USER_DISALLOWED, HMILevel.HMI_FULL);
-
- parameter.put(ParameterPermissions.KEY_ALLOWED, PARAMETER_PERMISSIONS.getAllowed());
- parameter.put(ParameterPermissions.KEY_USER_DISALLOWED, PARAMETER_PERMISSIONS.getUserDisallowed());
-
- reference.put(PermissionItem.KEY_RPC_NAME, RPC_NAME);
- reference.put(PermissionItem.KEY_HMI_PERMISSIONS, hmi);
- reference.put(PermissionItem.KEY_PARAMETER_PERMISSIONS, parameter);
+ reference.put(PermissionItem.KEY_RPC_NAME, Test.GENERAL_STRING);
+ reference.put(PermissionItem.KEY_HMI_PERMISSIONS, Test.JSON_HMIPERMISSIONS);
+ reference.put(PermissionItem.KEY_PARAMETER_PERMISSIONS, Test.JSON_PARAMETERPERMISSIONS);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.",
- reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while (iterator.hasNext()) {
String key = (String) iterator.next();
if (key.equals(PermissionItem.KEY_HMI_PERMISSIONS)) {
- assertTrue("JSON value didn't match expected value for key \"" + key + "\".",
- Validator.validateStringList(
- JsonUtils.readStringListFromJsonObject(reference, key),
- JsonUtils.readStringListFromJsonObject(underTest, key)));
+ assertTrue(Test.TRUE, Validator.validateStringList(JsonUtils.readStringListFromJsonObject(reference, key), JsonUtils.readStringListFromJsonObject(underTest, key)));
} else if (key.equals(PermissionItem.KEY_PARAMETER_PERMISSIONS)) {
- assertTrue("JSON value didn't match expected value for key \"" + key + "\".",
- Validator.validateStringList(
- JsonUtils.readStringListFromJsonObject(reference, key),
- JsonUtils.readStringListFromJsonObject(underTest, key)));
+ assertTrue(Test.TRUE, Validator.validateStringList(JsonUtils.readStringListFromJsonObject(reference, key), JsonUtils.readStringListFromJsonObject(underTest, key)));
} else {
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}
} catch (JSONException e) {
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull() {
- PermissionItem msg = new PermissionItem();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Rpc name wasn't set, but getter method returned an object.", msg.getRpcName());
- assertNull("HMI permissions wasn't set, but getter method returned an object.", msg.getHMIPermissions());
- assertNull("Parameter permissions wasn't set, but getter method returned an object.", msg.getParameterPermissions());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/PresetBankCapabilitiesTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/PresetBankCapabilitiesTest.java
index e90f04be0..f56d2a212 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/PresetBankCapabilitiesTest.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/PresetBankCapabilitiesTest.java
@@ -9,10 +9,13 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.PresetBankCapabilities;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.PresetBankCapabilities}
+ */
public class PresetBankCapabilitiesTest extends TestCase {
-
- private static final boolean PRESETS_AVAILABLE = true;
private PresetBankCapabilities msg;
@@ -20,44 +23,42 @@ public class PresetBankCapabilitiesTest extends TestCase {
public void setUp() {
msg = new PresetBankCapabilities();
- msg.setOnScreenPresetsAvailable(PRESETS_AVAILABLE);
+ msg.setOnScreenPresetsAvailable(Test.GENERAL_BOOLEAN);
}
- public void testPresetsAvailable() {
- boolean copy = msg.onScreenPresetsAvailable();
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ boolean presets = msg.onScreenPresetsAvailable();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, presets);
- assertEquals("Input value didn't match expected value.", PRESETS_AVAILABLE, copy);
+ // Invalid/Null Tests
+ PresetBankCapabilities msg = new PresetBankCapabilities();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.onScreenPresetsAvailable());
}
public void testJson() {
JSONObject reference = new JSONObject();
try {
- reference.put(PresetBankCapabilities.KEY_ON_SCREEN_PRESETS_AVAILABLE, PRESETS_AVAILABLE);
+ reference.put(PresetBankCapabilities.KEY_ON_SCREEN_PRESETS_AVAILABLE, Test.GENERAL_BOOLEAN);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.",
- reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while (iterator.hasNext()) {
String key = (String) iterator.next();
- assertEquals(
- "JSON value didn't match expected value for key \""
- + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
} catch (JSONException e) {
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull() {
- PresetBankCapabilities msg = new PresetBankCapabilities();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Presets available wasn't set, but getter method returned an object.", msg.onScreenPresetsAvailable());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ScreenParamsTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ScreenParamsTest.java
index 3b82645c7..4621f8950 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ScreenParamsTest.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/ScreenParamsTest.java
@@ -12,71 +12,54 @@ import com.smartdevicelink.proxy.rpc.ImageResolution;
import com.smartdevicelink.proxy.rpc.ScreenParams;
import com.smartdevicelink.proxy.rpc.TouchEventCapabilities;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
import com.smartdevicelink.test.Validator;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.ScreenParams}
+ */
public class ScreenParamsTest extends TestCase {
-
- private static final ImageResolution IMAGE_RESOLUTION = new ImageResolution();
- private static final Integer IMAGE_RESOLUTION_WIDTH = 640;
- private static final Integer IMAGE_RESOLUTION_HEIGHT = 480;
-
- private static final TouchEventCapabilities TOUCH_EVENT_CAPABILITIES = new TouchEventCapabilities();
- private static final boolean PRESS_AVAILABLE = true;
- private static final boolean MULTI_TOUCH_AVAILABLE = true;
- private static final boolean DOUBLE_PRESS_AVAILABLE = true;
private ScreenParams msg;
@Override
public void setUp() {
- createCustomObjects();
-
msg = new ScreenParams();
- msg.setImageResolution(IMAGE_RESOLUTION);
- msg.setTouchEventAvailable(TOUCH_EVENT_CAPABILITIES);
- }
-
- public void createCustomObjects() {
- TOUCH_EVENT_CAPABILITIES.setPressAvailable(PRESS_AVAILABLE);
- TOUCH_EVENT_CAPABILITIES.setMultiTouchAvailable(MULTI_TOUCH_AVAILABLE);
- TOUCH_EVENT_CAPABILITIES.setDoublePressAvailable(DOUBLE_PRESS_AVAILABLE);
- IMAGE_RESOLUTION.setResolutionWidth(IMAGE_RESOLUTION_WIDTH);
- IMAGE_RESOLUTION.setResolutionHeight(IMAGE_RESOLUTION_HEIGHT);
+ msg.setImageResolution(Test.GENERAL_IMAGERESOLUTION);
+ msg.setTouchEventAvailable(Test.GENERAL_TOUCHEVENTCAPABILITIES);
}
- public void testImageResolution () {
- ImageResolution copy = msg.getImageResolution();
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ ImageResolution imageRes = msg.getImageResolution();
+ TouchEventCapabilities touchEvent = msg.getTouchEventAvailable();
- assertTrue("Input value didn't match expected value.", Validator.validateImageResolution(IMAGE_RESOLUTION, copy));
- }
-
- public void testTouchEventCapabilities () {
- TouchEventCapabilities copy = msg.getTouchEventAvailable();
+ // Valid Tests
+ assertTrue(Test.TRUE, Validator.validateImageResolution(Test.GENERAL_IMAGERESOLUTION, imageRes));
+ assertTrue(Test.TRUE, Validator.validateTouchEventCapabilities(Test.GENERAL_TOUCHEVENTCAPABILITIES, touchEvent));
- assertTrue("Input value didn't match expected value.", Validator.validateTouchEventCapabilities(TOUCH_EVENT_CAPABILITIES, copy));
+ // Invalid/Null Tests
+ ScreenParams msg = new ScreenParams();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getImageResolution());
+ assertNull(Test.NULL, msg.getTouchEventAvailable());
}
public void testJson() {
JSONObject reference = new JSONObject();
- JSONObject imageRes = new JSONObject();
- JSONObject touchEvent = new JSONObject();
try {
- imageRes.put(ImageResolution.KEY_RESOLUTION_HEIGHT, IMAGE_RESOLUTION.getResolutionHeight());
- imageRes.put(ImageResolution.KEY_RESOLUTION_WIDTH, IMAGE_RESOLUTION.getResolutionWidth());
-
- touchEvent.put(TouchEventCapabilities.KEY_DOUBLE_PRESS_AVAILABLE, TOUCH_EVENT_CAPABILITIES.getDoublePressAvailable());
- touchEvent.put(TouchEventCapabilities.KEY_MULTI_TOUCH_AVAILABLE, TOUCH_EVENT_CAPABILITIES.getMultiTouchAvailable());
- touchEvent.put(TouchEventCapabilities.KEY_PRESS_AVAILABLE, TOUCH_EVENT_CAPABILITIES.getPressAvailable());
-
- reference.put(ScreenParams.KEY_RESOLUTION, imageRes);
- reference.put(ScreenParams.KEY_TOUCH_EVENT_AVAILABLE, touchEvent);
+ reference.put(ScreenParams.KEY_RESOLUTION, Test.JSON_IMAGERESOLUTION);
+ reference.put(ScreenParams.KEY_TOUCH_EVENT_AVAILABLE, Test.JSON_TOUCHEVENTCAPABILITIES);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.",
- reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while (iterator.hasNext()) {
@@ -86,35 +69,22 @@ public class ScreenParamsTest extends TestCase {
JSONObject touchEventObjReference = JsonUtils.readJsonObjectFromJsonObject(reference, key);
JSONObject touchEventObjTest = JsonUtils.readJsonObjectFromJsonObject(underTest, key);
- assertTrue("JSON value didn't match expected value for key \"" + key + "\".",
- Validator.validateTouchEventCapabilities(
- new TouchEventCapabilities(JsonRPCMarshaller.deserializeJSONObject(touchEventObjReference)),
- new TouchEventCapabilities(JsonRPCMarshaller.deserializeJSONObject(touchEventObjTest))));
+ assertTrue(Test.TRUE, Validator.validateTouchEventCapabilities(
+ new TouchEventCapabilities(JsonRPCMarshaller.deserializeJSONObject(touchEventObjReference)),
+ new TouchEventCapabilities(JsonRPCMarshaller.deserializeJSONObject(touchEventObjTest))));
} else if (key.equals(ScreenParams.KEY_RESOLUTION)) {
JSONObject resolutionObjReference = JsonUtils.readJsonObjectFromJsonObject(reference, key);
JSONObject resolutionObjTest = JsonUtils.readJsonObjectFromJsonObject(underTest, key);
- assertTrue("JSON value didn't match expected value for key \"" + key + "\".",
- Validator.validateImageResolution(
- new ImageResolution(JsonRPCMarshaller.deserializeJSONObject(resolutionObjReference)),
- new ImageResolution(JsonRPCMarshaller.deserializeJSONObject(resolutionObjTest))));
+ assertTrue(Test.TRUE, Validator.validateImageResolution(
+ new ImageResolution(JsonRPCMarshaller.deserializeJSONObject(resolutionObjReference)),
+ new ImageResolution(JsonRPCMarshaller.deserializeJSONObject(resolutionObjTest))));
} else {
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}
} catch (JSONException e) {
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
-
- public void testNull() {
- ScreenParams msg = new ScreenParams();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Image resolution wasn't set, but getter method returned an object.", msg.getImageResolution());
- assertNull("Touch event available wasn't set, but getter method returned an object.", msg.getTouchEventAvailable());
- }
} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SdlMsgVersionTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SdlMsgVersionTest.java
index 903b28905..c94afc643 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SdlMsgVersionTest.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SdlMsgVersionTest.java
@@ -9,11 +9,13 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.SdlMsgVersion}
+ */
public class SdlMsgVersionTest extends TestCase {
-
- private static final Integer MAJOR_VERSION = 0;
- private static final Integer MINOR_VERSION = 0;
private SdlMsgVersion msg;
@@ -21,53 +23,47 @@ public class SdlMsgVersionTest extends TestCase {
public void setUp() {
msg = new SdlMsgVersion();
- msg.setMajorVersion(MAJOR_VERSION);
- msg.setMinorVersion(MINOR_VERSION);
+ msg.setMajorVersion(Test.GENERAL_INT);
+ msg.setMinorVersion(Test.GENERAL_INT);
}
- public void testMajorVersion() {
- Integer copy = msg.getMajorVersion();
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ Integer major = msg.getMajorVersion();
+ Integer minor = msg.getMinorVersion();
- assertEquals("Input value didn't match expected value.", MAJOR_VERSION, copy);
- }
-
- public void testMinorVersion() {
- Integer copy = msg.getMinorVersion();
+ // Valid Tests
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, major);
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, minor);
- assertEquals("Input value didn't match expected value.", MINOR_VERSION, copy);
+ // Invalid/Null Tests
+ SdlMsgVersion msg = new SdlMsgVersion();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getMajorVersion());
+ assertNull(Test.NULL, msg.getMinorVersion());
}
public void testJson() {
JSONObject reference = new JSONObject();
try {
- reference.put(SdlMsgVersion.KEY_MAJOR_VERSION, MAJOR_VERSION);
- reference.put(SdlMsgVersion.KEY_MINOR_VERSION, MINOR_VERSION);
+ reference.put(SdlMsgVersion.KEY_MAJOR_VERSION, Test.GENERAL_INT);
+ reference.put(SdlMsgVersion.KEY_MINOR_VERSION, Test.GENERAL_INT);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.",
- reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while (iterator.hasNext()) {
String key = (String) iterator.next();
- assertEquals(
- "JSON value didn't match expected value for key \""
- + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
} catch (JSONException e) {
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull() {
- SdlMsgVersion msg = new SdlMsgVersion();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Major version wasn't set, but getter method returned an object.", msg.getMajorVersion());
- assertNull("Minor version wasn't set, but getter method returned an object.", msg.getMinorVersion());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SingleTireStatusTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SingleTireStatusTest.java
index af215121c..aa6d7fadd 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SingleTireStatusTest.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SingleTireStatusTest.java
@@ -10,10 +10,13 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.SingleTireStatus;
import com.smartdevicelink.proxy.rpc.enums.ComponentVolumeStatus;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.SingleTireStatus}
+ */
public class SingleTireStatusTest extends TestCase {
-
- private static final ComponentVolumeStatus STATUS = ComponentVolumeStatus.NORMAL;
private SingleTireStatus msg;
@@ -21,43 +24,42 @@ public class SingleTireStatusTest extends TestCase {
public void setUp() {
msg = new SingleTireStatus();
- msg.setStatus(STATUS);
+ msg.setStatus(Test.GENERAL_COMPONENTVOLUMESTATUS);
}
- public void testStatus() {
- ComponentVolumeStatus copy = msg.getStatus();
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ ComponentVolumeStatus status = msg.getStatus();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_COMPONENTVOLUMESTATUS, status);
- assertEquals("Input value didn't match expected value.", STATUS, copy);
+ // Invalid/Null Tests
+ SingleTireStatus msg = new SingleTireStatus();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getStatus());
}
public void testJson() {
JSONObject reference = new JSONObject();
try {
- reference.put(SingleTireStatus.KEY_STATUS, STATUS);
+ reference.put(SingleTireStatus.KEY_STATUS, Test.GENERAL_COMPONENTVOLUMESTATUS);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.", reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while (iterator.hasNext()) {
String key = (String) iterator.next();
- assertEquals(
- "JSON value didn't match expected value for key \""
- + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
} catch (JSONException e) {
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull() {
- SingleTireStatus msg = new SingleTireStatus();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Status wasn't set, but getter method returned an object.", msg.getStatus());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SoftButtonCapabilitiesTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SoftButtonCapabilitiesTest.java
index 3c23270fd..125aa5e41 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SoftButtonCapabilitiesTest.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SoftButtonCapabilitiesTest.java
@@ -9,13 +9,13 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.SoftButtonCapabilities;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.SoftButtonCapabilities}
+ */
public class SoftButtonCapabilitiesTest extends TestCase {
-
- private static final Boolean SHORT_PRESS_AVAILABLE = false;
- private static final Boolean LONG_PRESS_AVAILABLE = false;
- private static final Boolean UP_DOWN_AVAILABLE = false;
- private static final Boolean IMAGE_SUPPORTED = false;
private SoftButtonCapabilities msg;
@@ -23,71 +23,57 @@ public class SoftButtonCapabilitiesTest extends TestCase {
public void setUp() {
msg = new SoftButtonCapabilities();
- msg.setImageSupported(IMAGE_SUPPORTED);
- msg.setShortPressAvailable(SHORT_PRESS_AVAILABLE);
- msg.setLongPressAvailable(LONG_PRESS_AVAILABLE);
- msg.setUpDownAvailable(UP_DOWN_AVAILABLE);
+ msg.setImageSupported(Test.GENERAL_BOOLEAN);
+ msg.setShortPressAvailable(Test.GENERAL_BOOLEAN);
+ msg.setLongPressAvailable(Test.GENERAL_BOOLEAN);
+ msg.setUpDownAvailable(Test.GENERAL_BOOLEAN);
}
- public void testImageSupported () {
- Boolean copy = msg.getImageSupported();
+ /**
+ * 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();
- assertEquals("Input value didn't match expected value.", IMAGE_SUPPORTED, copy);
- }
-
- public void testUpDownAvailable () {
- Boolean copy = msg.getUpDownAvailable();
-
- assertEquals("Input value didn't match expected value.", UP_DOWN_AVAILABLE, copy);
- }
-
- public void testLongPressAvailable () {
- Boolean copy = msg.getLongPressAvailable();
+ // Valid Tests
+ assertEquals(Test.MATCH, (Boolean) Test.GENERAL_BOOLEAN, imageSupp);
+ assertEquals(Test.MATCH, (Boolean) Test.GENERAL_BOOLEAN, updown);
+ assertEquals(Test.MATCH, (Boolean) Test.GENERAL_BOOLEAN, longPress);
+ assertEquals(Test.MATCH, (Boolean) Test.GENERAL_BOOLEAN, shortPress);
- assertEquals("Input value didn't match expected value.", LONG_PRESS_AVAILABLE, copy);
- }
-
- public void testShortPressAvailable () {
- Boolean copy = msg.getShortPressAvailable();
-
- assertEquals("Input value didn't match expected value.", SHORT_PRESS_AVAILABLE, copy);
+ // Invalid/Null Tests
+ SoftButtonCapabilities msg = new SoftButtonCapabilities();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getImageSupported());
+ assertNull(Test.NULL, msg.getLongPressAvailable());
+ assertNull(Test.NULL, msg.getShortPressAvailable());
+ assertNull(Test.NULL, msg.getUpDownAvailable());
}
public void testJson() {
JSONObject reference = new JSONObject();
try {
- reference.put(SoftButtonCapabilities.KEY_IMAGE_SUPPORTED, IMAGE_SUPPORTED);
- reference.put(SoftButtonCapabilities.KEY_UP_DOWN_AVAILABLE, UP_DOWN_AVAILABLE);
- reference.put(SoftButtonCapabilities.KEY_LONG_PRESS_AVAILABLE, LONG_PRESS_AVAILABLE);
- reference.put(SoftButtonCapabilities.KEY_SHORT_PRESS_AVAILABLE, SHORT_PRESS_AVAILABLE);
+ reference.put(SoftButtonCapabilities.KEY_IMAGE_SUPPORTED, Test.GENERAL_BOOLEAN);
+ reference.put(SoftButtonCapabilities.KEY_UP_DOWN_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(SoftButtonCapabilities.KEY_LONG_PRESS_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(SoftButtonCapabilities.KEY_SHORT_PRESS_AVAILABLE, Test.GENERAL_BOOLEAN);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.",
- reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while (iterator.hasNext()) {
String key = (String) iterator.next();
- assertEquals(
- "JSON value didn't match expected value for key \""
- + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
} catch (JSONException e) {
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull() {
- SoftButtonCapabilities msg = new SoftButtonCapabilities();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Image supported wasn't set, but getter method returned an object.", msg.getImageSupported());
- assertNull("Long press available wasn't set, but getter method returned an object.", msg.getLongPressAvailable());
- assertNull("Short press available wasn't set, but getter method returned an object.", msg.getShortPressAvailable());
- assertNull("Up down available wasn't set, but getter method returned an object.", msg.getUpDownAvailable());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SoftButtonTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SoftButtonTest.java
index 0d8404ffe..b2dfb54fc 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SoftButtonTest.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/SoftButtonTest.java
@@ -11,95 +11,77 @@ import org.json.JSONObject;
import com.smartdevicelink.marshal.JsonRPCMarshaller;
import com.smartdevicelink.proxy.rpc.Image;
import com.smartdevicelink.proxy.rpc.SoftButton;
-import com.smartdevicelink.proxy.rpc.enums.ImageType;
import com.smartdevicelink.proxy.rpc.enums.SoftButtonType;
import com.smartdevicelink.proxy.rpc.enums.SystemAction;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
import com.smartdevicelink.test.Validator;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.SoftButton}
+ */
public class SoftButtonTest extends TestCase {
-
- private static final SoftButtonType TYPE = SoftButtonType.SBT_TEXT;
- private static final String TEXT = "text";
- private static final SystemAction SYS_ACTION = SystemAction.DEFAULT_ACTION;
- private static final Image IMAGE = new Image();
- private static final ImageType IMAGE_TYPE = ImageType.DYNAMIC;
- private static final Boolean IS_HIGHLIGHTED = false;
- private static final Integer ID = 0;
private SoftButton msg;
@Override
public void setUp() {
- IMAGE.setValue(Image.KEY_VALUE);
- IMAGE.setImageType(IMAGE_TYPE);
-
msg = new SoftButton();
- msg.setType(TYPE);
- msg.setText(TEXT);
- msg.setSystemAction(SYS_ACTION);
- msg.setImage(IMAGE);
- msg.setIsHighlighted(IS_HIGHLIGHTED);
- msg.setSoftButtonID(ID);
-
+ msg.setType(Test.GENERAL_SOFTBUTTONTYPE);
+ msg.setText(Test.GENERAL_STRING);
+ msg.setSystemAction(Test.GENERAL_SYSTEMACTION);
+ msg.setImage(Test.GENERAL_IMAGE);
+ msg.setIsHighlighted(Test.GENERAL_BOOLEAN);
+ msg.setSoftButtonID(Test.GENERAL_INT);
}
- public void testType() {
- SoftButtonType copy = msg.getType();
-
- assertEquals("Input value didn't match expected value.", TYPE, copy);
- }
-
- public void testText() {
- String copy = msg.getText();
-
- assertEquals("Input value didn't match expected value.", TEXT, copy);
- }
-
- public void testSysAction () {
- SystemAction copy = msg.getSystemAction();
-
- assertEquals("Input value didn't match expected value.", SYS_ACTION, copy);
- }
-
- public void testImage () {
- Image copy = msg.getImage();
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ SoftButtonType type = msg.getType();
+ String text = msg.getText();
+ SystemAction sysAction = msg.getSystemAction();
+ Image image = msg.getImage();
+ Boolean isHighlighted = msg.getIsHighlighted();
+ Integer id = msg.getSoftButtonID();
- assertTrue("Input value didn't match expected value.", Validator.validateImage(IMAGE, copy));
- }
-
- public void testIsHighlighted () {
- Boolean copy = msg.getIsHighlighted();
-
- assertEquals("Input value didn't match expected value.", IS_HIGHLIGHTED, copy);
- }
-
- public void testId () {
- Integer copy = msg.getSoftButtonID();
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_SOFTBUTTONTYPE, type);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, text);
+ assertEquals(Test.MATCH, Test.GENERAL_SYSTEMACTION, sysAction);
+ assertTrue(Test.TRUE, Validator.validateImage(Test.GENERAL_IMAGE, image));
+ assertEquals(Test.MATCH, (Boolean) Test.GENERAL_BOOLEAN, isHighlighted);
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, id);
- assertEquals("Input value didn't match expected value.", ID, copy);
+ // Invalid/Null Tests
+ SoftButton msg = new SoftButton();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getSoftButtonID());
+ assertNull(Test.NULL, msg.getImage());
+ assertNull(Test.NULL, msg.getIsHighlighted());
+ assertNull(Test.NULL, msg.getSystemAction());
+ assertNull(Test.NULL, msg.getText());
+ assertNull(Test.NULL, msg.getType());
}
public void testJson() {
JSONObject reference = new JSONObject();
- JSONObject image = new JSONObject();
- try {
- image.put(Image.KEY_IMAGE_TYPE, ImageType.DYNAMIC);
- image.put(Image.KEY_VALUE, "value");
-
- reference.put(SoftButton.KEY_SOFT_BUTTON_ID, ID);
- reference.put(SoftButton.KEY_TYPE, TYPE);
- reference.put(SoftButton.KEY_TEXT, TEXT);
- reference.put(SoftButton.KEY_IMAGE, image);
- reference.put(SoftButton.KEY_SYSTEM_ACTION, SYS_ACTION);
- reference.put(SoftButton.KEY_IS_HIGHLIGHTED, IS_HIGHLIGHTED);
+ try {
+ reference.put(SoftButton.KEY_SOFT_BUTTON_ID, Test.GENERAL_INT);
+ reference.put(SoftButton.KEY_TYPE, Test.GENERAL_SOFTBUTTONTYPE);
+ reference.put(SoftButton.KEY_TEXT, Test.GENERAL_STRING);
+ reference.put(SoftButton.KEY_IMAGE, Test.JSON_IMAGE);
+ reference.put(SoftButton.KEY_SYSTEM_ACTION, Test.GENERAL_SYSTEMACTION);
+ reference.put(SoftButton.KEY_IS_HIGHLIGHTED, Test.GENERAL_BOOLEAN);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.",
- reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while (iterator.hasNext()) {
@@ -110,30 +92,13 @@ public class SoftButtonTest extends TestCase {
JSONObject underTestArray = JsonUtils.readJsonObjectFromJsonObject(underTest, key);
Hashtable<String, Object> hashReference = JsonRPCMarshaller.deserializeJSONObject(referenceArray);
Hashtable<String, Object> hashTest= JsonRPCMarshaller.deserializeJSONObject(underTestArray);
-
- assertTrue("JSON value didn't match expected value for key \"" + key + "\"",
- Validator.validateImage(new Image(hashReference), new Image(hashTest)));
+ assertTrue(Test.TRUE, Validator.validateImage(new Image(hashReference), new Image(hashTest)));
} else {
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}
} catch (JSONException e) {
- //do nothing
+ fail(Test.JSON_FAIL);
}
}
-
-
- public void testNull() {
- SoftButton msg = new SoftButton();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Id wasn't set, but getter method returned an object.", msg.getSoftButtonID());
- assertNull("Image wasn't set, but getter method returned an object.", msg.getImage());
- assertNull("Is highlighted wasn't set, but getter method returned an object.", msg.getIsHighlighted());
- assertNull("System action wasn't set, but getter method returned an object.", msg.getSystemAction());
- assertNull("Text wasn't set, but getter method returned an object.", msg.getText());
- assertNull("Type wasn't set, but getter method returned an object.", msg.getType());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/StartTimeTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/StartTimeTest.java
index a011c1b5f..f84ca3ec3 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/StartTimeTest.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/StartTimeTest.java
@@ -9,12 +9,13 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.StartTime;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.StartTime}
+ */
public class StartTimeTest extends TestCase {
-
- private static final Integer HOURS = 0;
- private static final Integer MINUTES = 0;
- private static final Integer SECONDS = 0;
private StartTime msg;
@@ -22,62 +23,52 @@ public class StartTimeTest extends TestCase {
public void setUp() {
msg = new StartTime();
- msg.setHours(HOURS);
- msg.setMinutes(MINUTES);
- msg.setSeconds(SECONDS);
+ msg.setHours(Test.GENERAL_INT);
+ msg.setMinutes(Test.GENERAL_INT);
+ msg.setSeconds(Test.GENERAL_INT);
}
- public void testHours() {
- Integer copy = msg.getHours();
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ Integer hours = msg.getHours();
+ Integer minutes = msg.getMinutes();
+ Integer seconds = msg.getSeconds();
- assertEquals("Input value didn't match expected value.", HOURS, copy);
- }
-
- public void testMinutes () {
- Integer copy = msg.getMinutes();
+ // Valid Tests
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, hours);
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, minutes);
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, seconds);
- assertEquals("Input value didn't match expected value.", MINUTES, copy);
- }
-
- public void testSeconds () {
- Integer copy = msg.getSeconds();
-
- assertEquals("Input value didn't match expected value.", SECONDS, copy);
+ // Invalid/Null Tests
+ StartTime msg = new StartTime();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getHours());
+ assertNull(Test.NULL, msg.getMinutes());
+ assertNull(Test.NULL, msg.getSeconds());
}
public void testJson() {
JSONObject reference = new JSONObject();
try {
- reference.put(StartTime.KEY_HOURS, HOURS);
- reference.put(StartTime.KEY_MINUTES, MINUTES);
- reference.put(StartTime.KEY_SECONDS, SECONDS);
+ reference.put(StartTime.KEY_HOURS, Test.GENERAL_INT);
+ reference.put(StartTime.KEY_MINUTES, Test.GENERAL_INT);
+ reference.put(StartTime.KEY_SECONDS, Test.GENERAL_INT);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.",
- reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while (iterator.hasNext()) {
String key = (String) iterator.next();
- assertEquals(
- "JSON value didn't match expected value for key \""
- + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
} catch (JSONException e) {
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull() {
- StartTime msg = new StartTime();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Hours wasn't set, but getter method returned an object.", msg.getHours());
- assertNull("Minutes wasn't set, but getter method returned an object.", msg.getMinutes());
- assertNull("Seconds wasn't set, but getter method returned an object.", msg.getSeconds());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TTSChunkTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TTSChunkTest.java
index 088913344..598993771 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TTSChunkTest.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TTSChunkTest.java
@@ -10,11 +10,9 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.TTSChunk;
import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
public class TTSChunkTest extends TestCase {
-
- private static final SpeechCapabilities SPEECH_TYPE = SpeechCapabilities.SILENCE;
- private static final String TEXT = "text";
private TTSChunk msg;
@@ -22,53 +20,47 @@ public class TTSChunkTest extends TestCase {
public void setUp() {
msg = new TTSChunk();
- msg.setText(TEXT);
- msg.setType(SPEECH_TYPE);
+ msg.setText(Test.GENERAL_STRING);
+ msg.setType(Test.GENERAL_SPEECHCAPABILITIES);
}
- public void testText() {
- String copy = msg.getText();
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ String text = msg.getText();
+ SpeechCapabilities speechType = msg.getType();
- assertEquals("Input value didn't match expected value.", TEXT, copy);
- }
-
- public void testSpeechType () {
- SpeechCapabilities copy = msg.getType();
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, text);
+ assertEquals(Test.MATCH, Test.GENERAL_SPEECHCAPABILITIES, speechType);
- assertEquals("Input value didn't match expected value.", SPEECH_TYPE, copy);
+ // Invalid/Null Tests
+ TTSChunk msg = new TTSChunk();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getText());
+ assertNull(Test.NULL, msg.getType());
}
public void testJson() {
JSONObject reference = new JSONObject();
try {
- reference.put(TTSChunk.KEY_TEXT, TEXT);
- reference.put(TTSChunk.KEY_TYPE, SPEECH_TYPE);
+ reference.put(TTSChunk.KEY_TEXT, Test.GENERAL_STRING);
+ reference.put(TTSChunk.KEY_TYPE, Test.GENERAL_SPEECHCAPABILITIES);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.",
- reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while (iterator.hasNext()) {
String key = (String) iterator.next();
- assertEquals(
- "JSON value didn't match expected value for key \""
- + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
} catch (JSONException e) {
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull() {
- TTSChunk msg = new TTSChunk();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Text wasn't set, but getter method returned an object.", msg.getText());
- assertNull("Speech type wasn't set, but getter method returned an object.", msg.getType());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TextFieldTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TextFieldTest.java
index e3b981b8d..6b5d4d3e2 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TextFieldTest.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TextFieldTest.java
@@ -11,13 +11,13 @@ import com.smartdevicelink.proxy.rpc.TextField;
import com.smartdevicelink.proxy.rpc.enums.CharacterSet;
import com.smartdevicelink.proxy.rpc.enums.TextFieldName;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.TextField}
+ */
public class TextFieldTest extends TestCase {
-
- private static final TextFieldName NAME = TextFieldName.ETA;
- private static final CharacterSet CHARACTER_SET = CharacterSet.CID1SET;
- private static final Integer WIDTH = 0;
- private static final Integer ROWS = 0;
private TextField msg;
@@ -25,71 +25,57 @@ public class TextFieldTest extends TestCase {
public void setUp() {
msg = new TextField();
- msg.setName(NAME);
- msg.setCharacterSet(CHARACTER_SET);
- msg.setWidth(WIDTH);
- msg.setRows(ROWS);
+ msg.setName(Test.GENERAL_TEXTFIELDNAME);
+ msg.setCharacterSet(Test.GENERAL_CHARACTERSET);
+ msg.setWidth(Test.GENERAL_INT);
+ msg.setRows(Test.GENERAL_INT);
}
- public void testName() {
- TextFieldName copy = msg.getName();
-
- assertEquals("Input value didn't match expected value.", NAME, copy);
- }
-
- public void testCharacterSet () {
- CharacterSet copy = msg.getCharacterSet();
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ TextFieldName name = msg.getName();
+ CharacterSet charSet = msg.getCharacterSet();
+ Integer width = msg.getWidth();
+ Integer rows = msg.getRows();
- assertEquals("Input value didn't match expected value.", CHARACTER_SET, copy);
- }
-
- public void testWidth () {
- Integer copy = msg.getWidth();
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_TEXTFIELDNAME, name);
+ assertEquals(Test.MATCH, Test.GENERAL_CHARACTERSET, charSet);
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, width);
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, rows);
- assertEquals("Input value didn't match expected value.", WIDTH, copy);
- }
-
- public void testRows () {
- Integer copy = msg.getRows();
-
- assertEquals("Input value didn't match expected value.", ROWS, copy);
+ // Invalid/Null Tests
+ TextField msg = new TextField();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getName());
+ assertNull(Test.NULL, msg.getWidth());
+ assertNull(Test.NULL, msg.getRows());
+ assertNull(Test.NULL, msg.getCharacterSet());
}
public void testJson() {
JSONObject reference = new JSONObject();
try {
- reference.put(TextField.KEY_CHARACTER_SET, CHARACTER_SET);
- reference.put(TextField.KEY_WIDTH, WIDTH);
- reference.put(TextField.KEY_ROWS, ROWS);
- reference.put(TextField.KEY_NAME, NAME);
+ reference.put(TextField.KEY_CHARACTER_SET, Test.GENERAL_CHARACTERSET);
+ reference.put(TextField.KEY_WIDTH, Test.GENERAL_INT);
+ reference.put(TextField.KEY_ROWS, Test.GENERAL_INT);
+ reference.put(TextField.KEY_NAME, Test.GENERAL_TEXTFIELDNAME);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.",
- reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while (iterator.hasNext()) {
String key = (String) iterator.next();
- assertEquals(
- "JSON value didn't match expected value for key \""
- + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
} catch (JSONException e) {
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull() {
- TextField msg = new TextField();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Name wasn't set, but getter method returned an object.", msg.getName());
- assertNull("Width wasn't set, but getter method returned an object.", msg.getWidth());
- assertNull("Rows wasn't set, but getter method returned an object.", msg.getRows());
- assertNull("Character set wasn't set, but getter method returned an object.", msg.getCharacterSet());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TireStatusTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TireStatusTest.java
index 1a7b23c99..5552a5c29 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TireStatusTest.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TireStatusTest.java
@@ -8,141 +8,101 @@ import org.json.JSONObject;
import com.smartdevicelink.marshal.JsonRPCMarshaller;
import com.smartdevicelink.proxy.rpc.SingleTireStatus;
import com.smartdevicelink.proxy.rpc.TireStatus;
-import com.smartdevicelink.proxy.rpc.enums.ComponentVolumeStatus;
import com.smartdevicelink.proxy.rpc.enums.WarningLightStatus;
+import com.smartdevicelink.test.Test;
import com.smartdevicelink.test.Validator;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.TireStatus}
+ */
public class TireStatusTest extends TestCase {
-
- //private static final Map<TireZone, SingleTireStatus> TIRE_STATUSES = new HashMap<TireZone, SingleTireStatus>();
- private static final WarningLightStatus TIRE_PRESSURE_TELL_TALE = WarningLightStatus.OFF;
- private static final ComponentVolumeStatus TIRE_PRESSURE_NORMAL = ComponentVolumeStatus.NORMAL;
- private static final ComponentVolumeStatus TIRE_PRESSURE_FAULT = ComponentVolumeStatus.FAULT;
- private static final ComponentVolumeStatus TIRE_PRESSURE_LOW = ComponentVolumeStatus.LOW;
- private static final ComponentVolumeStatus TIRE_PRESSURE_ALERT = ComponentVolumeStatus.ALERT;
private TireStatus msg;
@Override
public void setUp() {
msg = new TireStatus();
- msg.setPressureTellTale(TIRE_PRESSURE_TELL_TALE);
+ msg.setPressureTellTale(Test.GENERAL_WARNINGLIGHTSTATUS);
SingleTireStatus tireLeftFront = new SingleTireStatus();
- tireLeftFront.setStatus(TIRE_PRESSURE_NORMAL);
+ tireLeftFront.setStatus(Test.GENERAL_COMPONENTVOLUMESTATUS);
msg.setLeftFront(tireLeftFront);
SingleTireStatus tireRightFront = new SingleTireStatus();
- tireRightFront.setStatus(TIRE_PRESSURE_FAULT);
+ tireRightFront.setStatus(Test.GENERAL_COMPONENTVOLUMESTATUS);
msg.setRightFront(tireRightFront);
SingleTireStatus tireLeftRear = new SingleTireStatus();
- tireLeftRear.setStatus(TIRE_PRESSURE_LOW);
+ tireLeftRear.setStatus(Test.GENERAL_COMPONENTVOLUMESTATUS);
msg.setLeftRear(tireLeftRear);
SingleTireStatus tireRightRear = new SingleTireStatus();
- tireRightRear.setStatus(TIRE_PRESSURE_NORMAL);
+ tireRightRear.setStatus(Test.GENERAL_COMPONENTVOLUMESTATUS);
msg.setRightRear(tireRightRear);
SingleTireStatus tireInnerLeftRear = new SingleTireStatus();
- tireInnerLeftRear.setStatus(TIRE_PRESSURE_LOW);
+ tireInnerLeftRear.setStatus(Test.GENERAL_COMPONENTVOLUMESTATUS);
msg.setInnerLeftRear(tireInnerLeftRear);
SingleTireStatus tireInnerRightRear = new SingleTireStatus();
- tireInnerRightRear.setStatus(TIRE_PRESSURE_ALERT);
+ tireInnerRightRear.setStatus(Test.GENERAL_COMPONENTVOLUMESTATUS);
msg.setInnerRightRear(tireInnerRightRear);
}
- public void testPressureTellTale() {
- WarningLightStatus copy = msg.getPressureTellTale();
- assertEquals("Input value didn't match expected value.", TIRE_PRESSURE_TELL_TALE, copy);
- }
-
- public void testTireLeftFront() {
- SingleTireStatus copy = msg.getLeftFront();
- assertEquals("Tire status does not match expected value.", TIRE_PRESSURE_NORMAL, copy.getStatus());
- }
-
- public void testTireRightFront() {
- SingleTireStatus copy = msg.getRightFront();
- assertEquals("Tire status does not match expected value.", TIRE_PRESSURE_FAULT, copy.getStatus());
- }
-
- public void testTireLeftRear() {
- SingleTireStatus copy = msg.getLeftRear();
- assertEquals("Tire status does not match expected value.", TIRE_PRESSURE_LOW, copy.getStatus());
- }
-
- public void testTireRightRear() {
- SingleTireStatus copy = msg.getRightRear();
- assertEquals("Tire status does not match expected value.", TIRE_PRESSURE_NORMAL, copy.getStatus());
- }
-
- public void testTireInnerLeftRear() {
- SingleTireStatus copy = msg.getInnerLeftRear();
- assertEquals("Tire status does not match expected value.", TIRE_PRESSURE_LOW, copy.getStatus());
- }
-
- public void testTireInnerRightRear() {
- SingleTireStatus copy = msg.getInnerRightRear();
- assertEquals("Tire status does not match expected value.", TIRE_PRESSURE_ALERT, copy.getStatus());
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ WarningLightStatus pressure = msg.getPressureTellTale();
+ SingleTireStatus leftFront = msg.getLeftFront();
+ SingleTireStatus rightFront = msg.getRightFront();
+ SingleTireStatus leftRear = msg.getLeftRear();
+ SingleTireStatus rightRear = msg.getRightRear();
+ SingleTireStatus innerLeftRear = msg.getInnerLeftRear();
+ SingleTireStatus innerRightRear = msg.getInnerRightRear();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_WARNINGLIGHTSTATUS, pressure);
+ assertEquals(Test.MATCH, Test.GENERAL_COMPONENTVOLUMESTATUS, leftFront.getStatus());
+ assertEquals(Test.MATCH, Test.GENERAL_COMPONENTVOLUMESTATUS, rightFront.getStatus());
+ assertEquals(Test.MATCH, Test.GENERAL_COMPONENTVOLUMESTATUS, leftRear.getStatus());
+ assertEquals(Test.MATCH, Test.GENERAL_COMPONENTVOLUMESTATUS, rightRear.getStatus());
+ assertEquals(Test.MATCH, Test.GENERAL_COMPONENTVOLUMESTATUS, innerLeftRear.getStatus());
+ assertEquals(Test.MATCH, Test.GENERAL_COMPONENTVOLUMESTATUS, innerRightRear.getStatus());
+
+ // Invalid/Null Tests
+ TireStatus msg = new TireStatus();
+ assertNotNull(Test.NOT_NULL, msg);
}
public void testJson() {
JSONObject reference = new JSONObject();
try {
- reference.put(TireStatus.KEY_PRESSURE_TELL_TALE, TIRE_PRESSURE_TELL_TALE);
+ reference.put(TireStatus.KEY_PRESSURE_TELL_TALE, Test.GENERAL_WARNINGLIGHTSTATUS);
JSONObject tireLeftFront = new JSONObject();
- tireLeftFront.put(SingleTireStatus.KEY_STATUS, TIRE_PRESSURE_NORMAL);
+ tireLeftFront.put(SingleTireStatus.KEY_STATUS, Test.GENERAL_COMPONENTVOLUMESTATUS);
reference.put(TireStatus.KEY_LEFT_FRONT, tireLeftFront);
JSONObject tireRightFront = new JSONObject();
- tireRightFront.put(SingleTireStatus.KEY_STATUS, TIRE_PRESSURE_FAULT);
+ tireRightFront.put(SingleTireStatus.KEY_STATUS, Test.GENERAL_COMPONENTVOLUMESTATUS);
reference.put(TireStatus.KEY_RIGHT_FRONT, tireRightFront);
JSONObject tireLeftRear = new JSONObject();
- tireLeftRear.put(SingleTireStatus.KEY_STATUS, TIRE_PRESSURE_LOW);
+ tireLeftRear.put(SingleTireStatus.KEY_STATUS, Test.GENERAL_COMPONENTVOLUMESTATUS);
reference.put(TireStatus.KEY_LEFT_REAR, tireLeftRear);
JSONObject tireRightRear = new JSONObject();
- tireRightRear.put(SingleTireStatus.KEY_STATUS, TIRE_PRESSURE_NORMAL);
+ tireRightRear.put(SingleTireStatus.KEY_STATUS, Test.GENERAL_COMPONENTVOLUMESTATUS);
reference.put(TireStatus.KEY_RIGHT_REAR, tireRightRear);
JSONObject tireInnerLeftRear = new JSONObject();
- tireInnerLeftRear.put(SingleTireStatus.KEY_STATUS, TIRE_PRESSURE_LOW);
+ tireInnerLeftRear.put(SingleTireStatus.KEY_STATUS, Test.GENERAL_COMPONENTVOLUMESTATUS);
reference.put(TireStatus.KEY_INNER_LEFT_REAR, tireInnerLeftRear);
JSONObject tireInnerRightRear = new JSONObject();
- tireInnerRightRear.put(SingleTireStatus.KEY_STATUS, TIRE_PRESSURE_ALERT);
+ tireInnerRightRear.put(SingleTireStatus.KEY_STATUS, Test.GENERAL_COMPONENTVOLUMESTATUS);
reference.put(TireStatus.KEY_INNER_RIGHT_REAR, tireInnerRightRear);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.",
- reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
- //TODO: does this test what's needed?
- assertTrue("JSON didn't match expected JSON.",
- Validator.validateTireStatus(
- new TireStatus(JsonRPCMarshaller.deserializeJSONObject(reference)),
- new TireStatus(JsonRPCMarshaller.deserializeJSONObject(underTest))));
-/*
- Iterator<?> iterator = reference.keys();
- while (iterator.hasNext()) {
- String key = (String) iterator.next();
-
- if (key.equals(TireStatus.KEY_PRESSURE_TELL_TALE)) {
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
- }
- else {
- System.out.println(JsonUtils.readJsonObjectFromJsonObject(reference, key));
- System.out.println(JsonUtils.readJsonObjectFromJsonObject(underTest, key));
-
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readJsonObjectFromJsonObject(reference, key),
- JsonUtils.readJsonObjectFromJsonObject(underTest, key));
- }
- }
- */
+ assertTrue(Test.TRUE, Validator.validateTireStatus(
+ new TireStatus(JsonRPCMarshaller.deserializeJSONObject(reference)),
+ new TireStatus(JsonRPCMarshaller.deserializeJSONObject(underTest))));
} catch (JSONException e) {
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull() {
- TireStatus msg = new TireStatus();
- assertNotNull("Null object creation failed.", msg);
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TouchCoordTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TouchCoordTest.java
index 23f464c86..cfa4a4f33 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TouchCoordTest.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TouchCoordTest.java
@@ -9,11 +9,13 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.TouchCoord;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.TouchCoord}
+ */
public class TouchCoordTest extends TestCase {
-
- private static final Integer X = 0;
- private static final Integer Y = 0;
private TouchCoord msg;
@@ -21,53 +23,47 @@ public class TouchCoordTest extends TestCase {
public void setUp() {
msg = new TouchCoord();
- msg.setX(X);
- msg.setY(Y);
+ msg.setX(Test.GENERAL_INT);
+ msg.setY(Test.GENERAL_INT);
}
- public void testX () {
- Integer copy = msg.getX();
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ Integer x = msg.getX();
+ Integer y = msg.getY();
- assertEquals("Input value didn't match expected value.", X, copy);
- }
-
- public void testY () {
- Integer copy = msg.getY();
+ // Valid Tests
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, x);
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, y);
- assertEquals("Input value didn't match expected value.", Y, copy);
+ // Invalid/Null Tests
+ TouchCoord msg = new TouchCoord();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getX());
+ assertNull(Test.NULL, msg.getY());
}
public void testJson() {
JSONObject reference = new JSONObject();
try {
- reference.put(TouchCoord.KEY_X, X);
- reference.put(TouchCoord.KEY_Y, Y);
+ reference.put(TouchCoord.KEY_X, Test.GENERAL_INT);
+ reference.put(TouchCoord.KEY_Y, Test.GENERAL_INT);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.",
- reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while (iterator.hasNext()) {
String key = (String) iterator.next();
- assertEquals(
- "JSON value didn't match expected value for key \""
- + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
} catch (JSONException e) {
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull() {
- TouchCoord msg = new TouchCoord();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("X wasn't set, but getter method returned an object.", msg.getX());
- assertNull("Y wasn't set, but getter method returned an object.", msg.getY());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TouchEventCapabilitiesTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TouchEventCapabilitiesTest.java
index 0eebac913..b488d4cb7 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TouchEventCapabilitiesTest.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TouchEventCapabilitiesTest.java
@@ -9,12 +9,13 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.TouchEventCapabilities;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.TouchEventCapabilties}
+ */
public class TouchEventCapabilitiesTest extends TestCase {
-
- private static final Boolean PRESS_AVAILABLE = false;
- private static final Boolean MULTI_TOUCH_AVAILABLE = false;
- private static final Boolean DOUBLE_PRESS_AVAILABLE = false;
private TouchEventCapabilities msg;
@@ -22,62 +23,52 @@ public class TouchEventCapabilitiesTest extends TestCase {
public void setUp() {
msg = new TouchEventCapabilities();
- msg.setPressAvailable(PRESS_AVAILABLE);
- msg.setDoublePressAvailable(DOUBLE_PRESS_AVAILABLE);
- msg.setMultiTouchAvailable(MULTI_TOUCH_AVAILABLE);
+ msg.setPressAvailable(Test.GENERAL_BOOLEAN);
+ msg.setDoublePressAvailable(Test.GENERAL_BOOLEAN);
+ msg.setMultiTouchAvailable(Test.GENERAL_BOOLEAN);
}
- public void testPressAvailable () {
- Boolean copy = msg.getPressAvailable();
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ Boolean press = msg.getPressAvailable();
+ Boolean multiTouch = msg.getMultiTouchAvailable();
+ Boolean doublePress = msg.getDoublePressAvailable();
- assertEquals("Input value didn't match expected value.", PRESS_AVAILABLE, copy);
- }
-
- public void testMultiTouchAvailable () {
- Boolean copy = msg.getMultiTouchAvailable();
+ // Valid Tests
+ assertEquals(Test.MATCH, (Boolean) Test.GENERAL_BOOLEAN, press);
+ assertEquals(Test.MATCH, (Boolean) Test.GENERAL_BOOLEAN, multiTouch);
+ assertEquals(Test.MATCH, (Boolean) Test.GENERAL_BOOLEAN, doublePress);
- assertEquals("Input value didn't match expected value.", MULTI_TOUCH_AVAILABLE, copy);
- }
-
- public void testDoublePressAvialable () {
- Boolean copy = msg.getDoublePressAvailable();
-
- assertEquals("Input value didn't match expected value.", DOUBLE_PRESS_AVAILABLE, copy);
+ // Invalid/Null Tests
+ TouchEventCapabilities msg = new TouchEventCapabilities();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getPressAvailable());
+ assertNull(Test.NULL, msg.getMultiTouchAvailable());
+ assertNull(Test.NULL, msg.getDoublePressAvailable());
}
public void testJson() {
JSONObject reference = new JSONObject();
try {
- reference.put(TouchEventCapabilities.KEY_PRESS_AVAILABLE, PRESS_AVAILABLE);
- reference.put(TouchEventCapabilities.KEY_MULTI_TOUCH_AVAILABLE, MULTI_TOUCH_AVAILABLE);
- reference.put(TouchEventCapabilities.KEY_DOUBLE_PRESS_AVAILABLE, DOUBLE_PRESS_AVAILABLE);
+ reference.put(TouchEventCapabilities.KEY_PRESS_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(TouchEventCapabilities.KEY_MULTI_TOUCH_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(TouchEventCapabilities.KEY_DOUBLE_PRESS_AVAILABLE, Test.GENERAL_BOOLEAN);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.",
- reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while (iterator.hasNext()) {
String key = (String) iterator.next();
- assertEquals(
- "JSON value didn't match expected value for key \""
- + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
} catch (JSONException e) {
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull() {
- TouchEventCapabilities msg = new TouchEventCapabilities();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Press available wasn't set, but getter method returned an object.", msg.getPressAvailable());
- assertNull("Multi touch available wasn't set, but getter method returned an object.", msg.getMultiTouchAvailable());
- assertNull("Double press available wasn't set, but getter method returned an object.", msg.getDoublePressAvailable());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TouchEventTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TouchEventTest.java
index 9bbab53f3..854ebc394 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TouchEventTest.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TouchEventTest.java
@@ -1,145 +1,89 @@
package com.smartdevicelink.test.rpc.datatypes;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import junit.framework.TestCase;
-import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.TouchCoord;
import com.smartdevicelink.proxy.rpc.TouchEvent;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
import com.smartdevicelink.test.Validator;
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.TouchEvent}
+ */
public class TouchEventTest extends TestCase {
-
- private static final Integer ID = 0;
-
- private static final Integer TS_ITEM_1 = 2;
- private static final Integer TS_ITEM_2 = 3;
- private static final Integer TS_ITEM_3 = 5;
- private static final Integer TS_ITEM_4 = 7;
- private final List<Integer> TS_LIST = Arrays.asList(new Integer[]{TS_ITEM_1, TS_ITEM_2, TS_ITEM_3, TS_ITEM_4});
-
-
- private final List<TouchCoord> C_LIST = new ArrayList<TouchCoord>();
- private final TouchCoord TOUCH_COORDINATE = new TouchCoord();
- private static final Integer TOUCH_COORDINATE_VALUE_X = 3;
- private static final Integer TOUCH_COORDINATE_VALUE_Y = 6;
-
- private final TouchCoord TOUCH_COORDINATE_2 = new TouchCoord();
- private static final Integer TOUCH_COORDINATE_VALUE_X_2 = 2;
- private static final Integer TOUCH_COORDINATE_VALUE_Y_2 = 8;
private TouchEvent msg;
@Override
- public void setUp() {
- TOUCH_COORDINATE.setX(TOUCH_COORDINATE_VALUE_X);
- TOUCH_COORDINATE.setY(TOUCH_COORDINATE_VALUE_Y);
- TOUCH_COORDINATE_2.setX(TOUCH_COORDINATE_VALUE_X_2);
- TOUCH_COORDINATE_2.setY(TOUCH_COORDINATE_VALUE_Y_2);
-
+ public void setUp() {
msg = new TouchEvent();
- msg.setId(ID);
- msg.setTs(TS_LIST);
-
- C_LIST.add(TOUCH_COORDINATE);
- C_LIST.add(TOUCH_COORDINATE_2);
- msg.setC(C_LIST);
+ msg.setId(Test.GENERAL_INT);
+ msg.setTs(Test.GENERAL_INTEGER_LIST);
+ msg.setC(Test.GENERAL_TOUCHCOORD_LIST);
}
- public void testId () {
- Integer copy = msg.getId();
-
- assertEquals("Input value didn't match expected value.", ID, copy);
- }
-
- public void testTimestamp () {
- List<Integer> copy = msg.getTs();
-
- assertTrue("Input value didn't match expected value.", Validator.validateIntegerList(TS_LIST, copy));
- }
-
- public void testTouchCoordinate () {
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ Integer id = msg.getId();
+ List<Integer> timestamp = msg.getTs();
List<TouchCoord> coordTest = msg.getC();
- assertEquals("Touch coordinate list lengths do not match", C_LIST.size(), coordTest.size());
+ // Valid Tests
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, id);
+ assertTrue(Test.TRUE, Validator.validateIntegerList(Test.GENERAL_INTEGER_LIST, timestamp));
+ assertEquals(Test.MATCH, Test.GENERAL_TOUCHCOORD_LIST.size(), coordTest.size());
- for (int index = 0; index < C_LIST.size(); index++) {
- assertTrue("Input value didn't match expected value", Validator.validateTouchCoord(C_LIST.get(index), coordTest.get(index)));
+ for (int index = 0; index < Test.GENERAL_TOUCHCOORD_LIST.size(); index++) {
+ assertTrue(Test.TRUE, Validator.validateTouchCoord(Test.GENERAL_TOUCHCOORD_LIST.get(index), coordTest.get(index)));
}
+
+ // Invalid/Null Tests
+ TouchEvent msg = new TouchEvent();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getId());
+ assertNull(Test.NULL, msg.getTs());
+ assertNull(Test.NULL, msg.getC());
}
public void testJson() {
JSONObject reference = new JSONObject();
- JSONArray cArray = new JSONArray();
try {
- reference.put(TouchEvent.KEY_ID, ID);
-
- List<Integer> tsList = new ArrayList<Integer>();
- tsList.add(TS_ITEM_1);
- tsList.add(TS_ITEM_2);
- tsList.add(TS_ITEM_3);
- tsList.add(TS_ITEM_4);
-
- JSONArray tsArray = JsonUtils.createJsonArray(tsList);
- reference.put(TouchEvent.KEY_TS, tsArray);
-
- JSONObject coord = new JSONObject();
- coord.put(TouchCoord.KEY_X, TOUCH_COORDINATE.getX());
- coord.put(TouchCoord.KEY_Y, TOUCH_COORDINATE.getY());
- cArray.put(coord);
- coord.put(TouchCoord.KEY_X, TOUCH_COORDINATE_2.getX());
- coord.put(TouchCoord.KEY_Y, TOUCH_COORDINATE_2.getY());
- cArray.put(coord);
- reference.put(TouchEvent.KEY_C, cArray);
+ reference.put(TouchEvent.KEY_ID, Test.GENERAL_INT);
+ reference.put(TouchEvent.KEY_TS, JsonUtils.createJsonArray(Test.GENERAL_INTEGER_LIST));
+ reference.put(TouchEvent.KEY_C, Test.JSON_TOUCHCOORDS);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.",
- reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while (iterator.hasNext()) {
String key = (String) iterator.next();
- //TODO: how does this return true?
if (key.equals(TouchEvent.KEY_C)) {
- assertTrue("JSON value didn't match expected value for key \"" + key + "\"",
- JsonUtils.readIntegerFromJsonObject(reference, key) == JsonUtils.readIntegerFromJsonObject(underTest, key));
- }
- else if (key.equals(TouchEvent.KEY_TS)) {
+ assertTrue(Test.TRUE, JsonUtils.readIntegerFromJsonObject(reference, key) == JsonUtils.readIntegerFromJsonObject(underTest, key));
+ } else if (key.equals(TouchEvent.KEY_TS)) {
List<Integer> tsListReference = JsonUtils.readIntegerListFromJsonObject(reference, key);
List<Integer> tsListTest = JsonUtils.readIntegerListFromJsonObject(underTest, key);
-
- assertTrue("Time stamp lists not the same for key \"" + key + "\".",
- tsListReference.containsAll(tsListTest) && tsListTest.containsAll(tsListReference));
-
- }
- else {
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertTrue(Test.TRUE, tsListReference.containsAll(tsListTest) && tsListTest.containsAll(tsListReference));
+ } else {
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}
} catch (JSONException e) {
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull() {
- TouchEvent msg = new TouchEvent();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Id wasn't set, but getter method returned an object.", msg.getId());
- assertNull("Timestamp wasn't set, but getter method returned an object.", msg.getTs());
- assertNull("Touch coordinate wasn't set, but getter method returned an object.", msg.getC());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TurnTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TurnTests.java
index 16f2349d8..8986fd4a9 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TurnTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/TurnTests.java
@@ -1,63 +1,56 @@
package com.smartdevicelink.test.rpc.datatypes;
+import junit.framework.TestCase;
+
import org.json.JSONException;
import org.json.JSONObject;
-import junit.framework.TestCase;
-
import com.smartdevicelink.proxy.rpc.Image;
import com.smartdevicelink.proxy.rpc.Turn;
-import com.smartdevicelink.proxy.rpc.enums.ImageType;
+import com.smartdevicelink.test.Test;
import com.smartdevicelink.test.Validator;
public class TurnTests extends TestCase {
- private static final Image TURN_ICON = new Image();
- private static final String NAV_TEXT = "nav_text";
-
private Turn msg;
@Override
public void setUp(){
msg = new Turn();
+ assertNotNull(Test.NOT_NULL, msg);
- TURN_ICON.setValue("turn_icon");
- TURN_ICON.setImageType(ImageType.STATIC);
-
- msg.setTurnIcon(TURN_ICON);
- msg.setNavigationText(NAV_TEXT);
+ msg.setTurnIcon(Test.GENERAL_IMAGE);
+ msg.setNavigationText(Test.GENERAL_STRING);
}
-
- public void testCreation () {
- assertNotNull("Object creation failed.", msg);
- }
-
- public void testTurnIcon () {
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
Image icon = msg.getTurnIcon();
- assertTrue("Turn icon didn't match expected value.", Validator.validateImage(TURN_ICON, icon));
- }
-
- public void testNavText () {
String text = msg.getNavigationText();
- assertEquals("Navigation text didn't match expected value.",NAV_TEXT, text);
+
+ // Valid Tests
+ assertTrue(Test.MATCH, Validator.validateImage(Test.GENERAL_IMAGE, icon));
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, text);
+
+ // Invalid/Null Tests
+ Turn msg = new Turn();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getNavigationText());
+ assertNull(Test.NULL, msg.getTurnIcon());
}
public void testJson(){
JSONObject reference = new JSONObject();
try{
- reference.put(Turn.KEY_NAVIGATION_TEXT, NAV_TEXT);
- reference.put(Turn.KEY_TURN_IMAGE, TURN_ICON.serializeJSON());
+ reference.put(Turn.KEY_NAVIGATION_TEXT, Test.GENERAL_STRING);
+ reference.put(Turn.KEY_TURN_IMAGE, Test.JSON_IMAGE);
} catch(JSONException e){
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull() {
- Turn msg = new Turn();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Navigation text wasn't set but getter method returned an object.", msg.getNavigationText());
- assertNull("Turn icon wasn't set but the getter method returned an object.", msg.getTurnIcon());
- }
} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/VehicleDataResultTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/VehicleDataResultTest.java
index bb2d5df01..8d5d1e861 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/VehicleDataResultTest.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/VehicleDataResultTest.java
@@ -11,11 +11,9 @@ import com.smartdevicelink.proxy.rpc.VehicleDataResult;
import com.smartdevicelink.proxy.rpc.enums.VehicleDataResultCode;
import com.smartdevicelink.proxy.rpc.enums.VehicleDataType;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
public class VehicleDataResultTest extends TestCase {
-
- private static final VehicleDataType TYPE = VehicleDataType.VEHICLEDATA_BRAKING;
- private static final VehicleDataResultCode RESULT = VehicleDataResultCode.SUCCESS;
private VehicleDataResult msg;
@@ -23,53 +21,49 @@ public class VehicleDataResultTest extends TestCase {
public void setUp() {
msg = new VehicleDataResult();
- msg.setDataType(TYPE);
- msg.setResultCode(RESULT);
+ msg.setDataType(Test.GENERAL_VEHICLEDATATYPE);
+ msg.setResultCode(Test.GENERAL_VEHICLEDATARESULTCODE);
}
- public void testType() {
- VehicleDataType copy = msg.getDataType();
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ VehicleDataResultCode result = msg.getResultCode();
+ VehicleDataType type = msg.getDataType();
- assertEquals("Input value didn't match expected value.", TYPE, copy);
- }
-
- public void testResult () {
- VehicleDataResultCode copy = msg.getResultCode();
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_VEHICLEDATARESULTCODE, result);
+ assertEquals(Test.MATCH, Test.GENERAL_VEHICLEDATATYPE, type);
- assertEquals("Input value didn't match expected value.", RESULT, copy);
+ // Invalid/Null Tests
+ VehicleDataResult msg = new VehicleDataResult();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getDataType());
+ assertNull(Test.NULL, msg.getResultCode());
}
public void testJson() {
JSONObject reference = new JSONObject();
try {
- reference.put(VehicleDataResult.KEY_RESULT_CODE, RESULT);
- reference.put(VehicleDataResult.KEY_DATA_TYPE, TYPE);
+ reference.put(VehicleDataResult.KEY_RESULT_CODE, Test.GENERAL_VEHICLEDATARESULTCODE);
+ reference.put(VehicleDataResult.KEY_DATA_TYPE, Test.GENERAL_VEHICLEDATATYPE);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.",
- reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while (iterator.hasNext()) {
String key = (String) iterator.next();
- assertEquals(
- "JSON value didn't match expected value for key \""
- + key + "\".",
+ assertEquals(Test.MATCH,
JsonUtils.readObjectFromJsonObject(reference, key),
JsonUtils.readObjectFromJsonObject(underTest, key));
}
} catch (JSONException e) {
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull() {
- VehicleDataResult msg = new VehicleDataResult();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Type wasn't set, but getter method returned an object.", msg.getDataType());
- assertNull("Result wasn't set, but getter method returned an object.", msg.getResultCode());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/VehicleTypeTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/VehicleTypeTest.java
index 8c91c7a10..17f663ae6 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/VehicleTypeTest.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/VehicleTypeTest.java
@@ -9,13 +9,9 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.rpc.VehicleType;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
public class VehicleTypeTest extends TestCase {
-
- private static final String MAKE = "make";
- private static final String MODEL = "model";
- private static final String YEAR = "year";
- private static final String TRIM = "trim";
private VehicleType msg;
@@ -23,71 +19,57 @@ public class VehicleTypeTest extends TestCase {
public void setUp() {
msg = new VehicleType();
- msg.setModel(MODEL);
- msg.setMake(MAKE);
- msg.setTrim(TRIM);
- msg.setModelYear(YEAR);
+ msg.setModel(Test.GENERAL_STRING);
+ msg.setMake(Test.GENERAL_STRING);
+ msg.setTrim(Test.GENERAL_STRING);
+ msg.setModelYear(Test.GENERAL_STRING);
}
- public void testModel() {
- String copy = msg.getModel();
-
- assertEquals("Input value didn't match expected value.", MODEL, copy);
- }
-
- public void testMake () {
- String copy = msg.getMake();
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ String year = msg.getModelYear();
+ String trim = msg.getTrim();
+ String make = msg.getMake();
+ String model = msg.getModel();
- assertEquals("Input value didn't match expected value.", MAKE, copy);
- }
-
- public void testTrim () {
- String copy = msg.getTrim();
-
- assertEquals("Input value didn't match expected value.", TRIM, copy);
- }
-
- public void testYear () {
- String copy = msg.getModelYear();
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, year);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, model);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, make);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, trim);
- assertEquals("Input value didn't match expected value.", YEAR, copy);
+ // Invalid/Null Tests
+ VehicleType msg = new VehicleType();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getModel());
+ assertNull(Test.NULL, msg.getMake());
+ assertNull(Test.NULL, msg.getModelYear());
+ assertNull(Test.NULL, msg.getTrim());
}
public void testJson() {
JSONObject reference = new JSONObject();
try {
- reference.put(VehicleType.KEY_MODEL, MODEL);
- reference.put(VehicleType.KEY_MAKE, MAKE);
- reference.put(VehicleType.KEY_MODEL_YEAR, YEAR);
- reference.put(VehicleType.KEY_TRIM, TRIM);
+ reference.put(VehicleType.KEY_MODEL, Test.GENERAL_STRING);
+ reference.put(VehicleType.KEY_MAKE, Test.GENERAL_STRING);
+ reference.put(VehicleType.KEY_MODEL_YEAR, Test.GENERAL_STRING);
+ reference.put(VehicleType.KEY_TRIM, Test.GENERAL_STRING);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.",
- reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while (iterator.hasNext()) {
String key = (String) iterator.next();
- assertEquals(
- "JSON value didn't match expected value for key \""
- + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
} catch (JSONException e) {
- /* do nothing */
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull() {
- VehicleType msg = new VehicleType();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Model wasn't set, but getter method returned an object.", msg.getModel());
- assertNull("Make wasn't set, but getter method returned an object.", msg.getMake());
- assertNull("Year wasn't set, but getter method returned an object.", msg.getModelYear());
- assertNull("Trim wasn't set, but getter method returned an object.", msg.getTrim());
- }
-}
+} \ No newline at end of file
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/VrHelpItemTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/VrHelpItemTest.java
index 6b5886e71..55f00dd1c 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/VrHelpItemTest.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/datatypes/VrHelpItemTest.java
@@ -11,67 +11,57 @@ import org.json.JSONObject;
import com.smartdevicelink.marshal.JsonRPCMarshaller;
import com.smartdevicelink.proxy.rpc.Image;
import com.smartdevicelink.proxy.rpc.VrHelpItem;
-import com.smartdevicelink.proxy.rpc.enums.ImageType;
import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
import com.smartdevicelink.test.Validator;
public class VrHelpItemTest extends TestCase {
-
- private static final String TEXT = "text";
- private static final Image IMAGE = new Image();
- private static final String IMAGE_VALUE = Image.KEY_VALUE;
- private static final ImageType IMAGE_TYPE = ImageType.DYNAMIC;
- private static final Integer POSITION = 0;
private VrHelpItem msg;
@Override
- public void setUp() {
- IMAGE.setValue(IMAGE_VALUE);
- IMAGE.setImageType(IMAGE_TYPE);
-
+ public void setUp() {
msg = new VrHelpItem();
- msg.setText(TEXT);
- msg.setImage(IMAGE);
- msg.setPosition(POSITION);
+ msg.setText(Test.GENERAL_STRING);
+ msg.setImage(Test.GENERAL_IMAGE);
+ msg.setPosition(Test.GENERAL_INT);
}
- public void testText() {
- String copy = msg.getText();
-
- assertEquals("Input value didn't match expected value.", TEXT, copy);
- }
-
- public void testImage () {
- Image copy = msg.getImage();
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ String text = msg.getText();
+ Image image = msg.getImage();
+ Integer position = msg.getPosition();
- assertTrue("Input value didn't match expected value.", Validator.validateImage(IMAGE, copy));
- }
-
- public void testPosition () {
- Integer copy = msg.getPosition();
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, text);
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, position);
+ assertTrue(Test.TRUE, Validator.validateImage(Test.GENERAL_IMAGE, image));
- assertEquals("Input value didn't match expected value.", POSITION, copy);
+ // Invalid/Null Tests
+ VrHelpItem msg = new VrHelpItem();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getImage());
+ assertNull(Test.NULL, msg.getText());
+ assertNull(Test.NULL, msg.getPosition());
}
public void testJson() {
JSONObject reference = new JSONObject();
- JSONObject image = new JSONObject();
- try {
- image.put(Image.KEY_IMAGE_TYPE, ImageType.DYNAMIC);
- image.put(Image.KEY_VALUE, "value");
-
- reference.put(VrHelpItem.KEY_IMAGE, image);
- reference.put(VrHelpItem.KEY_TEXT, TEXT);
- reference.put(VrHelpItem.KEY_POSITION, POSITION);
+ try {
+ reference.put(VrHelpItem.KEY_IMAGE, Test.JSON_IMAGE);
+ reference.put(VrHelpItem.KEY_TEXT, Test.GENERAL_STRING);
+ reference.put(VrHelpItem.KEY_POSITION, Test.GENERAL_INT);
JSONObject underTest = msg.serializeJSON();
-
- assertEquals("JSON size didn't match expected size.",
- reference.length(), underTest.length());
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
Iterator<?> iterator = reference.keys();
while (iterator.hasNext()) {
@@ -83,26 +73,13 @@ public class VrHelpItemTest extends TestCase {
Hashtable<String, Object> hashReference = JsonRPCMarshaller.deserializeJSONObject(objectEquals);
Hashtable<String, Object> hashTest = JsonRPCMarshaller.deserializeJSONObject(testEquals);
- assertTrue("JSON value didn't match expected value for key \"" + key + "\"",
- Validator.validateImage(new Image(hashReference), new Image(hashTest)));
+ assertTrue(Test.TRUE, Validator.validateImage(new Image(hashReference), new Image(hashTest)));
} else {
- assertEquals("JSON value didn't match expected value for key \"" + key + "\".",
- JsonUtils.readObjectFromJsonObject(reference, key),
- JsonUtils.readObjectFromJsonObject(underTest, key));
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
}
} catch (JSONException e) {
- //do nothing
+ fail(Test.JSON_FAIL);
}
}
-
- public void testNull() {
- VrHelpItem msg = new VrHelpItem();
- assertNotNull("Null object creation failed.", msg);
-
- assertNull("Image wasn't set, but getter method returned an object.", msg.getImage());
- assertNull("Text wasn't set, but getter method returned an object.", msg.getText());
- assertNull("Position wasn't set, but getter method returned an object.", msg.getPosition());
-
- }
-}
+} \ No newline at end of file