From: Philip Chimento Date: Thu, 12 Nov 2009 23:58:29 +0000 (+0000) Subject: Added Andrew Plotkin's unit tests for Glulx interpreters X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=05083a0ec75bbe2f9a80af09fa9469f64c7bb3f0;p=rodin%2Fchimara.git Added Andrew Plotkin's unit tests for Glulx interpreters git-svn-id: http://lassie.dyndns-server.com/svn/gargoyle-gtk@155 ddfedd41-794f-dd11-ae45-00112f111e67 --- diff --git a/tests/Makefile.am b/tests/Makefile.am index d0849b4..32c81c0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,9 +1,9 @@ AM_CFLAGS = -Wall AM_CPPFLAGS = -I$(top_srcdir) -dist_data_DATA = chimara.ui chimara.menus +dist_data_DATA = chimara.ui chimara.menus glulxercise.ui -noinst_PROGRAMS = test-chimara test-multisession +noinst_PROGRAMS = test-chimara test-multisession glulxercise test_chimara_SOURCES = main.c callbacks.c error.c error.h test_chimara_CPPFLAGS = $(AM_CPPFLAGS) \ @@ -17,6 +17,10 @@ test_multisession_SOURCES = test-multisession.c test_multisession_CFLAGS = @TEST_CFLAGS@ $(AM_CFLAGS) test_multisession_LDADD = @TEST_LIBS@ $(top_builddir)/libchimara/libchimara.la +glulxercise_SOURCES = glulxercise.c error.c error.h +glulxercise_CFLAGS = @TEST_CFLAGS@ $(AM_CFLAGS) +glulxercise_LDADD = @TEST_LIBS@ $(top_builddir)/libchimara/libchimara.la + pkglib_LTLIBRARIES = first.la model.la gridtest.la splittest.la multiwin.la PLUGIN_LIBTOOL_FLAGS=-module -avoid-version -export-symbols-regex "^glk_main$$" diff --git a/tests/accelfunctest.ulx b/tests/accelfunctest.ulx new file mode 100644 index 0000000..8bf6aad Binary files /dev/null and b/tests/accelfunctest.ulx differ diff --git a/tests/glulxercise.c b/tests/glulxercise.c new file mode 100644 index 0000000..3c786a9 --- /dev/null +++ b/tests/glulxercise.c @@ -0,0 +1,105 @@ +#include +#include +#include +#include "error.h" + +#define LOAD_WIDGET(name) GTK_WIDGET(gtk_builder_get_object(builder, name)) + +typedef struct { + GtkWidget *window, *test_picker, *go, *stop, *interp; +} Widgets; + +gboolean +on_window_delete_event() +{ + gtk_main_quit(); + return TRUE; +} + +void +on_go_clicked(GtkButton *go, Widgets *w) +{ + GError *error = NULL; + + gchar *filename = NULL; + GtkTreeIter iter; + GtkTreeModel *model = gtk_combo_box_get_model(GTK_COMBO_BOX(w->test_picker)); + gtk_combo_box_get_active_iter(GTK_COMBO_BOX(w->test_picker), &iter); + gtk_tree_model_get(model, &iter, 1, &filename, -1); + g_object_unref(model); + + if( !chimara_if_run_game(CHIMARA_IF(w->interp), filename, &error) ) + { + error_dialog(GTK_WINDOW(w->window), error, "Error starting Glk library: "); + gtk_main_quit(); + } + + gtk_widget_set_sensitive(w->go, FALSE); + gtk_widget_set_sensitive(w->stop, TRUE); + gtk_widget_set_sensitive(w->test_picker, FALSE); +} + +void +on_stop_clicked(GtkButton *stop, Widgets *w) +{ + chimara_glk_stop( CHIMARA_GLK(w->interp) ); + chimara_glk_wait( CHIMARA_GLK(w->interp) ); + + gtk_widget_set_sensitive(w->stop, FALSE); + gtk_widget_set_sensitive(w->go, TRUE); + gtk_widget_set_sensitive(w->test_picker, TRUE); +} + +void +on_glulxe_toggled(GtkToggleButton *glulxe, Widgets *w) +{ + if(gtk_toggle_button_get_active(glulxe)) + chimara_if_set_preferred_interpreter(CHIMARA_IF(w->interp), CHIMARA_IF_FORMAT_GLULX, CHIMARA_IF_INTERPRETER_GLULXE); +} + +void +on_git_toggled(GtkToggleButton *git, Widgets *w) +{ + if(gtk_toggle_button_get_active(git)) + chimara_if_set_preferred_interpreter(CHIMARA_IF(w->interp), CHIMARA_IF_FORMAT_GLULX, CHIMARA_IF_INTERPRETER_GIT); +} + +int +main(int argc, char *argv[]) +{ + GError *error = NULL; + + if( !g_thread_supported() ) + g_thread_init(NULL); + gdk_threads_init(); + gtk_init(&argc, &argv); + + GtkBuilder *builder = gtk_builder_new(); + if(!gtk_builder_add_from_file(builder, "glulxercise.ui", &error)) + { + error_dialog(NULL, error, "Failed to build interface: "); + return 1; + } + + Widgets *w = g_slice_new0(Widgets); + w->window = LOAD_WIDGET("window"); + GtkWidget *vbox = LOAD_WIDGET("vbox"); + w->test_picker = LOAD_WIDGET("test_picker"); + w->go = LOAD_WIDGET("go"); + w->stop = LOAD_WIDGET("stop"); + w->interp = chimara_if_new(); + gtk_box_pack_end_defaults(GTK_BOX(vbox), w->interp); + gtk_builder_connect_signals(builder, w); + gtk_widget_show_all(w->window); + + gdk_threads_enter(); + gtk_main(); + gdk_threads_leave(); + + chimara_glk_stop( CHIMARA_GLK(w->interp) ); + chimara_glk_wait( CHIMARA_GLK(w->interp) ); + + g_slice_free(Widgets, w); + + return 0; +} diff --git a/tests/glulxercise.ui b/tests/glulxercise.ui new file mode 100644 index 0000000..384a343 --- /dev/null +++ b/tests/glulxercise.ui @@ -0,0 +1,183 @@ + + + + + + 500 + 600 + 6 + + + + True + vertical + 6 + + + True + 6 + + + True + tests + 0 + + + + 0 + + + + + 0 + + + + + True + 6 + + + _Go + True + True + True + image1 + True + + + + 0 + + + + + gtk-stop + True + False + True + True + True + + + + False + 1 + + + + + False + 1 + + + + + False + 0 + + + + + True + 6 + + + True + 1 + Use + + + False + 0 + + + + + Glulx_e + True + True + False + True + True + True + + + + False + 1 + + + + + Gi_t + True + True + False + True + True + True + glulxe + + + + False + 2 + + + + + False + 1 + + + + + + + + + + + + + + + + + + Glulxercise + glulxercise.ulx + + + AccelFuncTest + accelfunctest.ulx + + + InputEventTest + inputeventtest.ulx + + + MemCopyTest + memcopytest.ulx + + + MemHeapTest + memheaptest.ulx + + + MemStreamTest + memstreamtest.ulx + + + UnicodeTest + unicodetest.ulx + + + + + True + gtk-yes + 4 + + diff --git a/tests/glulxercise.ulx b/tests/glulxercise.ulx new file mode 100644 index 0000000..671a325 Binary files /dev/null and b/tests/glulxercise.ulx differ diff --git a/tests/inputeventtext.ulx b/tests/inputeventtext.ulx new file mode 100644 index 0000000..3c45b24 Binary files /dev/null and b/tests/inputeventtext.ulx differ diff --git a/tests/memcopytest.ulx b/tests/memcopytest.ulx new file mode 100644 index 0000000..a25f873 Binary files /dev/null and b/tests/memcopytest.ulx differ diff --git a/tests/memheaptest.ulx b/tests/memheaptest.ulx new file mode 100644 index 0000000..7930b89 Binary files /dev/null and b/tests/memheaptest.ulx differ diff --git a/tests/memstreamtest.ulx b/tests/memstreamtest.ulx new file mode 100644 index 0000000..d784b3a Binary files /dev/null and b/tests/memstreamtest.ulx differ diff --git a/tests/unicodetest.ulx b/tests/unicodetest.ulx new file mode 100644 index 0000000..481ab6c Binary files /dev/null and b/tests/unicodetest.ulx differ