about summary refs log tree commit diff stats
path: root/tests/ui/mock_ui.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-12-19 21:05:39 +0000
committerJames Booth <boothj5@gmail.com>2013-12-19 21:05:39 +0000
commitd56f6dc39b002e16966354b0ad98cf7801260e0c (patch)
tree07480d1c9e14084dbfc5345a00fc002419ef50d9 /tests/ui/mock_ui.c
parentb27c5d0f5baa7161231642b14106db2e96065f95 (diff)
downloadprofani-tty-d56f6dc39b002e16966354b0ad98cf7801260e0c.tar.gz
Added mocks and stubs for cons_show
Diffstat (limited to 'tests/ui/mock_ui.c')
-rw-r--r--tests/ui/mock_ui.c51
1 files changed, 41 insertions, 10 deletions
diff --git a/tests/ui/mock_ui.c b/tests/ui/mock_ui.c
index 6e3e190c..c70fbcf4 100644
--- a/tests/ui/mock_ui.c
+++ b/tests/ui/mock_ui.c
@@ -1,5 +1,5 @@
 /*
- * mock_ui.h
+ * mock_ui.c
  *
  * Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com>
  *
@@ -28,6 +28,46 @@
 
 char output[256];
 
+static
+void _mock_cons_show(const char * const msg, ...)
+{
+    va_list args;
+    va_start(args, msg);
+    vsnprintf(output, sizeof(output), msg, args);
+    check_expected(output);
+    va_end(args);
+}
+
+static
+void _stub_cons_show(const char * const msg, ...)
+{
+}
+
+void
+mock_cons_show(void)
+{
+    cons_show = _mock_cons_show;
+    
+}
+
+void
+stub_cons_show(void)
+{
+    cons_show = _stub_cons_show;
+}
+
+void
+expect_cons_show(char *output)
+{
+    expect_string(_mock_cons_show, output, output);
+}
+
+void
+expect_cons_show_calls(int n)
+{
+    expect_any_count(_mock_cons_show, output, n);
+}
+
 // ui startup and control
 void ui_init(void) {}
 void ui_load_colours(void) {}
@@ -196,15 +236,6 @@ void title_bar_set_typing(gboolean is_typing) {}
 void title_bar_draw(void) {}
 
 // console window actions
-void cons_show(const char * const msg, ...)
-{
-    va_list args;
-    va_start(args, msg);
-    vsnprintf(output, sizeof(output), msg, args);
-    check_expected(output);
-    va_end(args);
-}
-
 void cons_about(void) {}
 void cons_help(void) {}
 void cons_basic_help(void) {}