Skip to content

Commit

Permalink
backend: add media_folder_name to CameraStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasVautherin committed Aug 30, 2018
1 parent e303cc6 commit 9707e5c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion backend/proto
Submodule proto updated from 2c4649 to e7a285
2 changes: 2 additions & 0 deletions backend/src/plugins/camera/camera_service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
28 changes: 17 additions & 11 deletions backend/test/camera_service_impl_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ class CameraServiceImplTest : public ::testing::TestWithParam<InputPair> {
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<void>
subscribeCameraStatusAsync(std::vector<dronecode_sdk::Camera::Status> &camera_status_events,
std::shared_ptr<grpc::ClientContext> context) const;
Expand Down Expand Up @@ -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));
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -849,8 +852,8 @@ TEST_F(CameraServiceImplTest, doesNotSendCameraStatusIfCallbackNotCalled)
TEST_F(CameraServiceImplTest, sendsOneCameraStatus)
{
std::vector<dronecode_sdk::Camera::Status> 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);
Expand All @@ -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();

Expand All @@ -896,23 +899,26 @@ TEST_F(CameraServiceImplTest, sendsMultipleCameraStatus)
1.2f,
3.4f,
2.2f,
2.3f));
2.3f,
"104E90HD"));
camera_status_events.push_back(
createCameraStatus(true,
false,
dronecode_sdk::Camera::Status::StorageStatus::FORMATTED,
11.2f,
58.4f,
8.65f,
2.2f));
2.2f,
"360E90HD"));
camera_status_events.push_back(
createCameraStatus(false,
false,
dronecode_sdk::Camera::Status::StorageStatus::NOT_AVAILABLE,
1.5f,
8.1f,
6.3f,
1.4f));
1.4f,
"GOPRO621"));

checkSendsCameraStatus(camera_status_events);
}
Expand Down
2 changes: 2 additions & 0 deletions plugins/camera/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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 << "]";
}

Expand Down

0 comments on commit 9707e5c

Please sign in to comment.