mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 06:21:14 +00:00
testsuite: Remove a bunch of broken tests
These tests have either been commented out for way too long or use APIs that we don't want to support.
This commit is contained in:
parent
24391634b5
commit
61db7da2ef
@ -44,7 +44,6 @@ TEST_PROGS += \
|
||||
cssprovider \
|
||||
defaultvalue \
|
||||
entry \
|
||||
expander \
|
||||
firefox-stylecontext \
|
||||
floating \
|
||||
focus \
|
||||
@ -79,16 +78,6 @@ if OS_UNIX
|
||||
#TEST_PROGS += defaultvalue
|
||||
endif
|
||||
|
||||
#TEST_PROGS += testing
|
||||
#TEST_PROGS += treeview-scrolling
|
||||
#TEST_PROGS += object
|
||||
#TEST_PROGS += filechooser
|
||||
|
||||
# this doesn't work in make distcheck, since running
|
||||
# on a naked X server creates slightly different event
|
||||
# sequences than running on a normal desktop
|
||||
# TEST_PROGS += crossingevents
|
||||
|
||||
treemodel_SOURCES = \
|
||||
treemodel.h \
|
||||
treemodel.c \
|
||||
|
@ -1,628 +0,0 @@
|
||||
/*
|
||||
* crossingevents.c: A test for crossing events
|
||||
*
|
||||
* Copyright (C) 2008 Cody Russell
|
||||
*
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct {
|
||||
GtkWidget *window;
|
||||
GtkWidget *eventbox;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *button;
|
||||
GtkWidget *check;
|
||||
gboolean events_connected;
|
||||
GQueue *queue;
|
||||
} CrossingTest;
|
||||
|
||||
typedef struct {
|
||||
gboolean entered;
|
||||
gchar *name;
|
||||
gboolean synthesized;
|
||||
GdkCrossingMode mode;
|
||||
GdkNotifyType detail;
|
||||
} CrossingEventData;
|
||||
|
||||
#define SLEEP_DURATION 100
|
||||
|
||||
void start_events (CrossingTest *test);
|
||||
void stop_events (CrossingTest *test);
|
||||
|
||||
static gboolean
|
||||
sleep_timeout_cb (gpointer data)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
sleep_in_main_loop (double fraction)
|
||||
{
|
||||
/* process all pending idles and events */
|
||||
while (g_main_context_pending (NULL))
|
||||
g_main_context_iteration (NULL, FALSE);
|
||||
/* sleeping probably isn't strictly necessary here */
|
||||
gdk_threads_add_timeout_full (G_MAXINT, fraction * SLEEP_DURATION, sleep_timeout_cb, NULL, NULL);
|
||||
gtk_main ();
|
||||
/* process any pending idles or events that arrived during sleep */
|
||||
while (g_main_context_pending (NULL))
|
||||
g_main_context_iteration (NULL, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
set_cursor (GtkWidget *widget)
|
||||
{
|
||||
int x, y, w, h;
|
||||
|
||||
gdk_window_get_origin (widget->window, &x, &y);
|
||||
|
||||
x += widget->allocation.x;
|
||||
y += widget->allocation.y;
|
||||
w = widget->allocation.width;
|
||||
h = widget->allocation.height;
|
||||
|
||||
gdk_display_warp_pointer (gtk_widget_get_display (widget),
|
||||
gtk_widget_get_screen (widget),
|
||||
x + w / 2,
|
||||
y + h / 2);
|
||||
|
||||
sleep_in_main_loop (0.5);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
on_enter (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data)
|
||||
{
|
||||
CrossingTest *test = (CrossingTest*)user_data;
|
||||
|
||||
CrossingEventData *evt = g_slice_new0 (CrossingEventData);
|
||||
evt->entered = TRUE;
|
||||
evt->name = g_strdup (gtk_widget_get_name (widget));
|
||||
evt->synthesized = event->send_event;
|
||||
evt->mode = event->mode;
|
||||
evt->detail = event->detail;
|
||||
|
||||
if (!test->queue)
|
||||
test->queue = g_queue_new ();
|
||||
|
||||
g_queue_push_tail (test->queue, evt);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
on_leave (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data)
|
||||
{
|
||||
CrossingTest *test = (CrossingTest*)user_data;
|
||||
|
||||
CrossingEventData *evt = g_slice_new0 (CrossingEventData);
|
||||
evt->entered = FALSE;
|
||||
evt->name = g_strdup (gtk_widget_get_name (widget));
|
||||
evt->synthesized = event->send_event;
|
||||
evt->mode = event->mode;
|
||||
evt->detail = event->detail;
|
||||
|
||||
if (!test->queue)
|
||||
test->queue = g_queue_new ();
|
||||
|
||||
g_queue_push_tail (test->queue, evt);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
on_check_toggled (GtkWidget *toggle, GtkWidget *button)
|
||||
{
|
||||
gtk_widget_set_sensitive (button, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (toggle)));
|
||||
}
|
||||
|
||||
static void
|
||||
sensitivity_setup (CrossingTest *test,
|
||||
gconstpointer user_data)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
|
||||
test->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_widget_set_name (test->window, "W");
|
||||
frame = gtk_frame_new ("Crossing Events");
|
||||
test->eventbox = gtk_event_box_new ();
|
||||
gtk_widget_set_name (test->eventbox, "E");
|
||||
|
||||
GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 10);
|
||||
gtk_container_add (GTK_CONTAINER (test->window), frame);
|
||||
gtk_container_add (GTK_CONTAINER (frame), test->eventbox);
|
||||
gtk_container_add (GTK_CONTAINER (test->eventbox), vbox);
|
||||
|
||||
test->button = gtk_button_new_with_label ("Click me!");
|
||||
gtk_widget_set_name (test->button, "B");
|
||||
gtk_box_pack_start (GTK_BOX (vbox), test->button, FALSE, TRUE, 0);
|
||||
|
||||
test->check = gtk_check_button_new_with_label ("Sensitive?");
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (test->check), TRUE);
|
||||
g_signal_connect (G_OBJECT (test->check),
|
||||
"toggled", G_CALLBACK (on_check_toggled), test->button);
|
||||
gtk_widget_set_name (test->check, "C");
|
||||
gtk_box_pack_start (GTK_BOX (vbox), test->check, FALSE, TRUE, 0);
|
||||
|
||||
gtk_widget_show_all (test->window);
|
||||
|
||||
gtk_window_move (GTK_WINDOW (test->window), 0, 0);
|
||||
|
||||
sleep_in_main_loop (0.5);
|
||||
}
|
||||
|
||||
static void
|
||||
sensitivity_teardown (CrossingTest *test,
|
||||
gconstpointer user_data)
|
||||
{
|
||||
stop_events (test);
|
||||
gtk_widget_destroy (test->window);
|
||||
|
||||
if (test->queue != NULL)
|
||||
{
|
||||
g_queue_clear (test->queue);
|
||||
test->queue = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
start_events (CrossingTest *test)
|
||||
{
|
||||
if (!test->events_connected)
|
||||
{
|
||||
g_object_connect (G_OBJECT (test->window),
|
||||
"signal::destroy", gtk_main_quit, NULL,
|
||||
"signal::enter-notify-event", on_enter, test,
|
||||
"signal::leave-notify-event", on_leave, test,
|
||||
NULL);
|
||||
g_object_connect (G_OBJECT (test->eventbox),
|
||||
"signal::enter-notify-event", on_enter, test,
|
||||
"signal::leave-notify-event", on_leave, test,
|
||||
NULL);
|
||||
g_object_connect (G_OBJECT (test->button),
|
||||
"signal::enter-notify-event", on_enter, test,
|
||||
"signal::leave-notify-event", on_leave, test,
|
||||
NULL);
|
||||
g_object_connect (G_OBJECT (test->check),
|
||||
"signal::enter-notify-event", on_enter, test,
|
||||
"signal::leave-notify-event", on_leave, test,
|
||||
NULL);
|
||||
test->events_connected = TRUE;
|
||||
}
|
||||
|
||||
sleep_in_main_loop (0.5);
|
||||
}
|
||||
|
||||
void
|
||||
stop_events (CrossingTest *test)
|
||||
{
|
||||
if (test->events_connected)
|
||||
{
|
||||
g_object_disconnect (G_OBJECT (test->window),
|
||||
"any_signal", gtk_main_quit, NULL,
|
||||
"any_signal", on_enter, test,
|
||||
"any_signal", on_leave, test,
|
||||
NULL);
|
||||
g_object_disconnect (G_OBJECT (test->eventbox),
|
||||
"any_signal", on_enter, test,
|
||||
"any_signal", on_leave, test,
|
||||
NULL);
|
||||
g_object_disconnect (G_OBJECT (test->button),
|
||||
"any_signal", on_enter, test,
|
||||
"any_signal", on_leave, test,
|
||||
NULL);
|
||||
g_object_disconnect (G_OBJECT (test->check),
|
||||
"any_signal", G_CALLBACK (on_check_toggled), test->button,
|
||||
"any_signal", on_enter, test,
|
||||
"any_signal", on_leave, test,
|
||||
NULL);
|
||||
test->events_connected = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
move_cursor_away (CrossingTest *test)
|
||||
{
|
||||
gdk_display_warp_pointer (gtk_widget_get_display (test->window),
|
||||
gtk_widget_get_screen (test->window),
|
||||
1000, -1000);
|
||||
|
||||
sleep_in_main_loop (0.5);
|
||||
}
|
||||
|
||||
void
|
||||
check_event (CrossingTest *test,
|
||||
const gchar *name,
|
||||
gboolean entered,
|
||||
gboolean synthesized,
|
||||
GdkCrossingMode mode,
|
||||
GdkNotifyType detail)
|
||||
{
|
||||
CrossingEventData *evt;
|
||||
|
||||
g_assert (test->queue != NULL);
|
||||
|
||||
evt = g_queue_pop_head (test->queue);
|
||||
|
||||
g_assert (evt->entered == entered);
|
||||
g_assert (strcmp (evt->name, name) == 0);
|
||||
g_assert (evt->synthesized == synthesized);
|
||||
g_assert (evt->mode == mode);
|
||||
|
||||
if (evt->detail != detail)
|
||||
g_print ("%s %s event, detail %d, expected detail %d\n",
|
||||
synthesized ? "synthesized" : "native",
|
||||
entered ? "enter" : "leave",
|
||||
evt->detail, detail);
|
||||
|
||||
g_assert (evt->detail == detail);
|
||||
}
|
||||
|
||||
/* Verify crossing events when moving into and out of a sensitive widget */
|
||||
static void
|
||||
cursor_on_sensitive (CrossingTest *test,
|
||||
gconstpointer user_data)
|
||||
{
|
||||
move_cursor_away (test);
|
||||
|
||||
start_events (test);
|
||||
|
||||
set_cursor (test->button);
|
||||
|
||||
check_event (test,
|
||||
"W",
|
||||
TRUE,
|
||||
FALSE, /* native */
|
||||
GDK_CROSSING_NORMAL,
|
||||
GDK_NOTIFY_NONLINEAR_VIRTUAL);
|
||||
|
||||
check_event (test,
|
||||
"E",
|
||||
TRUE,
|
||||
FALSE, /* native */
|
||||
GDK_CROSSING_NORMAL,
|
||||
GDK_NOTIFY_NONLINEAR_VIRTUAL);
|
||||
|
||||
check_event (test,
|
||||
"B",
|
||||
TRUE,
|
||||
FALSE, /* native */
|
||||
GDK_CROSSING_NORMAL,
|
||||
GDK_NOTIFY_NONLINEAR);
|
||||
|
||||
g_assert (g_queue_is_empty (test->queue));
|
||||
|
||||
move_cursor_away (test);
|
||||
|
||||
check_event (test,
|
||||
"B",
|
||||
FALSE,
|
||||
FALSE, /* native */
|
||||
GDK_CROSSING_NORMAL,
|
||||
GDK_NOTIFY_NONLINEAR);
|
||||
|
||||
check_event (test,
|
||||
"E",
|
||||
FALSE,
|
||||
FALSE, /* native */
|
||||
GDK_CROSSING_NORMAL,
|
||||
GDK_NOTIFY_NONLINEAR_VIRTUAL);
|
||||
|
||||
check_event (test,
|
||||
"W",
|
||||
FALSE,
|
||||
FALSE, /* native */
|
||||
GDK_CROSSING_NORMAL,
|
||||
GDK_NOTIFY_NONLINEAR_VIRTUAL);
|
||||
|
||||
g_assert (g_queue_is_empty (test->queue));
|
||||
|
||||
stop_events (test);
|
||||
}
|
||||
|
||||
static void
|
||||
change_sensitive_to_insensitive (CrossingTest *test,
|
||||
gconstpointer user_data)
|
||||
{
|
||||
move_cursor_away (test);
|
||||
set_cursor (test->button);
|
||||
|
||||
start_events (test);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (test->check), FALSE);
|
||||
|
||||
check_event (test,
|
||||
"B",
|
||||
FALSE,
|
||||
TRUE, /* synthesized */
|
||||
GDK_CROSSING_STATE_CHANGED,
|
||||
GDK_NOTIFY_ANCESTOR);
|
||||
|
||||
check_event (test,
|
||||
"E",
|
||||
FALSE,
|
||||
TRUE, /* synthesized */
|
||||
GDK_CROSSING_STATE_CHANGED,
|
||||
GDK_NOTIFY_VIRTUAL);
|
||||
|
||||
check_event (test,
|
||||
"W",
|
||||
FALSE,
|
||||
TRUE, /* synthesized */
|
||||
GDK_CROSSING_STATE_CHANGED,
|
||||
GDK_NOTIFY_VIRTUAL);
|
||||
|
||||
g_assert (g_queue_is_empty (test->queue));
|
||||
|
||||
stop_events (test);
|
||||
}
|
||||
|
||||
static void
|
||||
change_insensitive_to_sensitive (CrossingTest *test,
|
||||
gconstpointer user_data)
|
||||
{
|
||||
move_cursor_away (test);
|
||||
set_cursor (test->button);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (test->check), FALSE);
|
||||
|
||||
start_events (test);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (test->check), TRUE);
|
||||
|
||||
check_event (test,
|
||||
"W",
|
||||
TRUE,
|
||||
TRUE, /* synthesized */
|
||||
GDK_CROSSING_STATE_CHANGED,
|
||||
GDK_NOTIFY_VIRTUAL);
|
||||
|
||||
check_event (test,
|
||||
"E",
|
||||
TRUE,
|
||||
TRUE, /* synthesized */
|
||||
GDK_CROSSING_STATE_CHANGED,
|
||||
GDK_NOTIFY_VIRTUAL);
|
||||
|
||||
check_event (test,
|
||||
"B",
|
||||
TRUE,
|
||||
TRUE, /* synthesized */
|
||||
GDK_CROSSING_STATE_CHANGED,
|
||||
GDK_NOTIFY_ANCESTOR);
|
||||
|
||||
g_assert (g_queue_is_empty (test->queue));
|
||||
|
||||
stop_events (test);
|
||||
}
|
||||
|
||||
static void
|
||||
cursor_from_insensitive_to_sensitive (CrossingTest *test,
|
||||
gconstpointer user_data)
|
||||
{
|
||||
set_cursor (test->button);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (test->check), FALSE);
|
||||
|
||||
start_events (test);
|
||||
|
||||
set_cursor (test->check);
|
||||
|
||||
check_event (test,
|
||||
"C",
|
||||
TRUE,
|
||||
FALSE, /* native */
|
||||
GDK_CROSSING_NORMAL,
|
||||
GDK_NOTIFY_NONLINEAR);
|
||||
|
||||
g_assert (g_queue_is_empty (test->queue));
|
||||
|
||||
stop_events (test);
|
||||
}
|
||||
|
||||
static void
|
||||
cursor_from_sensitive_to_insensitive (CrossingTest *test,
|
||||
gconstpointer user_data)
|
||||
{
|
||||
set_cursor (test->check);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (test->check), FALSE);
|
||||
|
||||
start_events (test);
|
||||
|
||||
set_cursor (test->button);
|
||||
|
||||
check_event (test,
|
||||
"C",
|
||||
FALSE,
|
||||
FALSE, /* native */
|
||||
GDK_CROSSING_NORMAL,
|
||||
GDK_NOTIFY_NONLINEAR);
|
||||
|
||||
g_assert (g_queue_is_empty (test->queue));
|
||||
|
||||
stop_events (test);
|
||||
}
|
||||
|
||||
static void
|
||||
add_gtk_grab (CrossingTest *test,
|
||||
gconstpointer user_data)
|
||||
{
|
||||
set_cursor (test->button);
|
||||
|
||||
start_events (test);
|
||||
|
||||
gtk_grab_add (test->check);
|
||||
|
||||
check_event (test,
|
||||
"B",
|
||||
FALSE,
|
||||
TRUE, /* synthesized */
|
||||
GDK_CROSSING_GTK_GRAB,
|
||||
GDK_NOTIFY_ANCESTOR);
|
||||
|
||||
check_event (test,
|
||||
"E",
|
||||
FALSE,
|
||||
TRUE, /* synthesized */
|
||||
GDK_CROSSING_GTK_GRAB,
|
||||
GDK_NOTIFY_ANCESTOR);
|
||||
|
||||
check_event (test,
|
||||
"W",
|
||||
FALSE,
|
||||
TRUE, /* synthesized */
|
||||
GDK_CROSSING_GTK_GRAB,
|
||||
GDK_NOTIFY_ANCESTOR);
|
||||
|
||||
g_assert (g_queue_is_empty (test->queue));
|
||||
|
||||
stop_events (test);
|
||||
}
|
||||
|
||||
static void
|
||||
remove_gtk_grab (CrossingTest *test,
|
||||
gconstpointer user_data)
|
||||
{
|
||||
set_cursor (test->button);
|
||||
|
||||
gtk_grab_add (test->check);
|
||||
|
||||
start_events (test);
|
||||
|
||||
gtk_grab_remove (test->check);
|
||||
|
||||
check_event (test,
|
||||
"B",
|
||||
TRUE,
|
||||
TRUE, /* synthesized */
|
||||
GDK_CROSSING_GTK_UNGRAB,
|
||||
GDK_NOTIFY_ANCESTOR);
|
||||
|
||||
check_event (test,
|
||||
"E",
|
||||
TRUE,
|
||||
TRUE, /* synthesized */
|
||||
GDK_CROSSING_GTK_UNGRAB,
|
||||
GDK_NOTIFY_ANCESTOR);
|
||||
|
||||
check_event (test,
|
||||
"W",
|
||||
TRUE,
|
||||
TRUE, /* synthesized */
|
||||
GDK_CROSSING_GTK_UNGRAB,
|
||||
GDK_NOTIFY_ANCESTOR);
|
||||
|
||||
g_assert (g_queue_is_empty (test->queue));
|
||||
|
||||
stop_events (test);
|
||||
}
|
||||
|
||||
static void
|
||||
cursor_from_shadowed_to_unshadowed (CrossingTest *test,
|
||||
gconstpointer user_data)
|
||||
{
|
||||
set_cursor (test->button);
|
||||
|
||||
gtk_grab_add (test->check);
|
||||
|
||||
start_events (test);
|
||||
|
||||
set_cursor (test->check);
|
||||
|
||||
check_event (test,
|
||||
"C",
|
||||
FALSE,
|
||||
FALSE, /* native */
|
||||
GDK_CROSSING_NORMAL,
|
||||
GDK_NOTIFY_NONLINEAR);
|
||||
|
||||
check_event (test,
|
||||
"C",
|
||||
TRUE,
|
||||
FALSE, /* native */
|
||||
GDK_CROSSING_NORMAL,
|
||||
GDK_NOTIFY_NONLINEAR);
|
||||
|
||||
g_assert (g_queue_is_empty (test->queue));
|
||||
|
||||
stop_events (test);
|
||||
}
|
||||
|
||||
static void
|
||||
cursor_from_unshadowed_to_shadowed (CrossingTest *test,
|
||||
gconstpointer user_data)
|
||||
{
|
||||
set_cursor (test->check);
|
||||
|
||||
gtk_grab_add (test->check);
|
||||
|
||||
start_events (test);
|
||||
|
||||
set_cursor (test->button);
|
||||
|
||||
check_event (test,
|
||||
"C",
|
||||
FALSE,
|
||||
FALSE, /* native */
|
||||
GDK_CROSSING_NORMAL,
|
||||
GDK_NOTIFY_NONLINEAR);
|
||||
|
||||
check_event (test,
|
||||
"C",
|
||||
TRUE,
|
||||
FALSE, /* native */
|
||||
GDK_CROSSING_NORMAL,
|
||||
GDK_NOTIFY_NONLINEAR);
|
||||
|
||||
g_assert (g_queue_is_empty (test->queue));
|
||||
|
||||
stop_events (test);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
gtk_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add ("/crossings/cursor-on-sensitive", CrossingTest, NULL,
|
||||
sensitivity_setup, cursor_on_sensitive, sensitivity_teardown);
|
||||
|
||||
g_test_add ("/crossings/change-sensitive-to-insensitive", CrossingTest, NULL,
|
||||
sensitivity_setup, change_sensitive_to_insensitive, sensitivity_teardown);
|
||||
|
||||
g_test_add ("/crossings/cursor-from-insensitive-to-sensitive", CrossingTest, NULL,
|
||||
sensitivity_setup, cursor_from_insensitive_to_sensitive, sensitivity_teardown);
|
||||
|
||||
g_test_add ("/crossings/cursor-from-sensitive-to-insensitive", CrossingTest, NULL,
|
||||
sensitivity_setup, cursor_from_sensitive_to_insensitive, sensitivity_teardown);
|
||||
|
||||
g_test_add ("/crossings/change-insensitive-to-sensitive", CrossingTest, NULL,
|
||||
sensitivity_setup, change_insensitive_to_sensitive, sensitivity_teardown);
|
||||
|
||||
g_test_add ("/crossings/add-gtk-grab", CrossingTest, NULL,
|
||||
sensitivity_setup, add_gtk_grab, sensitivity_teardown);
|
||||
|
||||
g_test_add ("/crossings/remove-gtk-grab", CrossingTest, NULL,
|
||||
sensitivity_setup, remove_gtk_grab, sensitivity_teardown);
|
||||
|
||||
g_test_add ("/crossings/cursor-from-shadowed-to-unshadowed", CrossingTest, NULL,
|
||||
sensitivity_setup, cursor_from_shadowed_to_unshadowed, sensitivity_teardown);
|
||||
|
||||
g_test_add ("/crossings/cursor-from-unshadowed-to-shadowed", CrossingTest, NULL,
|
||||
sensitivity_setup, cursor_from_unshadowed_to_shadowed, sensitivity_teardown);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the GTK+ Team and others 1997-2001. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#include <gdk/gdkx.h>
|
||||
#endif
|
||||
|
||||
static void
|
||||
test_click_expander (void)
|
||||
{
|
||||
GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test click on expander");
|
||||
GtkWidget *expander = gtk_expander_new ("Test Expander");
|
||||
GtkWidget *label = gtk_label_new ("Test Label");
|
||||
gboolean expanded;
|
||||
gboolean simsuccess;
|
||||
gtk_container_add (GTK_CONTAINER (expander), label);
|
||||
gtk_container_add (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (window))), expander);
|
||||
gtk_widget_show (expander);
|
||||
gtk_widget_show (label);
|
||||
gtk_widget_show_now (window);
|
||||
/* check initial expander state */
|
||||
expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
|
||||
g_assert (!expanded);
|
||||
/* check expanding */
|
||||
simsuccess = gtk_test_widget_click (expander, 1, 0);
|
||||
g_assert (simsuccess == TRUE);
|
||||
|
||||
gtk_test_widget_wait_for_draw (expander);
|
||||
|
||||
expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
|
||||
g_assert (expanded);
|
||||
/* check collapsing */
|
||||
simsuccess = gtk_test_widget_click (expander, 1, 0);
|
||||
g_assert (simsuccess == TRUE);
|
||||
|
||||
gtk_test_widget_wait_for_draw (expander);
|
||||
|
||||
expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
|
||||
g_assert (!expanded);
|
||||
}
|
||||
|
||||
static void
|
||||
test_click_content_widget (void)
|
||||
{
|
||||
GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test click on content widget");
|
||||
GtkWidget *expander = gtk_expander_new ("Test Expander");
|
||||
GtkWidget *entry = gtk_entry_new ();
|
||||
gboolean expanded;
|
||||
gboolean simsuccess;
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (expander), entry);
|
||||
gtk_container_add (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (window))), expander);
|
||||
gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
|
||||
gtk_widget_show (expander);
|
||||
gtk_widget_show (entry);
|
||||
gtk_widget_show_now (window);
|
||||
|
||||
/* check click on content with expander open */
|
||||
expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
|
||||
g_assert (expanded);
|
||||
simsuccess = gtk_test_widget_click (entry, 1, 0);
|
||||
g_assert (simsuccess == TRUE);
|
||||
|
||||
gtk_test_widget_wait_for_draw (expander);
|
||||
|
||||
expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
|
||||
g_assert (expanded);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
gtk_test_init (&argc, &argv);
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) ;
|
||||
return 0; /* gtk_test functions don't work well elsewhere */
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
g_test_add_func ("/expander/click-expander", test_click_expander);
|
||||
g_test_add_func ("/expander/click-content-widget", test_click_content_widget);
|
||||
|
||||
return g_test_run();
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,304 +0,0 @@
|
||||
/* Gtk+ testing utilities
|
||||
* Copyright (C) 2007 Imendio AB
|
||||
* Authors: Tim Janik
|
||||
*
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Use a keyval that requires Shift to be active (in typical layouts)
|
||||
* like GDK_KEY_ampersand, which is '<shift>6'
|
||||
*/
|
||||
#define KEYVAL_THAT_REQUIRES_SHIFT GDK_KEY_ampersand
|
||||
|
||||
|
||||
/* --- test functions --- */
|
||||
static void
|
||||
test_button_clicks (void)
|
||||
{
|
||||
int a = 0, b = 0, c = 0;
|
||||
GtkWidget *window = gtk_test_display_button_window ("Test Window",
|
||||
"Test: gtk_test_widget_click",
|
||||
"IgnoreMe1", &a,
|
||||
"ClickMe", &b,
|
||||
"IgnoreMe2", &c,
|
||||
NULL);
|
||||
GtkWidget *button = gtk_test_find_widget (window, "*Click*", GTK_TYPE_BUTTON);
|
||||
gboolean simsuccess;
|
||||
g_assert (button != NULL);
|
||||
simsuccess = gtk_test_widget_click (button, 1, 0);
|
||||
g_assert (simsuccess == TRUE);
|
||||
while (gtk_events_pending ())
|
||||
gtk_main_iteration ();
|
||||
g_assert (a == 0);
|
||||
g_assert (b > 0);
|
||||
g_assert (c == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
test_button_keys (void)
|
||||
{
|
||||
int a = 0, b = 0, c = 0;
|
||||
GtkWidget *window = gtk_test_display_button_window ("Test Window",
|
||||
"Test: gtk_test_widget_send_key",
|
||||
"IgnoreMe1", &a,
|
||||
"ClickMe", &b,
|
||||
"IgnoreMe2", &c,
|
||||
NULL);
|
||||
GtkWidget *button = gtk_test_find_widget (window, "*Click*", GTK_TYPE_BUTTON);
|
||||
gboolean simsuccess;
|
||||
g_assert (button != NULL);
|
||||
gtk_widget_grab_focus (button);
|
||||
g_assert (gtk_widget_has_focus (button));
|
||||
simsuccess = gtk_test_widget_send_key (button, GDK_KEY_Return, 0);
|
||||
g_assert (simsuccess == TRUE);
|
||||
while (gtk_events_pending ())
|
||||
gtk_main_iteration ();
|
||||
g_assert (a == 0);
|
||||
g_assert (b > 0);
|
||||
g_assert (c == 0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
store_last_key_release (GtkWidget *widget,
|
||||
GdkEventKey *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
*((gint *)user_data) = event->keyval;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
test_send_shift_key (void)
|
||||
{
|
||||
GtkWidget *window = gtk_test_display_button_window ("Test Window",
|
||||
"Test: test_send_shift_key()",
|
||||
"IgnoreMe1", NULL,
|
||||
"SendMeKeys", NULL,
|
||||
"IgnoreMe2", NULL,
|
||||
NULL);
|
||||
GtkWidget *button = gtk_test_find_widget (window, "SendMeKeys", GTK_TYPE_BUTTON);
|
||||
gint last_key_release = 0;
|
||||
gboolean simsuccess;
|
||||
g_assert (button != NULL);
|
||||
g_signal_connect (button, "key-release-event",
|
||||
G_CALLBACK (store_last_key_release),
|
||||
&last_key_release);
|
||||
gtk_widget_grab_focus (button);
|
||||
g_assert (gtk_widget_has_focus (button));
|
||||
simsuccess = gtk_test_widget_send_key (button, KEYVAL_THAT_REQUIRES_SHIFT, 0 /*modifiers*/);
|
||||
g_assert (simsuccess == TRUE);
|
||||
while (gtk_events_pending ())
|
||||
gtk_main_iteration ();
|
||||
g_assert_cmpint (KEYVAL_THAT_REQUIRES_SHIFT, ==, last_key_release);
|
||||
}
|
||||
|
||||
static void
|
||||
test_slider_ranges (void)
|
||||
{
|
||||
GtkWidget *child;
|
||||
GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test: gtk_test_warp_slider");
|
||||
GtkWidget *hscale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
|
||||
-50, +50, 5);
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (window));
|
||||
gtk_container_add (GTK_CONTAINER (child), hscale);
|
||||
gtk_widget_show (hscale);
|
||||
gtk_widget_show_now (window);
|
||||
while (gtk_events_pending ())
|
||||
gtk_main_iteration ();
|
||||
gtk_test_slider_set_perc (hscale, 0.0);
|
||||
while (gtk_events_pending ())
|
||||
gtk_main_iteration ();
|
||||
g_assert (gtk_test_slider_get_value (hscale) == -50);
|
||||
gtk_test_slider_set_perc (hscale, 50.0);
|
||||
while (gtk_events_pending ())
|
||||
gtk_main_iteration ();
|
||||
g_assert (fabs (gtk_test_slider_get_value (hscale)) < 0.0001);
|
||||
gtk_test_slider_set_perc (hscale, 100.0);
|
||||
while (gtk_events_pending ())
|
||||
gtk_main_iteration ();
|
||||
g_assert (gtk_test_slider_get_value (hscale) == +50.0);
|
||||
}
|
||||
|
||||
static void
|
||||
test_text_access (void)
|
||||
{
|
||||
const int N_WIDGETS = 3;
|
||||
GtkWidget *widgets[N_WIDGETS];
|
||||
int i = 0;
|
||||
widgets[i++] = gtk_test_create_widget (GTK_TYPE_LABEL, NULL);
|
||||
widgets[i++] = gtk_test_create_widget (GTK_TYPE_ENTRY, NULL);
|
||||
widgets[i++] = gtk_test_create_widget (GTK_TYPE_TEXT_VIEW, NULL);
|
||||
g_assert (i == N_WIDGETS);
|
||||
for (i = 0; i < N_WIDGETS; i++)
|
||||
gtk_test_text_set (widgets[i], "foobar");
|
||||
for (i = 0; i < N_WIDGETS; i++)
|
||||
{
|
||||
gchar *text = gtk_test_text_get (widgets[i]);
|
||||
g_assert (strcmp (text, "foobar") == 0);
|
||||
g_free (text);
|
||||
}
|
||||
for (i = 0; i < N_WIDGETS; i++)
|
||||
gtk_test_text_set (widgets[i], "");
|
||||
for (i = 0; i < N_WIDGETS; i++)
|
||||
{
|
||||
gchar *text = gtk_test_text_get (widgets[i]);
|
||||
g_assert (strcmp (text, "") == 0);
|
||||
g_free (text);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_xserver_sync (void)
|
||||
{
|
||||
GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test: test_xserver_sync");
|
||||
GtkWidget *darea = gtk_drawing_area_new ();
|
||||
GtkWidget *child;
|
||||
GdkWindow *gdk_window;
|
||||
GTimer *gtimer = g_timer_new();
|
||||
gint sync_is_slower = 0, repeat = 5;
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (window));
|
||||
//gdk_window = gtk_widget_get_window (darea);
|
||||
|
||||
gtk_widget_set_size_request (darea, 320, 200);
|
||||
gtk_container_add (GTK_CONTAINER (child), darea);
|
||||
gtk_widget_show (darea);
|
||||
gtk_widget_show_now (window);
|
||||
|
||||
while (repeat--)
|
||||
{
|
||||
gint i, many = 200;
|
||||
double nosync_time, sync_time;
|
||||
cairo_t *cr;
|
||||
|
||||
while (gtk_events_pending ())
|
||||
gtk_main_iteration ();
|
||||
gdk_window = gtk_widget_get_window (darea);
|
||||
cr = gdk_cairo_create (gdk_window);
|
||||
cairo_set_source_rgba (cr, 0, 1, 0, 0.1);
|
||||
/* run a number of consecutive drawing requests, just using drawing queue */
|
||||
g_timer_start (gtimer);
|
||||
for (i = 0; i < many; i++)
|
||||
{
|
||||
cairo_paint (cr);
|
||||
}
|
||||
g_timer_stop (gtimer);
|
||||
nosync_time = g_timer_elapsed (gtimer, NULL);
|
||||
gdk_flush();
|
||||
while (gtk_events_pending ())
|
||||
gtk_main_iteration ();
|
||||
g_timer_start (gtimer);
|
||||
/* run a number of consecutive drawing requests with intermediate drawing syncs */
|
||||
for (i = 0; i < many; i++)
|
||||
{
|
||||
cairo_paint (cr);
|
||||
gdk_test_render_sync (gdk_window);
|
||||
}
|
||||
g_timer_stop (gtimer);
|
||||
sync_time = g_timer_elapsed (gtimer, NULL);
|
||||
sync_is_slower += sync_time > nosync_time * 1.5;
|
||||
}
|
||||
g_timer_destroy (gtimer);
|
||||
g_assert (sync_is_slower > 0);
|
||||
}
|
||||
|
||||
static void
|
||||
test_spin_button_arrows (void)
|
||||
{
|
||||
GtkWidget *child;
|
||||
GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test: test_spin_button_arrows");
|
||||
GtkWidget *spinner = gtk_spin_button_new_with_range (0, 100, 5);
|
||||
gboolean simsuccess;
|
||||
double oldval, newval;
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (window));
|
||||
gtk_container_add (GTK_CONTAINER (child), spinner);
|
||||
gtk_widget_show (spinner);
|
||||
gtk_widget_show_now (window);
|
||||
gtk_test_slider_set_perc (spinner, 0);
|
||||
/* check initial spinner value */
|
||||
oldval = gtk_test_slider_get_value (spinner);
|
||||
g_assert (oldval == 0);
|
||||
/* check simple increment */
|
||||
simsuccess = gtk_test_spin_button_click (GTK_SPIN_BUTTON (spinner), 1, TRUE);
|
||||
g_assert (simsuccess == TRUE);
|
||||
while (gtk_events_pending ()) /* let spin button timeout/idle handlers update */
|
||||
gtk_main_iteration ();
|
||||
newval = gtk_test_slider_get_value (spinner);
|
||||
g_assert (newval > oldval);
|
||||
/* check maximum warp */
|
||||
simsuccess = gtk_test_spin_button_click (GTK_SPIN_BUTTON (spinner), 3, TRUE);
|
||||
g_assert (simsuccess == TRUE);
|
||||
while (gtk_events_pending ()) /* let spin button timeout/idle handlers update */
|
||||
gtk_main_iteration ();
|
||||
oldval = gtk_test_slider_get_value (spinner);
|
||||
g_assert (oldval == 100);
|
||||
/* check simple decrement */
|
||||
oldval = gtk_test_slider_get_value (spinner);
|
||||
simsuccess = gtk_test_spin_button_click (GTK_SPIN_BUTTON (spinner), 1, FALSE);
|
||||
g_assert (simsuccess == TRUE);
|
||||
while (gtk_events_pending ()) /* let spin button timeout/idle handlers update */
|
||||
gtk_main_iteration ();
|
||||
newval = gtk_test_slider_get_value (spinner);
|
||||
g_assert (newval < oldval);
|
||||
/* check minimum warp */
|
||||
simsuccess = gtk_test_spin_button_click (GTK_SPIN_BUTTON (spinner), 3, FALSE);
|
||||
g_assert (simsuccess == TRUE);
|
||||
while (gtk_events_pending ()) /* let spin button timeout/idle handlers update */
|
||||
gtk_main_iteration ();
|
||||
oldval = gtk_test_slider_get_value (spinner);
|
||||
g_assert (oldval == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
test_statusbar_remove_all (void)
|
||||
{
|
||||
GtkWidget *statusbar;
|
||||
|
||||
g_test_bug ("640487");
|
||||
|
||||
statusbar = gtk_statusbar_new ();
|
||||
g_object_ref_sink (statusbar);
|
||||
|
||||
gtk_statusbar_push (GTK_STATUSBAR (statusbar), 1, "bla");
|
||||
gtk_statusbar_push (GTK_STATUSBAR (statusbar), 1, "bla");
|
||||
gtk_statusbar_remove_all (GTK_STATUSBAR (statusbar), 1);
|
||||
|
||||
g_object_unref (statusbar);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
gtk_test_init (&argc, &argv);
|
||||
g_test_bug_base ("http://bugzilla.gnome.org/");
|
||||
gtk_test_register_all_types();
|
||||
|
||||
g_test_add_func ("/tests/statusbar-remove-all", test_statusbar_remove_all);
|
||||
g_test_add_func ("/ui-tests/text-access", test_text_access);
|
||||
g_test_add_func ("/ui-tests/button-clicks", test_button_clicks);
|
||||
g_test_add_func ("/ui-tests/keys-events", test_button_keys);
|
||||
g_test_add_func ("/ui-tests/send-shift-key", test_send_shift_key);
|
||||
g_test_add_func ("/ui-tests/slider-ranges", test_slider_ranges);
|
||||
g_test_add_func ("/ui-tests/xserver-sync", test_xserver_sync);
|
||||
g_test_add_func ("/ui-tests/spin-button-arrows", test_spin_button_arrows);
|
||||
|
||||
return g_test_run();
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user