• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mavlink / MAVSDK / 4899817366

pending completion
4899817366

Pull #1772

github

GitHub
Merge c0bb90862 into e4e9c71dd
Pull Request #1772: Refactor MAVLinkParameters into client and server classes

2192 of 2192 new or added lines in 34 files covered. (100.0%)

7708 of 24812 relevant lines covered (31.07%)

19.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.71
/src/system_tests/camera_take_photo.cpp
1
#include "mavsdk.h"
2
#include "plugins/camera/camera.h"
3
#include "plugins/camera_server/camera_server.h"
4
#include "log.h"
5
#include <future>
6
#include <mutex>
7
#include <gtest/gtest.h>
8

9
using namespace mavsdk;
10

11
TEST(SystemTest, CameraTakePhoto)
1✔
12
{
13
    Mavsdk mavsdk_groundstation;
1✔
14
    mavsdk_groundstation.set_configuration(
1✔
15
        Mavsdk::Configuration{Mavsdk::Configuration::UsageType::GroundStation});
16

17
    Mavsdk mavsdk_camera;
1✔
18
    mavsdk_camera.set_configuration(
1✔
19
        Mavsdk::Configuration{Mavsdk::Configuration::UsageType::Camera});
20

21
    ASSERT_EQ(mavsdk_groundstation.add_any_connection("udp://:17000"), ConnectionResult::Success);
3✔
22
    ASSERT_EQ(mavsdk_camera.add_any_connection("udp://127.0.0.1:17000"), ConnectionResult::Success);
3✔
23

24
    auto camera_server =
1✔
25
        CameraServer{mavsdk_camera.server_component_by_type(Mavsdk::ServerComponentType::Camera)};
2✔
26
    camera_server.subscribe_take_photo([&camera_server](int32_t index) {
×
27
        LogInfo() << "Let's take photo " << index;
×
28

29
        CameraServer::CaptureInfo info;
×
30
        info.index = index;
×
31
        info.is_success = true;
×
32

33
        camera_server.respond_take_photo(CameraServer::TakePhotoFeedback::Ok, info);
×
34
    });
×
35

36
    auto prom = std::promise<std::shared_ptr<System>>();
1✔
37
    auto fut = prom.get_future();
1✔
38
    std::once_flag flag;
1✔
39

40
    auto handle = mavsdk_groundstation.subscribe_on_new_system([&]() {
1✔
41
        const auto system = mavsdk_groundstation.systems().back();
3✔
42
        if (system->is_connected() && system->has_camera()) {
1✔
43
            std::call_once(flag, [&]() { prom.set_value(system); });
2✔
44
        }
45
    });
1✔
46

47
    ASSERT_EQ(fut.wait_for(std::chrono::seconds(10)), std::future_status::ready);
1✔
48
    mavsdk_groundstation.unsubscribe_on_new_system(handle);
1✔
49
    auto system = fut.get();
1✔
50

51
    auto camera = Camera{system};
2✔
52
    return;
1✔
53

54
    // We want to take the picture in photo mode.
55
    // EXPECT_EQ(camera.set_mode(Camera::Mode::Photo), Camera::Result::Success);
56

57
    auto received_captured_info_prom = std::promise<void>{};
58
    auto received_captured_info_fut = received_captured_info_prom.get_future();
59

60
    Camera::CaptureInfoHandle capture_handle = camera.subscribe_capture_info(
61
        [&camera, &received_captured_info_prom, &capture_handle](Camera::CaptureInfo capture_info) {
×
62
            LogInfo() << "Received captured info for image: " << capture_info.index;
×
63
            // Unsubscribe again to prevent double setting promise.
64
            camera.unsubscribe_capture_info(capture_handle);
×
65
            received_captured_info_prom.set_value();
×
66
        });
×
67

68
    EXPECT_EQ(camera.take_photo(), Camera::Result::Success);
69
    ASSERT_EQ(
70
        received_captured_info_fut.wait_for(std::chrono::seconds(10)), std::future_status::ready);
71
    received_captured_info_fut.get();
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc