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

backend: fix wrong unit test in mission #382

Merged
merged 1 commit into from
May 3, 2018
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
16 changes: 15 additions & 1 deletion backend/src/plugins/mission/mission_service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,21 @@ class MissionServiceImpl final : public dronecore::rpc::mission::MissionService:
MissionItem::CameraAction
translateRPCCameraAction(const rpc::mission::MissionItem::CameraAction rpc_camera_action) const
{
return static_cast<MissionItem::CameraAction>(rpc_camera_action);
switch (rpc_camera_action) {
case rpc::mission::MissionItem::CameraAction::MissionItem_CameraAction_TAKE_PHOTO:
return MissionItem::CameraAction::TAKE_PHOTO;
case rpc::mission::MissionItem::CameraAction::MissionItem_CameraAction_START_PHOTO_INTERVAL:
return MissionItem::CameraAction::START_PHOTO_INTERVAL;
case rpc::mission::MissionItem::CameraAction::MissionItem_CameraAction_STOP_PHOTO_INTERVAL:
return MissionItem::CameraAction::STOP_PHOTO_INTERVAL;
case rpc::mission::MissionItem::CameraAction::MissionItem_CameraAction_START_VIDEO:
return MissionItem::CameraAction::START_VIDEO;
case rpc::mission::MissionItem::CameraAction::MissionItem_CameraAction_STOP_VIDEO:
return MissionItem::CameraAction::STOP_VIDEO;
case rpc::mission::MissionItem::CameraAction::MissionItem_CameraAction_NONE:
default:
return MissionItem::CameraAction::NONE;
}
}

void uploadMissionItems(const std::vector<std::shared_ptr<MissionItem>> &mission_items,
Expand Down
16 changes: 15 additions & 1 deletion backend/test/mission_service_impl_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,21 @@ MissionServiceImplUploadTest::generateUploadRequest(const
RPCCameraAction MissionServiceImplUploadTest::translateCameraAction(const CameraAction
camera_action) const
{
return static_cast<RPCCameraAction>(camera_action);
switch (camera_action) {
case CameraAction::TAKE_PHOTO:
return RPCCameraAction::MissionItem_CameraAction_TAKE_PHOTO;
case CameraAction::START_PHOTO_INTERVAL:
return RPCCameraAction::MissionItem_CameraAction_START_PHOTO_INTERVAL;
case CameraAction::STOP_PHOTO_INTERVAL:
return RPCCameraAction::MissionItem_CameraAction_STOP_PHOTO_INTERVAL;
case CameraAction::START_VIDEO:
return RPCCameraAction::MissionItem_CameraAction_START_VIDEO;
case CameraAction::STOP_VIDEO:
return RPCCameraAction::MissionItem_CameraAction_STOP_VIDEO;
case CameraAction::NONE:
default:
return RPCCameraAction::MissionItem_CameraAction_NONE;
}
}

TEST_F(MissionServiceImplUploadTest, uploadsEmptyMissionWhenNullRequest)
Expand Down