1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added carbon message tests

This commit is contained in:
James Booth 2015-07-20 21:28:25 +01:00
parent b63ede7964
commit bdcc0ddbf8
3 changed files with 79 additions and 0 deletions

View File

@ -124,6 +124,12 @@ int main(int argc, char* argv[]) {
unit_test_setup_teardown(send_disable_carbons, unit_test_setup_teardown(send_disable_carbons,
init_prof_test, init_prof_test,
close_prof_test), close_prof_test),
unit_test_setup_teardown(receive_carbon,
init_prof_test,
close_prof_test),
unit_test_setup_teardown(receive_self_carbon,
init_prof_test,
close_prof_test),
}; };
return run_tests(all_tests); return run_tests(all_tests);

View File

@ -48,3 +48,73 @@ send_disable_carbons(void **state)
"<iq id=\"*\" type=\"set\"><disable xmlns=\"urn:xmpp:carbons:2\"/></iq>" "<iq id=\"*\" type=\"set\"><disable xmlns=\"urn:xmpp:carbons:2\"/></iq>"
)); ));
} }
void
receive_carbon(void **state)
{
prof_input("/carbons on");
prof_connect();
assert_true(stbbr_received(
"<iq id=\"*\" type=\"set\"><enable xmlns=\"urn:xmpp:carbons:2\"/></iq>"
));
stbbr_send(
"<presence to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\">"
"<priority>10</priority>"
"<status>On my mobile</status>"
"</presence>"
);
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\""));
prof_input("/msg Buddy1");
prof_output_exact("unencrypted");
stbbr_send(
"<message type=\"chat\" to=\"stabber@localhost/profanity\" from=\"buddy1@localhost\">"
"<received xmlns=\"urn:xmpp:carbons:2\">"
"<forwarded xmlns=\"urn:xmpp:forward:0\">"
"<message id=\"prof_msg_7\" xmlns=\"jabber:client\" type=\"chat\" lang=\"en\" to=\"stabber@localhost/profanity\" from=\"buddy1@localhost/mobile\">"
"<body>test carbon from recipient</body>"
"</message>"
"</forwarded>"
"</received>"
"</message>"
);
assert_true(prof_output_regex("Buddy1/mobile: .+test carbon from recipient"));
}
void
receive_self_carbon(void **state)
{
prof_input("/carbons on");
prof_connect();
assert_true(stbbr_received(
"<iq id=\"*\" type=\"set\"><enable xmlns=\"urn:xmpp:carbons:2\"/></iq>"
));
stbbr_send(
"<presence to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\">"
"<priority>10</priority>"
"<status>On my mobile</status>"
"</presence>"
);
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\""));
prof_input("/msg Buddy1");
prof_output_exact("unencrypted");
stbbr_send(
"<message type=\"chat\" to=\"stabber@localhost/profanity\" from=\"stabber@localhost\">"
"<sent xmlns=\"urn:xmpp:carbons:2\">"
"<forwarded xmlns=\"urn:xmpp:forward:0\">"
"<message id=\"59\" xmlns=\"jabber:client\" type=\"chat\" to=\"buddy1@localhost/mobile\" lang=\"en\" from=\"stabber@localhost/profanity\">"
"<body>self sent carbon</body>"
"</message>"
"</forwarded>"
"</sent>"
"</message>"
);
assert_true(prof_output_regex("me: .+self sent carbon"));
}

View File

@ -1,3 +1,6 @@
void send_enable_carbons(void **state); void send_enable_carbons(void **state);
void connect_with_carbons_enabled(void **state); void connect_with_carbons_enabled(void **state);
void send_disable_carbons(void **state); void send_disable_carbons(void **state);
void receive_carbon(void **state);
void receive_self_carbon(void **state);