Initial commit.

This commit is contained in:
Daiki Ueno
2010-06-04 12:09:08 +09:00
commit 9b452c0ffa
58 changed files with 8953 additions and 0 deletions

28
tests/Makefile.am Normal file
View File

@ -0,0 +1,28 @@
# Copyright (C) 2010 Daiki Ueno <ueno@unixuser.org>
# Copyright (C) 2010 Red Hat, Inc.
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA
INCLUDES = -I$(top_srcdir) $(GOBJECT2_CFLAGS) $(SIMPLE_CFLAGS) $(XKB_CFLAGS)
TESTS = eek-simple-test eek-xkb-test
noinst_PROGRAMS = $(TESTS)
eek_simple_test_SOURCES = eek-simple-test.c
eek_simple_test_LDADD = $(top_builddir)/eek/libeek.la
eek_xkb_test_SOURCES = eek-xkb-test.c
eek_xkb_test_LDADD = $(top_builddir)/eek/libeek.la $(top_builddir)/eek/libeek-xkb.la

97
tests/eek-simple-test.c Normal file
View File

@ -0,0 +1,97 @@
/*
* Copyright (C) 2010 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#include "eek-simple-keyboard.h"
static void
test_create (void)
{
EekKeyboard *keyboard;
EekSection *section;
EekKey *key;
EekOutline outline = {45.0, NULL, 0};
EekBounds bounds = {0.1, 0.2, 3.0, 4.0};
EekKeysymMatrix *matrix;
GValue value = {0};
gint iv;
const gchar *sv;
gpointer bv;
guint keysyms[] = {'a', 'b', 'c', 'd', 'e', 'f'};
keyboard = eek_simple_keyboard_new ();
g_assert (keyboard);
g_assert (g_object_is_floating (keyboard));
section = eek_keyboard_create_section (keyboard,
"test-section",
45,
&bounds);
g_assert (section);
g_value_init (&value, G_TYPE_STRING);
g_object_get_property (G_OBJECT(section), "name", &value);
sv = g_value_get_string (&value);
g_assert_cmpstr (sv, ==, "test-section");
g_value_unset (&value);
g_value_init (&value, G_TYPE_INT);
g_object_get_property (G_OBJECT(section), "angle", &value);
iv = g_value_get_int (&value);
g_assert_cmpint (iv, ==, 45);
g_value_unset (&value);
g_value_init (&value, EEK_TYPE_BOUNDS);
g_object_get_property (G_OBJECT(section), "bounds", &value);
bv = g_value_get_boxed (&value);
g_assert (bv);
g_assert_cmpfloat (((EekBounds *)bv)->x, ==, 0.1);
g_value_unset (&value);
key = eek_section_create_key (section,
"test-key",
keysyms,
3,
2,
1,
2,
&outline,
&bounds);
g_assert (key);
g_value_init (&value, EEK_TYPE_KEYSYM_MATRIX);
g_object_get_property (G_OBJECT(key), "keysyms", &value);
matrix = g_value_get_boxed (&value);
g_assert_cmpint (matrix->data[0], ==, 'a');
g_value_unset (&value);
g_value_init (&value, G_TYPE_POINTER);
g_object_get_property (G_OBJECT(key), "outline", &value);
bv = g_value_get_pointer (&value);
g_assert (bv == &outline);
g_value_unset (&value);
g_object_unref (keyboard);
}
int
main (int argc, char **argv)
{
g_type_init ();
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/eek-simple-test/create", test_create);
return g_test_run ();
}

50
tests/eek-xkb-test.c Normal file
View File

@ -0,0 +1,50 @@
/*
* Copyright (C) 2010 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#include "eek-xkb.h"
static void
test_create (void)
{
EekLayout *layout;
const gchar *keycodes, *geometry, *symbols;
layout = eek_xkb_layout_new (NULL, "winbook", NULL);
g_assert (layout);
keycodes = eek_xkb_layout_get_keycodes (EEK_XKB_LAYOUT(layout));
g_assert (keycodes);
geometry = eek_xkb_layout_get_geometry (EEK_XKB_LAYOUT(layout));
g_assert (geometry);
symbols = eek_xkb_layout_get_symbols (EEK_XKB_LAYOUT(layout));
g_assert (symbols);
eek_xkb_layout_set_geometry (EEK_XKB_LAYOUT(layout), "winbook");
geometry = eek_xkb_layout_get_geometry (EEK_XKB_LAYOUT(layout));
g_assert_cmpstr (geometry, ==, "winbook");
g_object_unref (layout);
}
int
main (int argc, char **argv)
{
g_type_init ();
g_test_init (&argc, &argv, NULL);
gtk_init (&argc, &argv);
g_test_add_func ("/eek-xkb-test/create", test_create);
return g_test_run ();
}