11#include < viam/sdk/tests/mocks/camera_mocks.hpp>
2+ #include < algorithm>
23
34#include < viam/sdk/common/proto_value.hpp>
45#include < viam/sdk/components/camera.hpp>
@@ -16,8 +17,20 @@ 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, const ProtoStruct& extra) {
21+ last_filter_source_names_ = std::move (filter_source_names);
22+ last_extra_ = extra;
23+ if (last_filter_source_names_.empty ()) {
24+ return images_;
25+ }
26+ Camera::image_collection filtered = images_;
27+ filtered.images .clear ();
28+ for (const auto & img : images_.images ) {
29+ if (std::find (last_filter_source_names_.begin (), last_filter_source_names_.end (), img.source_name ) != last_filter_source_names_.end ()) {
30+ filtered.images .push_back (img);
31+ }
32+ }
33+ return filtered;
2134}
2235Camera::point_cloud MockCamera::get_point_cloud (std::string, const ProtoStruct&) {
2336 return pc_;
@@ -43,13 +56,13 @@ Camera::image_collection fake_raw_images() {
4356 std::vector<Camera::raw_image> images;
4457 Camera::raw_image image1;
4558 image1.mime_type = " image/jpeg" ;
46- image1.source_name = " color_sensor " ;
59+ image1.source_name = " color " ;
4760 std::vector<unsigned char > bytes1 = {' a' , ' b' , ' c' };
4861 image1.bytes = bytes1;
4962 images.push_back (image1);
5063 Camera::raw_image image2;
5164 image2.mime_type = " image/vnd.viam.dep" ;
52- image2.source_name = " depth_sensor " ;
65+ image2.source_name = " depth " ;
5366 std::vector<unsigned char > bytes2 = {' d' , ' e' , ' f' };
5467 image2.bytes = bytes2;
5568 images.push_back (image2);
0 commit comments