r15357 - gnucash/branches/sx-cleanup/src/gnome-utils/test - Add (start of) test of gnc-dense-cal-instance-model-adapter, gnc-dense-cal.
Josh Sled
jsled at cvs.gnucash.org
Sat Jan 13 14:37:51 EST 2007
Author: jsled
Date: 2007-01-13 14:37:50 -0500 (Sat, 13 Jan 2007)
New Revision: 15357
Trac: http://svn.gnucash.org/trac/changeset/15357
Added:
gnucash/branches/sx-cleanup/src/gnome-utils/test/test-sx.c
Modified:
gnucash/branches/sx-cleanup/src/gnome-utils/test/Makefile.am
Log:
Add (start of) test of gnc-dense-cal-instance-model-adapter, gnc-dense-cal.
Modified: gnucash/branches/sx-cleanup/src/gnome-utils/test/Makefile.am
===================================================================
--- gnucash/branches/sx-cleanup/src/gnome-utils/test/Makefile.am 2007-01-13 19:36:59 UTC (rev 15356)
+++ gnucash/branches/sx-cleanup/src/gnome-utils/test/Makefile.am 2007-01-13 19:37:50 UTC (rev 15357)
@@ -1,5 +1,5 @@
TESTS = \
- test-link-module test-load-module
+ test-link-module test-load-module test-sx
# The following tests are nice, but have absolutely no place in an
# automated testing system.
@@ -31,29 +31,30 @@
$(shell ${top_srcdir}/src/gnc-test-env --no-exports ${GNC_TEST_DEPS})
noinst_PROGRAMS = \
- test-link-module test-gnc-recurrence test-gnc-dialog
+ test-link-module test-gnc-recurrence test-gnc-dialog test-sx
INCLUDES= \
-I${top_srcdir}/src \
-I${top_srcdir}/src/engine \
+ -I${top_srcdir}/src/engine/test-core \
-I${top_srcdir}/src/gnome-utils \
-I${top_srcdir}/src/gnc-module \
-I${top_srcdir}/src/app-utils \
+ -I${top_srcdir}/src/test-core \
${GLIB_CFLAGS} ${GUILE_INCS} ${GNOME_CFLAGS} ${GLADE_CFLAGS} ${QOF_CFLAGS}
-test_gnc_recurrence_SOURCES=test-gnc-recurrence.c
-test_gnc_recurrence_LDADD = ${GNOME_LIBS} \
+LDADD = \
+ ${GNOME_LIBS} \
${top_builddir}/src/app-utils/libgncmod-app-utils.la \
${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
- ${top_builddir}/src/engine/libgncmod-engine.la
+ ${top_builddir}/src/engine/libgncmod-engine.la \
+ ${top_builddir}/src/engine/test-core/libgncmod-test-engine.la \
+ ${top_builddir}/src/test-core/libgncmod-test.la
-test_gnc_dialog_LDADD = ${GNOME_LIBS} \
- ${top_builddir}/src/app-utils/libgncmod-app-utils.la \
- ${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
- ${top_builddir}/src/engine/libgncmod-engine.la
+test_gnc_recurrence_SOURCES=test-gnc-recurrence.c
test_link_module_SOURCES=test-link-module.c
-test_link_module_LDADD= \
+test_link_module_LDADD = \
${GUILE_LIBS} \
${top_builddir}/src/gnc-module/libgncmodule.la
@@ -62,5 +63,3 @@
testit:
libtool --mode execute gdb test-link-module
-
-
Added: gnucash/branches/sx-cleanup/src/gnome-utils/test/test-sx.c
===================================================================
--- gnucash/branches/sx-cleanup/src/gnome-utils/test/test-sx.c 2007-01-13 19:36:59 UTC (rev 15356)
+++ gnucash/branches/sx-cleanup/src/gnome-utils/test/test-sx.c 2007-01-13 19:37:50 UTC (rev 15357)
@@ -0,0 +1,80 @@
+#include "config.h"
+#include <glib.h>
+#include "qof.h"
+#include "gnc-engine.h"
+#include "gnc-sx-instance-model.h"
+#include "gnc-sx-instance-dense-cal-adapter.h"
+#include "gnc-dense-cal.h"
+#include "gnc-dense-cal-model.h"
+
+#include "test-stuff.h"
+#include "test-engine-stuff.h"
+
+static void
+_removing(GObject *obj, SchedXaction *removing, gpointer unused_user_data)
+{
+ gnc_sx_instance_model_remove_sx_instances(GNC_SX_INSTANCE_MODEL(obj), removing);
+}
+
+static void
+setup_default_handlers(GncSxInstanceModel *model)
+{
+ g_signal_connect(model, "removing", (GCallback)_removing, NULL);
+}
+
+static void
+test()
+{
+ GDate *start, *end;
+ GncSxInstanceModel *model;
+ GncSxInstanceDenseCalAdapter *dense_cal_model;
+ GncDenseCal *cal;
+ SchedXaction *foo, *bar;
+
+ start = g_date_new();
+ g_date_clear(start, 1);
+ g_date_set_time_t(start, time(NULL));
+
+ end = g_date_new();
+ g_date_clear(end, 1);
+ g_date_set_time_t(end, time(NULL));
+ g_date_add_years(end, 1);
+
+ foo = add_daily_sx("foo", start, NULL, NULL);
+
+ model = gnc_sx_get_instances(end);
+ setup_default_handlers(model);
+
+ do_test(g_list_length(model->sx_instance_list) == 1, "1 instances");
+
+ dense_cal_model = gnc_sx_instance_dense_cal_adapter_new(model);
+ cal = GNC_DENSE_CAL(gnc_dense_cal_new_with_model(GNC_DENSE_CAL_MODEL(dense_cal_model)));
+ g_object_ref_sink(cal);
+
+ bar = add_daily_sx("bar", start, NULL, NULL);
+ do_test(g_list_length(model->sx_instance_list) == 2, "2 instances");
+
+ remove_sx(foo);
+
+ do_test(g_list_length(model->sx_instance_list) == 1, "1 instance");
+
+ g_object_unref(cal);
+ success("freed calendar");
+ g_object_unref(dense_cal_model);
+ success("freed dense-cal model");
+ g_object_unref(model);
+ success("freed instances");
+}
+
+int
+main(int argc, char **argv)
+{
+ g_type_init();
+ gnc_engine_init(argc, argv);
+ gtk_init(&argc, &argv);
+
+ test();
+
+ print_test_results();
+ exit(get_rv());
+}
More information about the gnucash-changes
mailing list