From 96e32fe17846a8ef25faad25bd57fbdc7338a16f Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 1 Apr 2014 23:14:53 +0100 Subject: [PATCH] Added cmd_win test --- Makefile.am | 1 + tests/testsuite.c | 3 +++ tests/ui/mock_ui.c | 20 ++++++++++++++++++++ tests/ui/mock_ui.h | 3 +++ 4 files changed, 27 insertions(+) diff --git a/Makefile.am b/Makefile.am index b508981b..13f2d591 100644 --- a/Makefile.am +++ b/Makefile.am @@ -77,6 +77,7 @@ tests_sources = \ tests/test_server_events.c \ tests/test_muc.c \ tests/test_cmd_roster.c \ + tests/test_cmd_win.c \ tests/testsuite.c main_source = src/main.c diff --git a/tests/testsuite.c b/tests/testsuite.c index f5bc8faf..93c5688e 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -30,6 +30,7 @@ #include "test_cmd_join.h" #include "test_muc.h" #include "test_cmd_roster.h" +#include "test_cmd_win.h" int main(int argc, char* argv[]) { const UnitTest all_tests[] = { @@ -518,6 +519,8 @@ int main(int argc, char* argv[]) { unit_test(cmd_roster_clearnick_shows_message_when_no_jid), unit_test(cmd_roster_clearnick_shows_message_when_no_contact_exists), unit_test(cmd_roster_clearnick_sends_name_change_request_with_empty_nick), + + unit_test(cmd_win_shows_message_when_win_doesnt_exist), }; return run_tests(all_tests); diff --git a/tests/ui/mock_ui.c b/tests/ui/mock_ui.c index 67eb51e8..5dc52a10 100644 --- a/tests/ui/mock_ui.c +++ b/tests/ui/mock_ui.c @@ -177,6 +177,13 @@ void _mock_cons_show_roster(GSList *list) check_expected(list); } +static +gboolean _mock_ui_win_exists(int index) +{ + check_expected(index); + return (gboolean)mock(); +} + // bind mocks and stubs void @@ -288,6 +295,12 @@ mock_cons_show_roster(void) cons_show_roster = _mock_cons_show_roster; } +void +mock_ui_win_exists(void) +{ + ui_win_exists = _mock_ui_win_exists; +} + // expectations void @@ -438,3 +451,10 @@ cons_show_roster_expect(GSList *list) { expect_any(_mock_cons_show_roster, list); } + +void +ui_win_exists_expect_and_return(int given_index, gboolean result) +{ + expect_value(_mock_ui_win_exists, index, given_index); + will_return(_mock_ui_win_exists, result); +} diff --git a/tests/ui/mock_ui.h b/tests/ui/mock_ui.h index 55b036e6..c939a002 100644 --- a/tests/ui/mock_ui.h +++ b/tests/ui/mock_ui.h @@ -64,4 +64,7 @@ void ui_room_join_expect(char *room); void mock_cons_show_roster(void); void cons_show_roster_expect(GSList *list); +void mock_ui_win_exists(void); +void ui_win_exists_expect_and_return(int given_index, gboolean result); + #endif