Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Feature/issue 595 - Progress Bar Seek Feature #749

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added JSON file to test OnSeekMediaClockTimer
  • Loading branch information
Bilal authored and Bilal committed May 2, 2018
commit 31ac2dd40a01282adbd5e89cf386bfc5559944a9
13 changes: 13 additions & 0 deletions sdl_android/src/androidTest/assets/json/OnSeekMediaClockTimer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"notification":{
"name":"OnSeekMediaClockTimer",
"correlationID":150,
"parameters":{
"seekTime":{
"minutes":55,
"seconds":19,
"hours":12
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package com.smartdevicelink.test.rpc.notifications;

import com.smartdevicelink.marshal.JsonRPCMarshaller;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCMessage;
import com.smartdevicelink.proxy.rpc.OnSeekMediaClockTimer;
import com.smartdevicelink.proxy.rpc.StartTime;
import com.smartdevicelink.test.BaseRpcTests;
import com.smartdevicelink.test.JsonUtils;
import com.smartdevicelink.test.Test;
import com.smartdevicelink.test.Validator;
import com.smartdevicelink.test.json.rpc.JsonFileReader;

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

import java.util.Hashtable;


public class OnSeekMediaClockTimerTests extends BaseRpcTests {
@Override
Expand Down Expand Up @@ -59,4 +65,31 @@ public void testRpcValues () {

assertNull(Test.NULL, msg.getSeekTime());
}

/**
* Tests a valid JSON construction of this RPC message.
*/
public void testJsonConstructor () {
JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType());
assertNotNull(Test.NOT_NULL, commandJson);

try {
Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
OnSeekMediaClockTimer cmd = new OnSeekMediaClockTimer(hash);

JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
assertNotNull(Test.NOT_NULL, body);

// Test everything in the json body.
assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());

JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS);
JSONObject seekTime = JsonUtils.readJsonObjectFromJsonObject(parameters, OnSeekMediaClockTimer.KEY_SEEK_TIME);
StartTime referenceSeekTime = new StartTime(JsonRPCMarshaller.deserializeJSONObject(seekTime));
assertTrue(Test.TRUE, Validator.validateStartTime(referenceSeekTime, cmd.getSeekTime()));

} catch (JSONException e) {
fail(Test.JSON_FAIL);
}
}
}