Made tests build and work again

This commit is contained in:
Yevgen Muntyan 2006-12-10 16:53:57 -06:00
parent 5bdb0977ce
commit 4e343cd912
9 changed files with 129 additions and 82 deletions

View File

@ -5,13 +5,31 @@ AM_CFLAGS = \
$(MOO_DEBUG_CFLAGS)
noinst_PROGRAMS =
EXTRA_PROGRAMS = \
testhtml testtext medit mterm \
markup termbuffer testfileview \
testpaned testpanedfileview \
miniglade langparser testobject \
testfold ms testkeyfile \
testthreads
test_programs = \
markup testpaned miniglade \
testobject testthreads
if MOO_BUILD_EDIT
test_programs += \
testtext testfileview \
testpanedfileview testfold \
testkeyfile
if MOO_OS_UNIX
test_programs += ms
endif
endif
if MOO_BUILD_TERM
test_programs += mterm termbuffer
endif
if MOO_BUILD_APP
test_programs += testhtml
endif
EXTRA_PROGRAMS = medit $(test_programs)
if MOO_ENABLE_TESTS
noinst_PROGRAMS += $(test_programs)
endif
all-tests: $(EXTRA_PROGRAMS)
@ -68,12 +86,9 @@ bin_PROGRAMS = $(medit)
ldflags = -export-dynamic $(PYTHON_EXTRA_LDFLAGS)
ldadd = ../moo/libmoo.la
test_ldflags = -export-dynamic $(PYTHON_EXTRA_LDFLAGS)
test_ldadd = ../moo/libmoo-test.la
if MOO_OS_MINGW
ldflags += -mwindows
test_ldflags += -mwindows
endif MOO_OS_MINGW
@ -111,10 +126,6 @@ testtext_LDADD = $(ldadd)
testtext_SOURCES = testtext.c
langparser_LDFLAGS = $(ldflags)
langparser_LDADD = $(ldadd)
langparser_SOURCES = testparser.c
testkeyfile_LDFLAGS = $(ldflags)
testkeyfile_LDADD = $(ldadd)
testkeyfile_SOURCES = testkeyfile.c

View File

@ -4,60 +4,82 @@
#include <string.h>
int main (int argc, char *argv[])
static void
show_it (MooGladeXML *xml,
const char *name)
{
MooGladeXML *my_xml;
gboolean check = FALSE;
const char *file;
GtkWidget *root;
GtkWidget *window, *widget;
gtk_init (&argc, &argv);
if (name)
widget = moo_glade_xml_get_widget (xml, name);
else
widget = moo_glade_xml_get_root (xml);
if (argc < 2)
g_return_if_fail (widget != NULL);
if (GTK_IS_WINDOW (widget))
{
g_print ("usage: %s [--check] <filename>\n", argv[0]);
exit (1);
}
if (!strcmp (argv[1], "--check"))
{
if (argc < 3)
{
g_print ("usage: %s [--check] <filename>\n", argv[0]);
exit (1);
}
else
{
file = argv[2];
check = TRUE;
}
window = widget;
}
else
{
file = argv[1];
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_add (GTK_CONTAINER (window), widget);
}
my_xml = moo_glade_xml_new (file, NULL);
gtk_widget_show (widget);
gtk_widget_show (window);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_main ();
}
if (!my_xml)
int main (int argc, char *argv[])
{
MooGladeXML *xml;
gboolean parse_only = FALSE;
char *root = NULL;
GOptionContext *opt_ctx;
GError *error = NULL;
const char *file;
GOptionEntry options[] = {
{ "parse-only", 0, 0, G_OPTION_ARG_NONE, &parse_only, "do not show widgets", NULL },
{ "root", 0, 0, G_OPTION_ARG_STRING, &root, "root widget to show", "ROOT" },
{ NULL, 0, 0, 0, NULL, NULL, NULL },
};
opt_ctx = g_option_context_new ("FILE - test glade parser");
g_option_context_add_main_entries (opt_ctx, options, NULL);
g_option_context_add_group (opt_ctx, gtk_get_option_group (FALSE));
if (!g_option_context_parse (opt_ctx, &argc, &argv, &error))
{
g_print ("could not parse '%s'\n", file);
g_print ("%s\n", error->message);
exit (1);
}
gtk_init_check (NULL, NULL);
if (argc != 2)
{
g_print ("usage: %s [OPTIONS] FILE\n", argv[0]);
exit (1);
}
file = argv[1];
xml = moo_glade_xml_new (file, root, NULL, &error);
if (!xml)
{
g_print ("could not parse file '%s': %s\n", file, error->message);
exit (1);
}
g_print ("*** Success ***\n");
if (!check)
{
root = moo_glade_xml_get_root (my_xml);
if (!parse_only)
show_it (xml, root);
if (GTK_IS_WINDOW (root))
{
gtk_widget_show (root);
gtk_main ();
}
}
g_object_unref (my_xml);
g_object_unref (xml);
return 0;
}

View File

@ -20,14 +20,16 @@
#include <readline/history.h>
static void usage (const char *prg)
static void
usage (const char *prg)
{
g_print ("usage:\t%s <file>\n\t%s -c <script>\n", prg, prg);
exit (1);
}
static int run_interactive (void)
static int
run_interactive (void)
{
MSContext *ctx;

View File

@ -14,11 +14,11 @@ int main (int argc, char *argv[])
G_CALLBACK (gtk_main_quit), NULL);
gtk_window_set_default_size (GTK_WINDOW (window), -1, 500);
tree = _moo_file_view_new ();
tree = g_object_new (MOO_TYPE_FILE_VIEW, NULL);
gtk_container_add (GTK_CONTAINER (window), tree);
_moo_file_view_chdir (MOO_FILE_VIEW (tree),
g_get_home_dir (), NULL);;
moo_file_view_chdir (MOO_FILE_VIEW (tree),
g_get_home_dir (), NULL);;
gtk_widget_show_all (window);

View File

@ -19,27 +19,27 @@ int main (int argc, char *argv[])
memset (text, '\n', 999);
gtk_text_buffer_set_text (GTK_TEXT_BUFFER (buffer), text, -1);
tree = moo_fold_tree_new (buffer);
tree = _moo_fold_tree_new (buffer);
f1 = moo_fold_tree_add (tree, 0, 2);
f1 = _moo_fold_tree_add (tree, 0, 2);
g_assert (f1 != NULL);
g_assert (!moo_fold_tree_add (tree, 0, 3));
g_assert (!moo_fold_tree_add (tree, 2, 3));
g_assert (!moo_fold_tree_add (tree, 2, 3));
g_assert (!_moo_fold_tree_add (tree, 0, 3));
g_assert (!_moo_fold_tree_add (tree, 2, 3));
g_assert (!_moo_fold_tree_add (tree, 2, 3));
f2 = moo_fold_tree_add (tree, 1, 2);
f2 = _moo_fold_tree_add (tree, 1, 2);
g_assert (f2 != NULL);
f3 = moo_fold_tree_add (tree, 10, 20);
f3 = _moo_fold_tree_add (tree, 10, 20);
g_assert (f3 != NULL);
g_assert (!moo_fold_tree_add (tree, 0, 15));
g_assert (!moo_fold_tree_add (tree, 3, 15));
g_assert (!_moo_fold_tree_add (tree, 0, 15));
g_assert (!_moo_fold_tree_add (tree, 3, 15));
moo_fold_tree_remove (tree, f1);
moo_fold_tree_remove (tree, f2);
moo_fold_tree_remove (tree, f3);
_moo_fold_tree_remove (tree, f1);
_moo_fold_tree_remove (tree, f2);
_moo_fold_tree_remove (tree, f3);
return 0;
}

View File

@ -52,17 +52,17 @@ test_closure (void)
gpointer object;
object = gtk_text_buffer_new (NULL);
cl = moo_closure_new_simple (object, NULL,
G_CALLBACK (do_something),
NULL);
cl = _moo_closure_new_simple (object, NULL,
G_CALLBACK (do_something),
NULL);
moo_closure_invoke (cl);
moo_closure_invoke (cl);
moo_closure_unref (cl);
object = gtk_text_buffer_new (NULL);
cl = moo_closure_new_simple (object, NULL,
G_CALLBACK (do_something2),
NULL);
cl = _moo_closure_new_simple (object, NULL,
G_CALLBACK (do_something2),
NULL);
moo_closure_invoke (cl);
g_object_unref (object);
moo_closure_invoke (cl);
@ -85,11 +85,11 @@ test_ptr (void)
static gboolean really_died = FALSE;
object = gtk_text_buffer_new (NULL);
ptr = moo_object_ptr_new (object, (GWeakNotify) object_died, &really_died);
ptr = _moo_object_ptr_new (object, (GWeakNotify) object_died, &really_died);
g_object_unref (object);
if (!really_died)
g_error ("oops");
moo_object_ptr_free (ptr);
_moo_object_ptr_free (ptr);
}

View File

@ -21,7 +21,7 @@ static void add_panes (GtkWidget *paned, MooPanePosition pane_position)
label = moo_pane_label_new (GTK_STOCK_CANCEL, NULL, NULL, "File Selector", "File Selector");
moo_big_paned_insert_pane (MOO_BIG_PANED (paned),
_moo_file_view_new (),
g_object_new (MOO_TYPE_FILE_VIEW, NULL),
label, pane_position, -1);
moo_pane_label_free (label);
}

View File

@ -53,9 +53,9 @@ static void create_window_with_paned (GtkPositionType pane_position)
"Click a button. Click a button. Click a button. Click a button. ",
-1);
fileview = _moo_file_view_new ();
_moo_file_view_chdir (MOO_FILE_VIEW (fileview),
g_get_home_dir (), NULL);
fileview = g_object_new (MOO_TYPE_FILE_VIEW, NULL);
moo_file_view_chdir (MOO_FILE_VIEW (fileview),
g_get_home_dir (), NULL);
label = moo_pane_label_new (GTK_STOCK_DIRECTORY, NULL, NULL,
"File selector", "File selector");

View File

@ -24,9 +24,21 @@ callback (void)
static gpointer
thread_main (gpointer data)
{
guint i;
/* g_print may not be used here */
printf ("thread %d: starting\n", GPOINTER_TO_UINT (data));
_moo_message_async ("thread %d: hi there");
for (i = 0; i < 10; ++i)
{
_moo_message_async ("thread %d: hi there #%d", GPOINTER_TO_UINT (data), i);
g_usleep (g_random_int_range (10, 100) * 1000);
gdk_threads_enter ();
_moo_message ("thread %d: hi there #%d again", GPOINTER_TO_UINT (data), i);
gdk_threads_leave ();
g_usleep (g_random_int_range (10, 100) * 1000);
}
printf ("thread %d: exiting\n", GPOINTER_TO_UINT (data));
return NULL;
}