From 9707e5ca15c842d591e10cb56964381dc1428581 Mon Sep 17 00:00:00 2001 From: Jonas Vautherin Date: Thu, 30 Aug 2018 20:11:43 +0200 Subject: [PATCH] backend: add media_folder_name to CameraStatus --- backend/proto | 2 +- .../src/plugins/camera/camera_service_impl.h | 2 ++ backend/test/camera_service_impl_test.cpp | 28 +++++++++++-------- plugins/camera/camera.cpp | 2 ++ 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/backend/proto b/backend/proto index 2c46494b11..e7a285733a 160000 --- a/backend/proto +++ b/backend/proto @@ -1 +1 @@ -Subproject commit 2c46494b11cf99b48f932e4ee3fae241d630b96d +Subproject commit e7a285733aa03e4b56a771551a68e3f2d4b91a6f diff --git a/backend/src/plugins/camera/camera_service_impl.h b/backend/src/plugins/camera/camera_service_impl.h index 5361cbf18f..918756a4f5 100644 --- a/backend/src/plugins/camera/camera_service_impl.h +++ b/backend/src/plugins/camera/camera_service_impl.h @@ -458,6 +458,7 @@ class CameraServiceImpl final : public rpc::camera::CameraService::Service { status->set_used_storage_mib(camera_status.used_storage_mib); status->set_available_storage_mib(camera_status.available_storage_mib); status->set_recording_time_s(camera_status.recording_time_s); + status->set_media_folder_name(camera_status.media_folder_name); status->set_total_storage_mib(camera_status.total_storage_mib); return status; @@ -487,6 +488,7 @@ class CameraServiceImpl final : public rpc::camera::CameraService::Service { status.used_storage_mib = rpc_camera_status.used_storage_mib(); status.available_storage_mib = rpc_camera_status.available_storage_mib(); status.recording_time_s = rpc_camera_status.recording_time_s(); + status.media_folder_name = rpc_camera_status.media_folder_name(); status.total_storage_mib = rpc_camera_status.total_storage_mib(); return status; diff --git a/backend/test/camera_service_impl_test.cpp b/backend/test/camera_service_impl_test.cpp index f800eb830e..2b5df097b1 100644 --- a/backend/test/camera_service_impl_test.cpp +++ b/backend/test/camera_service_impl_test.cpp @@ -101,7 +101,8 @@ class CameraServiceImplTest : public ::testing::TestWithParam { const float used_storage_mib, const float available_storage_mib, const float total_storage_mib, - const float recording_time_s) const; + const float recording_time_s, + const std::string media_folder_name) const; std::future subscribeCameraStatusAsync(std::vector &camera_status_events, std::shared_ptr context) const; @@ -780,8 +781,8 @@ dronecode_sdk::Camera::CaptureInfo CameraServiceImplTest::createArbitraryCapture TEST_F(CameraServiceImplTest, registersToCameraStatus) { - const auto expected_camera_status = - createCameraStatus(false, true, ARBITRARY_CAMERA_STORAGE_STATUS, 3.4f, 12.6f, 16.0f, 0.4f); + const auto expected_camera_status = createCameraStatus( + false, true, ARBITRARY_CAMERA_STORAGE_STATUS, 3.4f, 12.6f, 16.0f, 0.4f, "100E90HD"); dronecode_sdk::Camera::subscribe_status_callback_t status_callback; EXPECT_CALL(_camera, subscribe_status(_)) .WillOnce(SaveResult(&status_callback, &_callback_saved_promise)); @@ -802,7 +803,8 @@ dronecode_sdk::Camera::Status CameraServiceImplTest::createCameraStatus( const float used_storage_mib, const float available_storage_mib, const float total_storage_mib, - const float recording_time_s) const + const float recording_time_s, + const std::string media_folder_name) const { dronecode_sdk::Camera::Status status; status.video_on = is_video_on; @@ -812,6 +814,7 @@ dronecode_sdk::Camera::Status CameraServiceImplTest::createCameraStatus( status.available_storage_mib = available_storage_mib; status.total_storage_mib = total_storage_mib; status.recording_time_s = recording_time_s; + status.media_folder_name = media_folder_name; return status; } @@ -849,8 +852,8 @@ TEST_F(CameraServiceImplTest, doesNotSendCameraStatusIfCallbackNotCalled) TEST_F(CameraServiceImplTest, sendsOneCameraStatus) { std::vector camera_status_events; - auto camera_status_event = - createCameraStatus(false, true, ARBITRARY_CAMERA_STORAGE_STATUS, 3.4f, 12.6f, 16.0f, 22.4f); + auto camera_status_event = createCameraStatus( + false, true, ARBITRARY_CAMERA_STORAGE_STATUS, 3.4f, 12.6f, 16.0f, 22.4f, "105E90HD"); camera_status_events.push_back(camera_status_event); checkSendsCameraStatus(camera_status_events); @@ -874,8 +877,8 @@ void CameraServiceImplTest::checkSendsCameraStatus( camera_status_callback(camera_status_event); } context->TryCancel(); - auto arbitrary_camera_status_event = - createCameraStatus(false, true, ARBITRARY_CAMERA_STORAGE_STATUS, 3.4f, 12.6f, 16.0f, 0.0f); + auto arbitrary_camera_status_event = createCameraStatus( + false, true, ARBITRARY_CAMERA_STORAGE_STATUS, 3.4f, 12.6f, 16.0f, 0.0f, "111E90HD"); camera_status_callback(arbitrary_camera_status_event); camera_status_events_future.wait(); @@ -896,7 +899,8 @@ TEST_F(CameraServiceImplTest, sendsMultipleCameraStatus) 1.2f, 3.4f, 2.2f, - 2.3f)); + 2.3f, + "104E90HD")); camera_status_events.push_back( createCameraStatus(true, false, @@ -904,7 +908,8 @@ TEST_F(CameraServiceImplTest, sendsMultipleCameraStatus) 11.2f, 58.4f, 8.65f, - 2.2f)); + 2.2f, + "360E90HD")); camera_status_events.push_back( createCameraStatus(false, false, @@ -912,7 +917,8 @@ TEST_F(CameraServiceImplTest, sendsMultipleCameraStatus) 1.5f, 8.1f, 6.3f, - 1.4f)); + 1.4f, + "GOPRO621")); checkSendsCameraStatus(camera_status_events); } diff --git a/plugins/camera/camera.cpp b/plugins/camera/camera.cpp index 6872e87da9..a93e01194d 100644 --- a/plugins/camera/camera.cpp +++ b/plugins/camera/camera.cpp @@ -287,6 +287,7 @@ bool operator==(const Camera::Status &lhs, const Camera::Status &rhs) lhs.used_storage_mib == rhs.used_storage_mib && lhs.available_storage_mib == rhs.available_storage_mib && lhs.total_storage_mib == rhs.total_storage_mib && + lhs.media_folder_name == rhs.media_folder_name && lhs.recording_time_s == rhs.recording_time_s && lhs.storage_status == rhs.storage_status; } @@ -298,6 +299,7 @@ std::ostream &operator<<(std::ostream &str, Camera::Status const &status) << ", available_storage_mib: " << status.available_storage_mib << ", total_storage_mib: " << status.total_storage_mib << ", recording_time_s: " << status.recording_time_s + << ", media_folder_name: " << status.media_folder_name << ", storage_status: " << status.storage_status << "]"; }