about summary refs log tree commit diff stats
path: root/tests/functionaltests
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-07-20 21:28:25 +0100
committerJames Booth <boothj5@gmail.com>2015-07-20 21:36:58 +0100
commitbdcc0ddbf813f9b19016eb873d5abe0d9d417996 (patch)
treeb498ee41023c77298f1c605ecb842c5f4b8560d4 /tests/functionaltests
parentb63ede7964ffb932d27fac0bfe22aae7b92de2a5 (diff)
downloadprofani-tty-bdcc0ddbf813f9b19016eb873d5abe0d9d417996.tar.gz
Added carbon message tests
Diffstat (limited to 'tests/functionaltests')
-rw-r--r--tests/functionaltests/functionaltests.c6
-rw-r--r--tests/functionaltests/test_carbons.c70
-rw-r--r--tests/functionaltests/test_carbons.h3
3 files changed, 79 insertions, 0 deletions
diff --git a/tests/functionaltests/functionaltests.c b/tests/functionaltests/functionaltests.c
index 60ad341c..b665ad4b 100644
--- a/tests/functionaltests/functionaltests.c
+++ b/tests/functionaltests/functionaltests.c
@@ -124,6 +124,12 @@ int main(int argc, char* argv[]) {
         unit_test_setup_teardown(send_disable_carbons,
             init_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);
diff --git a/tests/functionaltests/test_carbons.c b/tests/functionaltests/test_carbons.c
index f0a8214b..96639d60 100644
--- a/tests/functionaltests/test_carbons.c
+++ b/tests/functionaltests/test_carbons.c
@@ -48,3 +48,73 @@ send_disable_carbons(void **state)
         "<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"));
+}
diff --git a/tests/functionaltests/test_carbons.h b/tests/functionaltests/test_carbons.h
index 6f756d33..6d24c8ae 100644
--- a/tests/functionaltests/test_carbons.h
+++ b/tests/functionaltests/test_carbons.h
@@ -1,3 +1,6 @@
 void send_enable_carbons(void **state);
 void connect_with_carbons_enabled(void **state);
 void send_disable_carbons(void **state);
+void receive_carbon(void **state);
+void receive_self_carbon(void **state);
+