Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

object-store: Add more tests

The filter test does not pass yet.
  • Loading branch information...
commit d42a44938699ee30a998fc42bc149aebf69389db 1 parent adcfc7e
Rob Staudinger authored
View
24 object-store/Makefile
@@ -1,7 +1,18 @@
-PROGRAM = object-store-test
+PROGRAMS = \
+ object-store-example \
+ object-store-test \
+ $(NULL)
-SOURCES = \
+example_SOURCES = \
+ foo-object-store.c \
+ foo-object-store.h \
+ foo-test-object.c \
+ foo-test-object.h \
+ object-store-example.c \
+ $(NULL)
+
+test_SOURCES = \
foo-object-store.c \
foo-object-store.h \
foo-test-object.c \
@@ -11,12 +22,15 @@ SOURCES = \
PKGFLAGS = `pkg-config --cflags --libs clutter-1.0 mx-1.0`
-all: $(PROGRAM)
+all: $(PROGRAMS)
clean:
- rm -f $(PROGRAM)
+ rm -f $(PROGRAMS)
+
+object-store-example: $(example_SOURCES)
+ $(CC) $(CPPLAGS) $(CFLAGS) $(PKGFLAGS) -o $@ $^
-$(PROGRAM): $(SOURCES)
+object-store-test: $(test_SOURCES)
$(CC) $(CPPLAGS) $(CFLAGS) $(PKGFLAGS) -o $@ $^
.PHONY: clean
View
43 object-store/foo-test-object.c
@@ -27,11 +27,13 @@ G_DEFINE_TYPE (FooTestObject, foo_test_object, G_TYPE_OBJECT)
enum
{
PROP_0,
+ PROP_NUMBER,
PROP_TEXT
};
typedef struct
{
+ int number;
char *text;
} FooTestObjectPrivate;
@@ -43,6 +45,11 @@ _get_property (GObject *object,
{
switch (property_id)
{
+ case PROP_NUMBER:
+ g_value_set_int (value,
+ foo_test_object_get_number (
+ FOO_TEST_OBJECT (object)));
+ break;
case PROP_TEXT:
g_value_set_string (value,
foo_test_object_get_text (
@@ -61,6 +68,10 @@ _set_property (GObject *object,
{
switch (property_id)
{
+ case PROP_NUMBER:
+ foo_test_object_set_number (FOO_TEST_OBJECT (object),
+ g_value_get_int (value));
+ break;
case PROP_TEXT:
foo_test_object_set_text (FOO_TEST_OBJECT (object),
g_value_get_string (value));
@@ -88,6 +99,12 @@ foo_test_object_class_init (FooTestObjectClass *klass)
object_class->finalize = _finalize;
g_object_class_install_property (object_class,
+ PROP_NUMBER,
+ g_param_spec_int ("number", "", "",
+ G_MININT32, G_MAXINT32, 0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
PROP_TEXT,
g_param_spec_string ("text", "", "",
NULL,
@@ -105,6 +122,32 @@ foo_test_object_new (void)
return g_object_new (FOO_TYPE_TEST_OBJECT, NULL);
}
+int
+foo_test_object_get_number (FooTestObject *self)
+{
+ FooTestObjectPrivate *priv = GET_PRIVATE (self);
+
+ g_return_val_if_fail (FOO_IS_TEST_OBJECT (self), 0);
+
+ return priv->number;
+}
+
+void
+foo_test_object_set_number (FooTestObject *self,
+ int number)
+{
+ FooTestObjectPrivate *priv = GET_PRIVATE (self);
+
+ g_return_if_fail (FOO_IS_TEST_OBJECT (self));
+
+ if (number != priv->number)
+ {
+ priv->number = number;
+
+ g_object_notify (G_OBJECT (self), "number");
+ }
+}
+
char const *
foo_test_object_get_text (FooTestObject *self)
{
View
7 object-store/foo-test-object.h
@@ -57,6 +57,13 @@ foo_test_object_get_type (void);
FooTestObject *
foo_test_object_new (void);
+int
+foo_test_object_get_number (FooTestObject *self);
+
+void
+foo_test_object_set_number (FooTestObject *self,
+ int number);
+
char const *
foo_test_object_get_text (FooTestObject *self);
View
230 object-store/object-store-example.c
@@ -0,0 +1,230 @@
+/*
+ * Copyright (c) 2010, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Author: Rob Staudinger <robsta@linux.intel.com>
+ */
+
+#include <stdbool.h>
+#include <stdlib.h>
+#include <mx/mx.h>
+#include "foo-object-store.h"
+#include "foo-test-object.h"
+
+typedef struct
+{
+ ClutterActor *view;
+ MxEntry *entry;
+ ClutterModel *store;
+} ObjectStoreTest;
+
+/*
+ * Look up item by index.
+ * Returned object needs to be g_object_unref'd.
+ * May return NULL.
+ */
+FooTestObject *
+store_get_object (ClutterModel *store,
+ unsigned index)
+{
+ ClutterModelIter *iter;
+ FooTestObject *object = NULL;
+
+ iter = clutter_model_get_iter_at_row (store, index);
+ if (iter &&
+ !clutter_model_iter_is_last (iter))
+ {
+ /* Column #0 of the model holds the actual object. */
+ clutter_model_iter_get (iter,
+ 0, &object,
+ -1);
+ }
+
+ return object;
+}
+
+/*
+ * Add object to the store.
+ */
+static void
+store_add_object (ClutterModel *store,
+ char const *text)
+{
+ FooTestObject *object;
+
+ object = foo_test_object_new ();
+ foo_test_object_set_text (object, text);
+
+ /* Column #0 holds the actual object, the other cols are mapped to
+ * its properties. */
+ clutter_model_append (store, 0, object, -1);
+ g_object_unref (object);
+}
+
+static void
+_update_clicked (MxButton *button,
+ ObjectStoreTest *app)
+{
+ char const *input;
+
+ input = mx_entry_get_text (app->entry);
+ if (input == NULL ||
+ input[0] == '\0')
+ {
+ g_warning ("Please enter text");
+ return;
+
+ } else if (input[0] == '-') {
+
+ /* Remove item */
+ int index = g_ascii_isdigit (input[1]) ?
+ atoi (&input[1]) :
+ -1;
+ if (index < 0)
+ {
+ g_warning ("Invalid number, can not remove");
+ return;
+ }
+
+ clutter_model_remove (app->store, index);
+
+ } else if (g_ascii_isdigit (input[0])) {
+
+ /* Update item */
+ unsigned index = atoi (input);
+ char **tokens = g_strsplit (input, ":", 2);
+ char const *text = tokens[1];
+ FooTestObject *object = store_get_object (app->store, index);
+
+ if (object == NULL)
+ {
+ g_warning ("Failed to find object");
+ return;
+ }
+
+ foo_test_object_set_text (FOO_TEST_OBJECT (object), text);
+ g_object_unref (object);
+
+ } else {
+
+ /* Add item */
+ store_add_object (app->store, input);
+ }
+
+ mx_entry_set_text (app->entry, "");
+}
+
+static void
+_dump_clicked (MxButton *button,
+ ObjectStoreTest *app)
+{
+ ClutterModelIter *iter;
+
+ for (iter = clutter_model_get_first_iter (app->store);
+ !clutter_model_iter_is_last (iter);
+ iter = clutter_model_iter_next (iter))
+ {
+ FooTestObject *object = NULL;
+ char *text = NULL;
+
+ clutter_model_iter_get (iter,
+ 0, &object,
+ 1, &text,
+ -1);
+ g_debug ("%p %s\n", object, text);
+ g_object_unref (object);
+ g_free (text);
+ }
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ ClutterActor *stage;
+ MxBoxLayout *vbox;
+ MxBoxLayout *hbox;
+ ClutterActor *button;
+ ClutterActor *label;
+ ObjectStoreTest app = { 0, };
+
+ clutter_init (&argc, &argv);
+
+ stage = clutter_stage_get_default ();
+ clutter_actor_set_size (stage, 320.0, 240.0);
+
+ vbox = (MxBoxLayout *) mx_box_layout_new ();
+ clutter_actor_set_size (CLUTTER_ACTOR (vbox), 320.0, 240.0);
+ mx_box_layout_set_orientation (vbox, MX_ORIENTATION_VERTICAL);
+ clutter_container_add_actor (CLUTTER_CONTAINER (stage), CLUTTER_ACTOR (vbox));
+
+ /* Create model */
+ app.store = foo_object_store_new (2,
+ FOO_TYPE_TEST_OBJECT, "foo", /* column #0 */
+ G_TYPE_STRING, "text"); /* column #1 */
+
+ /*
+ * Create view
+ */
+ app.view = mx_list_view_new ();
+
+ /* Use MxButton to render the model's items */
+ mx_list_view_set_item_type (MX_LIST_VIEW (app.view), MX_TYPE_BUTTON);
+
+ /* Map column #1 to attribute "label" of view's GtkButton */
+ mx_list_view_add_attribute (MX_LIST_VIEW (app.view), "label", 1);
+
+ /* Connect to model */
+ mx_list_view_set_model (MX_LIST_VIEW (app.view), app.store);
+
+ mx_box_layout_add_actor_with_properties (vbox, app.view, -1,
+ "expand", true,
+ "x-fill", true,
+ "y-fill", true,
+ NULL);
+
+ hbox = (MxBoxLayout *) mx_box_layout_new ();
+ mx_box_layout_set_orientation (hbox, MX_ORIENTATION_HORIZONTAL);
+ mx_box_layout_add_actor_with_properties (vbox, CLUTTER_ACTOR (hbox), -1,
+ "expand", false,
+ "x-fill", true,
+ NULL);
+
+ app.entry = (MxEntry *) mx_entry_new ();
+ mx_box_layout_add_actor_with_properties (hbox, CLUTTER_ACTOR (app.entry), -1,
+ "expand", true,
+ "x-fill", true,
+ NULL);
+
+ button = mx_button_new_with_label ("Update");
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (_update_clicked), &app);
+ clutter_container_add_actor (CLUTTER_CONTAINER (hbox), button);
+
+ button = mx_button_new_with_label ("Dump");
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (_dump_clicked), &app);
+ clutter_container_add_actor (CLUTTER_CONTAINER (hbox), button);
+
+ label = mx_label_new_with_text ("Enter text and update to add item\n"
+ "Enter <number>:<text> to change item <number>\n"
+ "Enter -<number> to delete item <number>");
+ clutter_container_add_actor (CLUTTER_CONTAINER (vbox), label);
+
+ clutter_actor_show_all (stage);
+ clutter_main ();
+
+ return EXIT_SUCCESS;
+}
View
BIN  object-store/object-store-test
Binary file not shown
View
506 object-store/object-store-test.c
@@ -1,230 +1,364 @@
-/*
- * Copyright (c) 2010, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Author: Rob Staudinger <robsta@linux.intel.com>
- */
-
-#include <stdbool.h>
#include <stdlib.h>
-#include <mx/mx.h>
+#include <string.h>
+#include <clutter/clutter.h>
#include "foo-object-store.h"
#include "foo-test-object.h"
-typedef struct
+typedef struct _ModelData
{
- ClutterActor *view;
- MxEntry *entry;
- ClutterModel *store;
-} ObjectStoreTest;
-
-/*
- * Look up item by index.
- * Returned object needs to be g_object_unref'd.
- * May return NULL.
- */
-FooTestObject *
-store_get_object (ClutterModel *store,
- unsigned index)
-{
- ClutterModelIter *iter;
- FooTestObject *object = NULL;
-
- iter = clutter_model_get_iter_at_row (store, index);
- if (iter &&
- !clutter_model_iter_is_last (iter))
- {
- /* Column #0 of the model holds the actual object. */
- clutter_model_iter_get (iter,
- 0, &object,
- -1);
- }
+ ClutterModel *model;
- return object;
+ guint n_row;
+} ModelData;
+
+enum
+{
+ COLUMN_OBJECT, /* FOO_TYPE_OBJECT_STORE */
+ COLUMN_NUMBER, /* G_TYPE_INT */
+ COLUMN_TEXT, /* G_TYPE_STRING */
+
+ N_COLUMNS
+};
+
+static const struct {
+ const gchar *expected_foo;
+ gint expected_bar;
+} base_model[] = {
+ { "String 1", 1 },
+ { "String 2", 2 },
+ { "String 3", 3 },
+ { "String 4", 4 },
+ { "String 5", 5 },
+ { "String 6", 6 },
+ { "String 7", 7 },
+ { "String 8", 8 },
+ { "String 9", 9 },
+};
+
+static const struct {
+ const gchar *expected_foo;
+ gint expected_bar;
+} forward_base[] = {
+ { "String 1", 1 },
+ { "String 2", 2 },
+ { "String 3", 3 },
+ { "String 4", 4 },
+ { "String 5", 5 },
+ { "String 6", 6 },
+ { "String 7", 7 },
+ { "String 8", 8 },
+ { "String 9", 9 },
+};
+
+static const struct {
+ const gchar *expected_foo;
+ gint expected_bar;
+} backward_base[] = {
+ { "String 9", 9 },
+ { "String 8", 8 },
+ { "String 7", 7 },
+ { "String 6", 6 },
+ { "String 5", 5 },
+ { "String 4", 4 },
+ { "String 3", 3 },
+ { "String 2", 2 },
+ { "String 1", 1 },
+};
+
+static const struct {
+ const gchar *expected_foo;
+ gint expected_bar;
+} filter_odd[] = {
+ { "String 1", 1 },
+ { "String 3", 3 },
+ { "String 5", 5 },
+ { "String 7", 7 },
+ { "String 9", 9 },
+};
+
+static const struct {
+ const gchar *expected_foo;
+ gint expected_bar;
+} filter_even[] = {
+ { "String 8", 8 },
+ { "String 6", 6 },
+ { "String 4", 4 },
+ { "String 2", 2 },
+};
+
+static inline void
+compare_iter (ClutterModelIter *iter,
+ const gint expected_row,
+ const gchar *expected_foo,
+ const gint expected_bar)
+{
+ gchar *foo = NULL;
+ gint bar = 0;
+ gint row = 0;
+
+ row = clutter_model_iter_get_row (iter);
+ clutter_model_iter_get (iter,
+ COLUMN_TEXT, &foo,
+ COLUMN_NUMBER, &bar,
+ -1);
+
+ if (g_test_verbose ())
+ g_print ("Row %d => %d: Got [ '%s', '%d' ], expected [ '%s', '%d' ]\n",
+ row, expected_row,
+ foo, bar,
+ expected_foo, expected_bar);
+
+ g_assert_cmpint (row, ==, expected_row);
+ g_assert_cmpstr (foo, ==, expected_foo);
+ g_assert_cmpint (bar, ==, expected_bar);
+
+ g_free (foo);
}
-/*
- * Add object to the store.
- */
static void
-store_add_object (ClutterModel *store,
- char const *text)
+on_row_added (ClutterModel *model,
+ ClutterModelIter *iter,
+ gpointer data)
{
- FooTestObject *object;
+ ModelData *model_data = data;
- object = foo_test_object_new ();
- foo_test_object_set_text (object, text);
+ compare_iter (iter,
+ model_data->n_row,
+ base_model[model_data->n_row].expected_foo,
+ base_model[model_data->n_row].expected_bar);
- /* Column #0 holds the actual object, the other cols are mapped to
- * its properties. */
- clutter_model_append (store, 0, object, -1);
- g_object_unref (object);
+ model_data->n_row += 1;
}
-static void
-_update_clicked (MxButton *button,
- ObjectStoreTest *app)
+static gboolean
+filter_even_rows (ClutterModel *model,
+ ClutterModelIter *iter,
+ gpointer dummy G_GNUC_UNUSED)
+{
+ gint bar_value;
+
+ clutter_model_iter_get (iter, COLUMN_NUMBER, &bar_value, -1);
+
+ if (bar_value % 2 == 0)
+ return TRUE;
+
+ return FALSE;
+}
+
+static gboolean
+filter_odd_rows (ClutterModel *model,
+ ClutterModelIter *iter,
+ gpointer dummy G_GNUC_UNUSED)
+{
+ gint bar_value;
+
+ clutter_model_iter_get (iter, COLUMN_NUMBER, &bar_value, -1);
+
+ if (bar_value % 2 != 0)
+ return TRUE;
+
+ return FALSE;
+}
+
+void
+test_list_model_filter (void)
{
- char const *input;
-
- input = mx_entry_get_text (app->entry);
- if (input == NULL ||
- input[0] == '\0')
- {
- g_warning ("Please enter text");
- return;
-
- } else if (input[0] == '-') {
-
- /* Remove item */
- int index = g_ascii_isdigit (input[1]) ?
- atoi (&input[1]) :
- -1;
- if (index < 0)
+ ModelData test_data = { NULL, 0 };
+ ClutterModelIter *iter;
+ gint i;
+
+ test_data.model = foo_object_store_new (N_COLUMNS,
+ FOO_TYPE_TEST_OBJECT, "object",
+ G_TYPE_INT, "number",
+ G_TYPE_STRING, "text");
+ test_data.n_row = 0;
+
+ for (i = 1; i < 10; i++)
{
- g_warning ("Invalid number, can not remove");
- return;
+ gchar *foo = g_strdup_printf ("String %d", i);
+ GObject *object = g_object_new (FOO_TYPE_TEST_OBJECT,
+ "number", i,
+ "text", foo,
+ NULL);
+
+ clutter_model_append (test_data.model,
+ COLUMN_OBJECT, object,
+ -1);
+
+ g_object_unref (object);
+ g_free (foo);
}
- clutter_model_remove (app->store, index);
+ if (g_test_verbose ())
+ g_print ("Forward iteration (filter odd)...\n");
- } else if (g_ascii_isdigit (input[0])) {
+ clutter_model_set_filter (test_data.model, filter_odd_rows, NULL, NULL);
- /* Update item */
- unsigned index = atoi (input);
- char **tokens = g_strsplit (input, ":", 2);
- char const *text = tokens[1];
- FooTestObject *object = store_get_object (app->store, index);
+ iter = clutter_model_get_first_iter (test_data.model);
+ g_assert (iter != NULL);
- if (object == NULL)
+ i = 0;
+ while (!clutter_model_iter_is_last (iter))
{
- g_warning ("Failed to find object");
- return;
+ compare_iter (iter, i,
+ filter_odd[i].expected_foo,
+ filter_odd[i].expected_bar);
+
+ iter = clutter_model_iter_next (iter);
+ i += 1;
}
- foo_test_object_set_text (FOO_TEST_OBJECT (object), text);
- g_object_unref (object);
+ g_object_unref (iter);
- } else {
+ if (g_test_verbose ())
+ g_print ("Backward iteration (filter even)...\n");
- /* Add item */
- store_add_object (app->store, input);
- }
+ clutter_model_set_filter (test_data.model, filter_even_rows, NULL, NULL);
- mx_entry_set_text (app->entry, "");
+ iter = clutter_model_get_last_iter (test_data.model);
+ g_assert (iter != NULL);
+
+ i = 0;
+ do
+ {
+ compare_iter (iter, G_N_ELEMENTS (filter_even) - i - 1,
+ filter_even[i].expected_foo,
+ filter_even[i].expected_bar);
+
+ iter = clutter_model_iter_prev (iter);
+ i += 1;
+ }
+ while (!clutter_model_iter_is_first (iter));
+
+ g_object_unref (iter);
+
+ g_object_unref (test_data.model);
}
-static void
-_dump_clicked (MxButton *button,
- ObjectStoreTest *app)
+void
+test_list_model_iterate (void)
{
+ ModelData test_data = { NULL, 0 };
ClutterModelIter *iter;
+ gint i;
+
+ test_data.model = foo_object_store_new (N_COLUMNS,
+ FOO_TYPE_TEST_OBJECT, "object",
+ G_TYPE_INT, "number",
+ G_TYPE_STRING, "text");
+ test_data.n_row = 0;
- for (iter = clutter_model_get_first_iter (app->store);
- !clutter_model_iter_is_last (iter);
- iter = clutter_model_iter_next (iter))
- {
- FooTestObject *object = NULL;
- char *text = NULL;
+ g_signal_connect (test_data.model, "row-added",
+ G_CALLBACK (on_row_added),
+ &test_data);
- clutter_model_iter_get (iter,
- 0, &object,
- 1, &text,
+ for (i = 1; i < 10; i++)
+ {
+ gchar *foo = g_strdup_printf ("String %d", i);
+ GObject *object = g_object_new (FOO_TYPE_TEST_OBJECT,
+ "number", i,
+ "text", foo,
+ NULL);
+
+ clutter_model_append (test_data.model,
+ COLUMN_OBJECT, object,
+ -1);
+
+ g_object_unref (object);
+ g_free (foo);
+ }
+
+ if (g_test_verbose ())
+ g_print ("Forward iteration...\n");
+
+ iter = clutter_model_get_first_iter (test_data.model);
+ g_assert (iter != NULL);
+
+ i = 0;
+ while (!clutter_model_iter_is_last (iter))
+ {
+ compare_iter (iter, i,
+ forward_base[i].expected_foo,
+ forward_base[i].expected_bar);
+
+ iter = clutter_model_iter_next (iter);
+ i += 1;
+ }
+
+ g_object_unref (iter);
+
+ if (g_test_verbose ())
+ g_print ("Backward iteration...\n");
+
+ iter = clutter_model_get_last_iter (test_data.model);
+ g_assert (iter != NULL);
+
+ i = 0;
+ do
+ {
+ compare_iter (iter, G_N_ELEMENTS (backward_base) - i - 1,
+ backward_base[i].expected_foo,
+ backward_base[i].expected_bar);
+
+ iter = clutter_model_iter_prev (iter);
+ i += 1;
+ }
+ while (!clutter_model_iter_is_first (iter));
+
+ compare_iter (iter, G_N_ELEMENTS (backward_base) - i - 1,
+ backward_base[i].expected_foo,
+ backward_base[i].expected_bar);
+
+ g_object_unref (iter);
+
+ g_object_unref (test_data.model);
+}
+
+void
+test_list_model_populate (void)
+{
+ ModelData test_data = { NULL, 0 };
+ gint i;
+
+ test_data.model = foo_object_store_new (N_COLUMNS,
+ FOO_TYPE_TEST_OBJECT, "object",
+ G_TYPE_INT, "number",
+ G_TYPE_STRING, "text");
+ test_data.n_row = 0;
+
+ g_signal_connect (test_data.model, "row-added",
+ G_CALLBACK (on_row_added),
+ &test_data);
+
+ for (i = 1; i < 10; i++)
+ {
+ gchar *foo = g_strdup_printf ("String %d", i);
+ GObject *object = g_object_new (FOO_TYPE_TEST_OBJECT,
+ "number", i,
+ "text", foo,
+ NULL);
+
+ clutter_model_append (test_data.model,
+ COLUMN_OBJECT, object,
-1);
- g_debug ("%p %s\n", object, text);
- g_object_unref (object);
- g_free (text);
- }
+
+ g_object_unref (object);
+ g_free (foo);
+ }
+
+ g_object_unref (test_data.model);
}
int
main (int argc,
char **argv)
{
- ClutterActor *stage;
- MxBoxLayout *vbox;
- MxBoxLayout *hbox;
- ClutterActor *button;
- ClutterActor *label;
- ObjectStoreTest app = { 0, };
-
+
clutter_init (&argc, &argv);
- stage = clutter_stage_get_default ();
- clutter_actor_set_size (stage, 320.0, 240.0);
-
- vbox = (MxBoxLayout *) mx_box_layout_new ();
- clutter_actor_set_size (CLUTTER_ACTOR (vbox), 320.0, 240.0);
- mx_box_layout_set_orientation (vbox, MX_ORIENTATION_VERTICAL);
- clutter_container_add_actor (CLUTTER_CONTAINER (stage), CLUTTER_ACTOR (vbox));
-
- /* Create model */
- app.store = foo_object_store_new (2,
- FOO_TYPE_TEST_OBJECT, "foo", /* column #0 */
- G_TYPE_STRING, "text"); /* column #1 */
-
- /*
- * Create view
- */
- app.view = mx_list_view_new ();
-
- /* Use MxButton to render the model's items */
- mx_list_view_set_item_type (MX_LIST_VIEW (app.view), MX_TYPE_BUTTON);
-
- /* Map column #1 to attribute "label" of view's GtkButton */
- mx_list_view_add_attribute (MX_LIST_VIEW (app.view), "label", 1);
-
- /* Connect to model */
- mx_list_view_set_model (MX_LIST_VIEW (app.view), app.store);
-
- mx_box_layout_add_actor_with_properties (vbox, app.view, -1,
- "expand", true,
- "x-fill", true,
- "y-fill", true,
- NULL);
-
- hbox = (MxBoxLayout *) mx_box_layout_new ();
- mx_box_layout_set_orientation (hbox, MX_ORIENTATION_HORIZONTAL);
- mx_box_layout_add_actor_with_properties (vbox, CLUTTER_ACTOR (hbox), -1,
- "expand", false,
- "x-fill", true,
- NULL);
-
- app.entry = (MxEntry *) mx_entry_new ();
- mx_box_layout_add_actor_with_properties (hbox, CLUTTER_ACTOR (app.entry), -1,
- "expand", true,
- "x-fill", true,
- NULL);
-
- button = mx_button_new_with_label ("Update");
- g_signal_connect (button, "clicked",
- G_CALLBACK (_update_clicked), &app);
- clutter_container_add_actor (CLUTTER_CONTAINER (hbox), button);
-
- button = mx_button_new_with_label ("Dump");
- g_signal_connect (button, "clicked",
- G_CALLBACK (_dump_clicked), &app);
- clutter_container_add_actor (CLUTTER_CONTAINER (hbox), button);
-
- label = mx_label_new_with_text ("Enter text and update to add item\n"
- "Enter <number>:<text> to change item <number>\n"
- "Enter -<number> to delete item <number>");
- clutter_container_add_actor (CLUTTER_CONTAINER (vbox), label);
-
- clutter_actor_show_all (stage);
- clutter_main ();
+ test_list_model_populate ();
+ test_list_model_iterate ();
+ test_list_model_filter ();
return EXIT_SUCCESS;
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.