summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPadraig O'Briain <padraigo@src.gnome.org>2001-05-09 13:12:12 +0000
committerPadraig O'Briain <padraigo@src.gnome.org>2001-05-09 13:12:12 +0000
commit70f373359027afced7afda327825507745338dc2 (patch)
tree981249a872810418ec7db066bccbba7b8c85aae8
parentc9fd6332ccc41e99a6b89f077954d28c0a28808e (diff)
downloadatk-70f373359027afced7afda327825507745338dc2.tar.gz
Update configure.in to create Makefile in tests directory.
CReate tests directory and add test module teststateset.c
-rw-r--r--Makefile.am2
-rw-r--r--configure.in3
-rw-r--r--tests/Makefile.am13
-rw-r--r--tests/README7
-rw-r--r--tests/teststateset.c222
5 files changed, 245 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index ae92ff3..4da774f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
# Process this file with automake to create Makefile.in.
-SUBDIRS=atk
+SUBDIRS=atk tests
EXTRA_DIST = \
atk.pc.in
diff --git a/configure.in b/configure.in
index bbe2266..4b3474d 100644
--- a/configure.in
+++ b/configure.in
@@ -76,6 +76,7 @@ AC_CHECK_LIB(pango, pango_context_new, :, AC_MSG_ERROR([
AC_OUTPUT([
Makefile
-atk/Makefile
atk.pc
+atk/Makefile
+tests/Makefile
])
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..6e6767d
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,13 @@
+
+lib_LTLIBRARIES = libteststateset.la
+
+libatk = $(top_builddir)/atk/libatk.la
+
+INCLUDES = -I$(top_srcdir) \
+ @DEP_CFLAGS@
+DEPS = \
+ $(libatk)
+
+libteststateset_la_SOURCES = teststateset.c
+libteststateset_la_LDFLAGS = -avoid-version \
+ -module
diff --git a/tests/README b/tests/README
new file mode 100644
index 0000000..b3973c0
--- /dev/null
+++ b/tests/README
@@ -0,0 +1,7 @@
+The tests in this directory are grouped into shared libraries, each of
+which is a GTK_MODULE. That is, they are designed to be loaded into a running
+GTK program by specifying the GTK_MODULES environment variable.
+
+teststateset
+============
+This module tests the interfaces in atk/atkstatset.h
diff --git a/tests/teststateset.c b/tests/teststateset.c
new file mode 100644
index 0000000..3c5a674
--- /dev/null
+++ b/tests/teststateset.c
@@ -0,0 +1,222 @@
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <atk/atk.h>
+
+static gboolean test_state_set();
+
+static gboolean
+test_state_set()
+{
+ AtkStateSet *state_set1, *state_set2, *state_set3;
+ AtkStateType state_array[3];
+ gboolean b_val;
+
+ state_set1 = atk_state_set_new();
+
+ b_val = atk_state_set_is_empty (state_set1);
+ if (b_val)
+ {
+ g_print ("New state set is not empty\n");
+ return FALSE;
+ }
+
+ b_val = atk_state_set_add_state (state_set1, ATK_STATE_ACTIVE);
+ if (!b_val)
+ {
+ g_print ("Adding new state set failed\n");
+ return FALSE;
+ }
+
+ b_val = atk_state_set_is_empty (state_set1);
+ if (!b_val)
+ {
+ g_print ("New state set is empty when it should not be\n");
+ return FALSE;
+ }
+
+ b_val = atk_state_set_add_state (state_set1, ATK_STATE_ACTIVE);
+ if (b_val)
+ {
+ g_print ("Adding new state set succeeded when it should not have\n");
+ return FALSE;
+ }
+
+ state_array[0] = ATK_STATE_ACTIVE;
+ state_array[1] = ATK_STATE_VISIBLE;
+ state_array[2] = ATK_STATE_BUSY;
+ atk_state_set_add_states (state_set1, state_array, 3);
+
+ b_val = atk_state_set_contains_state (state_set1, ATK_STATE_ACTIVE);
+ if (!b_val)
+ {
+ g_print ("Contains state failed for ATK_STATE_ACTIVE but should not have\n");
+ return FALSE;
+ }
+
+ b_val = atk_state_set_contains_state (state_set1, ATK_STATE_VISIBLE);
+ if (!b_val)
+ {
+ g_print ("Contains state failed for ATK_STATE_VISIBLE but should not have\n");
+ return FALSE;
+ }
+
+ b_val = atk_state_set_contains_state (state_set1, ATK_STATE_BUSY);
+ if (!b_val)
+ {
+ g_print ("Contains state failed for ATK_STATE_BUSY but should not have\n");
+ return FALSE;
+ }
+
+ b_val = atk_state_set_contains_state (state_set1, ATK_STATE_VERTICAL);
+ if (b_val)
+ {
+ g_print ("Contains state succeeded for ATK_STATE_VERTICAL but should not have\n");
+ return FALSE;
+ }
+
+ atk_state_set_remove_state (state_set1, ATK_STATE_BUSY);
+ b_val = atk_state_set_contains_state (state_set1, ATK_STATE_BUSY);
+ if (b_val)
+ {
+ g_print ("Contains state succeeded for ATK_STATE_BUSY but should not have\n");
+ return FALSE;
+ }
+ b_val = atk_state_set_contains_state (state_set1, ATK_STATE_VISIBLE);
+ if (!b_val)
+ {
+ g_print ("Contains state failed for ATK_STATE_VISIBLE but should not have\n");
+ return FALSE;
+ }
+
+ b_val = atk_state_set_contains_states (state_set1, state_array, 3);
+ if (b_val)
+ {
+ g_print ("Contains states succeeded should not have\n");
+ return FALSE;
+ }
+
+ b_val = atk_state_set_contains_states (state_set1, state_array, 2);
+ if (!b_val)
+ {
+ g_print ("Contains states failed should not have\n");
+ return FALSE;
+ }
+
+ state_array[0] = ATK_STATE_SINGLE_LINE;
+ state_array[1] = ATK_STATE_VISIBLE;
+ state_array[2] = ATK_STATE_VERTICAL;
+
+ state_set2 = atk_state_set_new();
+ atk_state_set_add_states (state_set2, state_array, 3);
+
+ state_set3 = atk_state_set_and_sets (state_set1, state_set2);
+ b_val = atk_state_set_contains_state (state_set3, ATK_STATE_VISIBLE);
+ if (!b_val)
+ {
+ g_print ("Contains state failed for ATK_STATE_VISIBLE after and but should not have\n");
+ return FALSE;
+ }
+ b_val = atk_state_set_contains_state (state_set3, ATK_STATE_BUSY);
+ if (b_val)
+ {
+ g_print ("Contains state succeeded for ATK_STATE_BUSY after and but should not have\n");
+ return FALSE;
+ }
+ g_object_unref (state_set3);
+
+ atk_state_set_remove_state (state_set1, ATK_STATE_VISIBLE);
+ state_set3 = atk_state_set_and_sets (state_set1, state_set2);
+ if (state_set3)
+ {
+ g_print ("state_set 3 is not NULL after and but should be\n");
+ return FALSE;
+ }
+
+ state_set3 = atk_state_set_or_sets (state_set1, state_set2);
+ b_val = atk_state_set_contains_state (state_set3, ATK_STATE_VISIBLE);
+ if (!b_val)
+ {
+ g_print ("Contains state failed for ATK_STATE_VISIBLE after or but should not have\n");
+ return FALSE;
+ }
+
+ b_val = atk_state_set_contains_state (state_set3, ATK_STATE_INVALID);
+ if (b_val)
+ {
+ g_print ("Contains state succeeded for ATK_STATE_INVALID after or but should not have\n");
+ return FALSE;
+ }
+ g_object_unref (state_set3);
+
+ b_val = atk_state_set_add_state (state_set1, ATK_STATE_VISIBLE);
+ if (!b_val)
+ {
+ g_print ("Adding new state set failed\n");
+ return FALSE;
+ }
+ state_set3 = atk_state_set_xor_sets (state_set1, state_set2);
+ b_val = atk_state_set_contains_state (state_set3, ATK_STATE_VISIBLE);
+ if (b_val)
+ {
+ g_print ("Contains state succeeded for ATK_STATE_VISIBLE after xor but should not have\n");
+ return FALSE;
+ }
+
+ b_val = atk_state_set_contains_state (state_set3, ATK_STATE_ACTIVE);
+ if (!b_val)
+ {
+ g_print ("Contains state failed for ATK_STATE_ACTIVE after xor but should not have\n");
+ return FALSE;
+ }
+
+ atk_state_set_clear_states (state_set1);
+ b_val = atk_state_set_contains_state (state_set1, ATK_STATE_ACTIVE);
+ if (b_val)
+ {
+ g_print ("Contains state succeeded for ATK_STATE_ACTIVE but should not have\n");
+ return FALSE;
+ }
+
+ g_object_unref (state_set1);
+ g_object_unref (state_set2);
+ g_object_unref (state_set3);
+ return TRUE;
+
+}
+
+int
+gtk_module_init(gint argc, char* argv[])
+{
+ gboolean b_ret;
+
+ g_print("State Set test module loaded\n");
+
+ b_ret = test_state_set();
+
+ if (b_ret)
+ {
+ g_print ("State Set tests succeeded\n");
+ }
+ else
+ {
+ g_print ("State Set tests failed\n");
+ }
+ return 0;
+}