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/media skip indicators #2703

Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ extern const char* minutes;
extern const char* seconds;
extern const char* update_mode;
extern const char* audioStreamingIndicator;
extern const char* forward_seek_indicator;
extern const char* back_seek_indicator;
extern const char* seek_time;
extern const char* trigger_source;
extern const char* hmi_level;
extern const char* activate_app_hmi_level;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,114 @@ TEST_F(SetMediaClockRequestTest, OnEvent_Canceled) {
command->on_event(event);
}

TEST_F(SetMediaClockRequestTest, MessageWithForwardSeekIndicator_TRACK) {
MessageSharedPtr msg = CreateMsgParams();
mobile_apis::SeekIndicatorType::eType seek_indicator_type =
mobile_apis::SeekIndicatorType::TRACK;

(*msg)[am::strings::msg_params][am::strings::forward_seek_indicator] =
seek_indicator_type;
std::shared_ptr<SetMediaClockRequest> command(
CreateCommand<SetMediaClockRequest>(msg));

ExpectationsSetupHelper(true);

command->Run();

EXPECT_EQ(
seek_indicator_type,
static_cast<mobile_apis::SeekIndicatorType::eType>(
(*msg)[am::strings::msg_params][am::strings::forward_seek_indicator]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, check the existing of key (using assert) before this expectation

.asInt()));
auto msg_params = (*msg)[am::strings::msg_params];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's better to move this line before first usage of (*msg)[am::strings::msg_params]

EXPECT_TRUE(msg_params.keyExists(am::strings::forward_seek_indicator));
EXPECT_FALSE(msg_params.keyExists(am::strings::back_seek_indicator));
EXPECT_FALSE(msg_params.keyExists(am::strings::seek_time));
}

TEST_F(SetMediaClockRequestTest, MessageWithBackSeekIndicator_TRACK) {
MessageSharedPtr msg = CreateMsgParams();
mobile_apis::SeekIndicatorType::eType seek_indicator_type =
mobile_apis::SeekIndicatorType::TRACK;

(*msg)[am::strings::msg_params][am::strings::back_seek_indicator] =
seek_indicator_type;
std::shared_ptr<SetMediaClockRequest> command(
CreateCommand<SetMediaClockRequest>(msg));

ExpectationsSetupHelper(true);

command->Run();

EXPECT_EQ(
seek_indicator_type,
static_cast<mobile_apis::SeekIndicatorType::eType>(
(*msg)[am::strings::msg_params][am::strings::back_seek_indicator]
.asInt()));

auto msg_params = (*msg)[am::strings::msg_params];
EXPECT_TRUE(msg_params.keyExists(am::strings::back_seek_indicator));
EXPECT_FALSE(msg_params.keyExists(am::strings::forward_seek_indicator));
EXPECT_FALSE(msg_params.keyExists(am::strings::seek_time));
}

TEST_F(SetMediaClockRequestTest, MessageWithForwardSeekIndicator_TIME) {
MessageSharedPtr msg = CreateMsgParams();
mobile_apis::SeekIndicatorType::eType seek_indicator_type =
mobile_apis::SeekIndicatorType::TIME;
std::uint32_t seek_time = 10;
Copy link
Contributor

@APipko APipko Oct 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For magic numbers it's better to use const. And please use u postfix to avoid implicit conversion


auto msg_params = (*msg)[am::strings::msg_params];

msg_params[am::strings::forward_seek_indicator] = seek_indicator_type;
msg_params[am::strings::seek_time] = seek_time;

std::shared_ptr<SetMediaClockRequest> command(
CreateCommand<SetMediaClockRequest>(msg));

ExpectationsSetupHelper(true);

command->Run();

EXPECT_TRUE(msg_params.keyExists(am::strings::forward_seek_indicator));
EXPECT_FALSE(msg_params.keyExists(am::strings::back_seek_indicator));

EXPECT_EQ(seek_indicator_type,
static_cast<mobile_apis::SeekIndicatorType::eType>(
msg_params[am::strings::forward_seek_indicator].asInt()));

EXPECT_TRUE(msg_params.keyExists(am::strings::seek_time));
EXPECT_EQ(seek_time, msg_params[am::strings::seek_time].asInt());
}

TEST_F(SetMediaClockRequestTest, MessageWithBackSeekIndicator_TIME) {
MessageSharedPtr msg = CreateMsgParams();
mobile_apis::SeekIndicatorType::eType seek_indicator_type =
mobile_apis::SeekIndicatorType::TIME;
std::uint32_t seek_time = 10;

auto msg_params = (*msg)[am::strings::msg_params];

msg_params[am::strings::back_seek_indicator] = seek_indicator_type;
msg_params[am::strings::seek_time] = seek_time;

std::shared_ptr<SetMediaClockRequest> command(
CreateCommand<SetMediaClockRequest>(msg));

ExpectationsSetupHelper(true);

command->Run();

EXPECT_EQ(seek_indicator_type,
static_cast<mobile_apis::SeekIndicatorType::eType>(
msg_params[am::strings::back_seek_indicator].asInt()));

EXPECT_TRUE(msg_params.keyExists(am::strings::back_seek_indicator));
EXPECT_FALSE(msg_params.keyExists(am::strings::forward_seek_indicator));

EXPECT_TRUE(msg_params.keyExists(am::strings::seek_time));
EXPECT_EQ(seek_time, msg_params[am::strings::seek_time].asInt());
}
} // namespace set_media_clock_timer_request
} // namespace mobile_commands_test
} // namespace commands_test
Expand Down
3 changes: 3 additions & 0 deletions src/components/application_manager/src/smart_object_keys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ const char* minutes = "minutes";
const char* seconds = "seconds";
const char* update_mode = "updateMode";
const char* audioStreamingIndicator = "audioStreamingIndicator";
const char* forward_seek_indicator = "forwardSeekIndicator";
const char* back_seek_indicator = "backSeekIndicator";
const char* seek_time = "seek_time";
const char* trigger_source = "triggerSource";
const char* hmi_level = "hmiLevel";
const char* activate_app_hmi_level = "level";
Expand Down
17 changes: 17 additions & 0 deletions src/components/interfaces/HMI_API.xml
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,21 @@
</element>
</enum>

<enum name="SeekIndicatorType" since="5.0">
<element name="TRACK"/>
<element name="TIME"/>
</enum>

<struct name="SeekStreamingIndicator" since="5.0">
<description>
The seek next / skip previous subscription buttons content.
</description>
<param name="type" type="SeekIndicatorType" mandatory="true" />
<param name="seekTime" type="Integer" minvalue="1" maxvalue="99" mandatory="false">
<description>If the type is TIME, this number of seconds may be present alongside the skip indicator. It will indicate the number of seconds thathe currently playing media will skip forward or backward.</description>
</param>
</struct>

<enum name="SystemContext">
<description>Enumeration that describes possible contexts the application might be in on HU.</description>
<description>Communicated to whichever app is in HMI FULL, except Alert.</description>
Expand Down Expand Up @@ -4228,6 +4243,8 @@
<param name="appID" type="Integer" mandatory="true">
<description>ID of application that requested this RPC.</description>
</param>
<param name="forwardSeekIndicator" type="Common.SeekStreamingIndicator" mandatory="false" />
<param name="backSeekIndicator" type="Common.SeekStreamingIndicator" mandatory="false" />
</function>
<function name="SetMediaClockTimer" messagetype="response">
</function>
Expand Down
19 changes: 18 additions & 1 deletion src/components/interfaces/MOBILE_API.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,22 @@
<description>Indicates that a button press of the Play/Pause button would stop the current playback.</description>
</element>
</enum>


<enum name="SeekIndicatorType" since="5.0">
<element name="TRACK"/>
<element name="TIME"/>
</enum>

<struct name="SeekStreamingIndicator" since="5.0">
<description>
The seek next / skip previous subscription buttons content.
</description>
<param name="type" type="SeekIndicatorType" mandatory="true"/>
<param name="seekTime" type="Integer" minvalue="1" maxvalue="99" mandatory="false">
<description>If the type is TIME, this number of seconds may be present alongside the skip indicator. It will indicate the number of seconds that the currently playing media will skip forward or backward.</description>
</param>
</struct>

<enum name="TimerMode" since="1.0">
<element name="UP" >
<description>Causes the media clock timer to update from 0:00 to a specified time</description>
Expand Down Expand Up @@ -4667,6 +4682,8 @@
<param name="audioStreamingIndicator" type="AudioStreamingIndicator" mandatory="false" since="5.0">
<description>Indicates that a button press of the Play/Pause button would play, pause or Stop the current playback.</description>
</param>
<param name="forwardSeekIndicator" type="SeekStreamingIndicator" mandatory="false" since="5.0"/>
<param name="backSeekIndicator" type="SeekStreamingIndicator" mandatory="false" since="5.0"/>
</function>

<function name="SetMediaClockTimer" functionID="SetMediaClockTimerID" messagetype="response" since="1.0">
Expand Down