about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-02-23 20:09:00 +0000
committerJames Booth <boothj5@gmail.com>2014-02-23 20:09:00 +0000
commit1f78d5b582205c590eee2cfc6b1c3ddd7f390b26 (patch)
treee86c3335634f27c2ed81ce6b2321377b574ea41c
parent5307b92821d2988a51c3048db9912d8a45dc6cde (diff)
downloadprofani-tty-1f78d5b582205c590eee2cfc6b1c3ddd7f390b26.tar.gz
Added tests for /otr start from non chat windows
-rw-r--r--tests/test_cmd_otr.c37
-rw-r--r--tests/test_cmd_otr.h4
-rw-r--r--tests/testsuite.c4
3 files changed, 45 insertions, 0 deletions
diff --git a/tests/test_cmd_otr.c b/tests/test_cmd_otr.c
index 57b26df3..5ad66514 100644
--- a/tests/test_cmd_otr.c
+++ b/tests/test_cmd_otr.c
@@ -468,6 +468,43 @@ void cmd_otr_theirfp_shows_fingerprint(void **state)
     free(help);
 }
 
+static void
+test_cmd_otr_start_from_wintype(win_type_t wintype)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { "start", NULL };
+    mock_connection_status(JABBER_CONNECTED);
+    mock_current_win_type(wintype);
+    mock_ui_current_print_line();
+
+    ui_current_print_line_expect("You must be in a regular chat window to start an OTR session.");
+
+    gboolean result = cmd_otr(args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_otr_start_shows_message_when_in_console(void **state)
+{
+    test_cmd_otr_start_from_wintype(WIN_CONSOLE);
+}
+
+void cmd_otr_start_shows_message_when_in_muc(void **state)
+{
+    test_cmd_otr_start_from_wintype(WIN_MUC);
+}
+
+void cmd_otr_start_shows_message_when_in_private(void **state)
+{
+    test_cmd_otr_start_from_wintype(WIN_PRIVATE);
+}
+
+void cmd_otr_start_shows_message_when_in_duck(void **state)
+{
+    test_cmd_otr_start_from_wintype(WIN_DUCK);
+}
+
 #else
 void cmd_otr_shows_message_when_otr_unsupported(void **state)
 {
diff --git a/tests/test_cmd_otr.h b/tests/test_cmd_otr.h
index 95c67a46..7d217770 100644
--- a/tests/test_cmd_otr.h
+++ b/tests/test_cmd_otr.h
@@ -34,6 +34,10 @@ void cmd_otr_theirfp_shows_message_when_in_private(void **state);
 void cmd_otr_theirfp_shows_message_when_in_duck(void **state);
 void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state);
 void cmd_otr_theirfp_shows_fingerprint(void **state);
+void cmd_otr_start_shows_message_when_in_console(void **state);
+void cmd_otr_start_shows_message_when_in_muc(void **state);
+void cmd_otr_start_shows_message_when_in_private(void **state);
+void cmd_otr_start_shows_message_when_in_duck(void **state);
 #else
 void cmd_otr_shows_message_when_otr_unsupported(void **state);
 #endif
diff --git a/tests/testsuite.c b/tests/testsuite.c
index 0e3911ad..a0f61cbd 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -475,6 +475,10 @@ int main(int argc, char* argv[]) {
         unit_test(cmd_otr_theirfp_shows_message_when_in_duck),
         unit_test(cmd_otr_theirfp_shows_message_when_non_otr_chat_window),
         unit_test(cmd_otr_theirfp_shows_fingerprint),
+        unit_test(cmd_otr_start_shows_message_when_in_console),
+        unit_test(cmd_otr_start_shows_message_when_in_muc),
+        unit_test(cmd_otr_start_shows_message_when_in_private),
+        unit_test(cmd_otr_start_shows_message_when_in_duck),
 #else
         unit_test(cmd_otr_shows_message_when_otr_unsupported),
 #endif