changeset 408:7f7855df2af0

Make unittest built by automake and autoconf. ./configure --enable-testcase to build testcase.
author Thinker K.F. Li <thinker@branda.to>
date Tue, 07 Jul 2009 22:46:19 +0800
parents 92a459a1c5aa
children 1e9b615a47e8
files configure.ac include/mb_paint.h src/Makefile.am src/event.c src/redraw_man.c
diffstat 5 files changed, 28 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Tue Jul 07 22:45:12 2009 +0800
+++ b/configure.ac	Tue Jul 07 22:46:19 2009 +0800
@@ -14,7 +14,7 @@
 
 # Checks for libraries.
 PKG_CHECK_MODULES([cairo], [cairo >= 1.6], , AC_MSG_ERROR([cairo >= 1.6 not found]))
-PKG_CHECK_MODULES([pangocairo], [pangocairo >= 1.22], , AC_MSG_ERROR([pangocairo >= 1.22 not found]))
+PKG_CHECK_MODULES([pangocairo], [pangocairo >= 1.0], , AC_MSG_ERROR([pangocairo >= 1.0 not found]))
 
 # Checks for header files.
 AC_PATH_X
@@ -35,6 +35,10 @@
 AC_FUNC_SELECT_ARGTYPES
 AC_CHECK_FUNCS([gettimeofday memset select sqrt strdup])
 
+AC_ARG_ENABLE([testcase],[enable testcase for unittest],
+	[AC_SUBST([TESTCASE],[testcase])],
+	[AC_SUBST([TESTCASE],)])
+
 AC_CONFIG_FILES([Makefile
                  libmbfly.pc
                  libmbfly-uninstalled.pc
--- a/include/mb_paint.h	Tue Jul 07 22:45:12 2009 +0800
+++ b/include/mb_paint.h	Tue Jul 07 22:46:19 2009 +0800
@@ -4,6 +4,7 @@
 #include <cairo.h>
 #include "mb_types.h"
 #include "mb_redraw_man.h"
+#include "mb_img_ldr.h"
 #include "mb_tools.h"
 
 typedef float co_comp_t;
--- a/src/Makefile.am	Tue Jul 07 22:45:12 2009 +0800
+++ b/src/Makefile.am	Tue Jul 07 22:46:19 2009 +0800
@@ -2,7 +2,8 @@
 
 lib_LTLIBRARIES = libmbfly.la
 
-noinst_PROGRAMS = X_main
+noinst_PROGRAMS = X_main $(TESTCASE)
+
 MBAF_SOURCES=mbaf/mbapp.c mbaf/mbbutton.c mbaf/mbobject.c mbaf/animated_menu.c
 libmbfly_la_SOURCES = animate.c chgcolor.c coord.c event.c geo.c	\
 	observer.c paint.c redraw_man.c rotate.c shape_path.c		\
@@ -15,5 +16,13 @@
 
 X_main_SOURCES = X_main.c
 X_main_LDADD = $(top_builddir)/src/libmbfly.la
-X_main_CPPFLAGS = @pangocairo_CFLAGS@ -I$(top_builddir)/src
+X_main_CPPFLAGS = @pangocairo_CFLAGS@ -I$(top_builddir)/include
 X_main_LDFLAGS = @pangocairo_LIBS@
+
+testcase_SOURCES = testcase.c $(libmbfly_la_SOURCES)
+testcase_CFLAGS = -I$(top_builddir)/include \
+		-DUNITTEST -g @cairo_CFLAGS@ \
+		@pangocairo_CFLAGS@
+testcase_LDFLAGS = -lcunit -L/usr/local/lib/ @pangocairo_LIBS@
+
+EXTRA_PROGRAMS = testcase
--- a/src/event.c	Tue Jul 07 22:45:12 2009 +0800
+++ b/src/event.c	Tue Jul 07 22:46:19 2009 +0800
@@ -116,7 +116,7 @@
 	    (w) += (s) - (a);			\
 	    (s) = (a);				\
 	} else {				\
-	    (w) = MAX(w, (a) - (s) + 1);	\
+	    (w) = MB_MAX(w, (a) - (s) + 1);	\
 	}					\
     } while(0)
 
@@ -155,7 +155,8 @@
        MBO_SHAPES=0x1000,
        MBO_PATH,
        MBO_TEXT,
-       MBO_RECT
+       MBO_RECT,
+       MBO_IMAGE
 };
 #define MBO_TYPE(x) (((mb_obj_t *)(x))->obj_type)
 #define IS_MBO_SHAPES(x) (((mb_obj_t *)(x))->obj_type & MBO_SHAPES)
--- a/src/redraw_man.c	Tue Jul 07 22:45:12 2009 +0800
+++ b/src/redraw_man.c	Tue Jul 07 22:46:19 2009 +0800
@@ -10,6 +10,9 @@
 #include "mb_observer.h"
 #include "mb_prop.h"
 
+/* required by rdman_img_ldr_load_paint() */
+#include "mb_paint.h"
+
 /*! \page dirty Dirty geo, coord, and area.
  *
  * \section dirty_of_ego Dirty of geo
@@ -1885,6 +1888,10 @@
     cairo_set_operator(rdman->backend, saved_op);
 }
 #else /* UNITTEST */
+static void make_clip(cairo_t *cr, int n_dirty_areas,
+		      area_t **dirty_areas) {
+}
+
 static void clear_canvas(canvas_t *canvas) {
 }
 
@@ -2293,7 +2300,6 @@
 /* Test cases */
 
 #include <CUnit/Basic.h>
-#include "mb_paint.h"
 
 struct _sh_dummy {
     shape_t shape;
@@ -2376,7 +2382,7 @@
     if(paint == NULL)
 	return NULL;
 
-    paint_init(paint, dummy_paint_prepare, dummy_paint_free);
+    paint_init(paint, MBP_DUMMY, dummy_paint_prepare, dummy_paint_free);
 
     return paint;
 }