1+ #include < algorithm>
12#include < viam/sdk/tests/mocks/camera_mocks.hpp>
23
34#include < viam/sdk/common/proto_value.hpp>
@@ -16,8 +17,23 @@ ProtoStruct MockCamera::do_command(const ProtoStruct&) {
1617Camera::raw_image MockCamera::get_image (std::string, const ProtoStruct&) {
1718 return image_;
1819}
19- Camera::image_collection MockCamera::get_images () {
20- return images_;
20+ Camera::image_collection MockCamera::get_images (std::vector<std::string> filter_source_names,
21+ const ProtoStruct& extra) {
22+ last_filter_source_names_ = std::move (filter_source_names);
23+ last_extra_ = extra;
24+ if (last_filter_source_names_.empty ()) {
25+ return images_;
26+ }
27+ Camera::image_collection filtered = images_;
28+ filtered.images .clear ();
29+ for (const auto & img : images_.images ) {
30+ if (std::find (last_filter_source_names_.begin (),
31+ last_filter_source_names_.end (),
32+ img.source_name ) != last_filter_source_names_.end ()) {
33+ filtered.images .push_back (img);
34+ }
35+ }
36+ return filtered;
2137}
2238Camera::point_cloud MockCamera::get_point_cloud (std::string, const ProtoStruct&) {
2339 return pc_;
@@ -43,13 +59,13 @@ Camera::image_collection fake_raw_images() {
4359 std::vector<Camera::raw_image> images;
4460 Camera::raw_image image1;
4561 image1.mime_type = " image/jpeg" ;
46- image1.source_name = " color_sensor " ;
62+ image1.source_name = " color " ;
4763 std::vector<unsigned char > bytes1 = {' a' , ' b' , ' c' };
4864 image1.bytes = bytes1;
4965 images.push_back (image1);
5066 Camera::raw_image image2;
5167 image2.mime_type = " image/vnd.viam.dep" ;
52- image2.source_name = " depth_sensor " ;
68+ image2.source_name = " depth " ;
5369 std::vector<unsigned char > bytes2 = {' d' , ' e' , ' f' };
5470 image2.bytes = bytes2;
5571 images.push_back (image2);
0 commit comments