seed r830 - trunk/tests/c



Author: hortont
Date: Mon Feb  2 12:10:34 2009
New Revision: 830
URL: http://svn.gnome.org/viewvc/seed?rev=830&view=rev

Log:
Whoops forgot to add the test.


Added:
   trunk/tests/c/api-js-signal-from-c.c

Added: trunk/tests/c/api-js-signal-from-c.c
==============================================================================
--- (empty file)
+++ trunk/tests/c/api-js-signal-from-c.c	Mon Feb  2 12:10:34 2009
@@ -0,0 +1,43 @@
+#include "../../libseed/seed.h"
+#include "test-common.h"
+
+gfloat hello_cb(gint a, gchar * b)
+{
+	g_assert(a == 2);
+	g_assert(strncmp(b, "Test", 4) == 0);
+	
+	return 5.12;
+}
+
+void js_signal_from_c(TestSimpleFixture * fixture, gconstpointer _data)
+{
+	TestSharedState * state = (TestSharedState *)_data;
+	
+	SeedValue * val = seed_simple_evaluate(state->eng->context,
+"Seed.import_namespace(\"Gtk\");"
+"Gtk.init(null, null);"
+"HelloWindowType = {"
+"    parent: Gtk.Window.type,"
+"    name: \"HelloWindow\","
+"    class_init: function(klass, prototype)"
+"    {"
+"	var HelloSignalDefinition = {name: \"hello\","
+"								 parameters: [GObject.TYPE_INT,"
+"											  GObject.TYPE_STRING],"
+"								 return_type: GObject.TYPE_FLOAT};"
+"	hello_signal_id = klass.install_signal(HelloSignalDefinition);"
+"    },"
+"    init: function(instance)"
+"    {"
+"    }};"
+"HelloWindow = new GType(HelloWindowType);"
+"w = new HelloWindow();");
+
+	GObject * obj = seed_value_to_object(state->eng->context, val, NULL);
+	
+	g_signal_connect(obj, "hello", G_CALLBACK(hello_cb), NULL);
+
+	val = seed_simple_evaluate(state->eng->context, "g = w.signal.hello.emit(2,'Test')");
+	
+	g_assert(seed_value_to_float(state->eng->context, val, NULL) == 5.12);
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]