/* * test_carbons.c * * Copyright (C) 2015 - 2017 James Booth * Copyright (C) 2026 - 2026 Michael Vetter * * SPDX-License-Identifier: GPL-3.0-or-later */ #include #include "prof_cmocka.h" #include #include #include #include "proftest.h" void send_enable_carbons(void** state) { prof_connect(); prof_input("/carbons on"); assert_true(stbbr_received( "")); } void connect_with_carbons_enabled(void** state) { prof_input("/carbons on"); prof_connect(); assert_true(stbbr_received( "")); } void send_disable_carbons(void** state) { prof_input("/carbons on"); prof_connect(); assert_true(stbbr_received( "")); prof_input("/carbons off"); assert_true(stbbr_received( "")); } void receive_carbon(void** state) { prof_input("/carbons on"); stbbr_for_xmlns("urn:xmpp:carbons:2", ""); prof_connect(); assert_true(stbbr_received( "")); stbbr_send( "" "10" "On my mobile" ""); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\"")); prof_input("/msg Buddy1"); assert_true(prof_output_exact("unencrypted")); stbbr_send( "" "" "" "" "test carbon from recipient" "" "" "" ""); assert_true(prof_output_regex("Buddy1/mobile: test carbon from recipient")); } void receive_self_carbon(void** state) { prof_input("/carbons on"); stbbr_for_xmlns("urn:xmpp:carbons:2", ""); prof_connect(); assert_true(stbbr_received( "")); stbbr_send( "" "10" "On my mobile" ""); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\"")); prof_input("/msg Buddy1"); assert_true(prof_output_exact("unencrypted")); stbbr_send( "" "" "" "" "test carbon from sender" "" "" "" ""); assert_true(prof_output_regex("me: test carbon from sender")); } void receive_private_carbon(void** state) { prof_input("/carbons on"); stbbr_for_xmlns("urn:xmpp:carbons:2", ""); prof_connect(); assert_true(stbbr_received( "")); stbbr_send( "" "10" "On my mobile" ""); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\"")); prof_input("/msg Buddy1"); assert_true(prof_output_exact("unencrypted")); stbbr_send( "" "" "" "" "Private carbon" "" "" "" "" ""); assert_true(prof_output_regex("Buddy1/mobile: Private carbon")); }