diff --git a/ChangeLog b/ChangeLog index 7c8b235030..a468f0cd7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Jul 4 19:55:49 2003 Soeren Sandmann + + * tests/stresstest-toolbar: remove this accidentally committed + file. + + * tests/stresstest-toolbar.c: really add this new test + Fri Jul 4 19:06:31 2003 Soeren Sandmann * tests/stresstest-toolbar.c: new test for removing items diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 7c8b235030..a468f0cd7a 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +Fri Jul 4 19:55:49 2003 Soeren Sandmann + + * tests/stresstest-toolbar: remove this accidentally committed + file. + + * tests/stresstest-toolbar.c: really add this new test + Fri Jul 4 19:06:31 2003 Soeren Sandmann * tests/stresstest-toolbar.c: new test for removing items diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 7c8b235030..a468f0cd7a 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,10 @@ +Fri Jul 4 19:55:49 2003 Soeren Sandmann + + * tests/stresstest-toolbar: remove this accidentally committed + file. + + * tests/stresstest-toolbar.c: really add this new test + Fri Jul 4 19:06:31 2003 Soeren Sandmann * tests/stresstest-toolbar.c: new test for removing items diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 7c8b235030..a468f0cd7a 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,10 @@ +Fri Jul 4 19:55:49 2003 Soeren Sandmann + + * tests/stresstest-toolbar: remove this accidentally committed + file. + + * tests/stresstest-toolbar.c: really add this new test + Fri Jul 4 19:06:31 2003 Soeren Sandmann * tests/stresstest-toolbar.c: new test for removing items diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 7c8b235030..a468f0cd7a 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,10 @@ +Fri Jul 4 19:55:49 2003 Soeren Sandmann + + * tests/stresstest-toolbar: remove this accidentally committed + file. + + * tests/stresstest-toolbar.c: really add this new test + Fri Jul 4 19:06:31 2003 Soeren Sandmann * tests/stresstest-toolbar.c: new test for removing items diff --git a/tests/stresstest-toolbar b/tests/stresstest-toolbar deleted file mode 100755 index d76722ae13..0000000000 --- a/tests/stresstest-toolbar +++ /dev/null @@ -1,117 +0,0 @@ -#! /bin/sh - -# stresstest-toolbar - temporary wrapper script for .libs/stresstest-toolbar -# Generated by ltmain.sh - GNU libtool 1.5 (1.1220 2003/04/05 19:32:58) -# -# The stresstest-toolbar program cannot be directly executed until all the libtool -# libraries that it depends on are installed. -# -# This wrapper script should never be moved out of the build directory. -# If it is, it will not operate correctly. - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='/bin/sed -e 1s/^X//' -sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -if test "${CDPATH+set}" = set; then CDPATH=:; export CDPATH; fi - -relink_command="(cd /home/ssp/vertigo/toolcheck/gtk+/tests; LIBRARY_PATH=\".:/usr/X11R6/lib/\"; export LIBRARY_PATH; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; PATH=\"/usr/local/lib/beta/bin:/home/ssp/vertigo/usr/bin:/home/ssp/vertigo/usr/games:/usr/local/gnu/bin:/usr/java/bin:/home/ssp/usr/bin:/home/ssp/usr/bin/i386-linux:/usr/local/bin:/usr/bin/X11:/usr/bin:/bin:/sbin:/usr/sbin:/usr/ucb:/home/ssp/usr/bin:/usr/ccs/bin:/users/hendren/JOOS/Bin:.\"; export PATH; gcc -g -O2 -g -Wall -o \$progdir/\$file stresstest-toolbar.o ../gdk-pixbuf/.libs/libgdk_pixbuf-2.0.so -L/home/ssp/vertigo/usr/lib ../gdk/.libs/libgdk-x11-2.0.so -L/usr/X11R6/lib -L/usr/local/lib ../gtk/.libs/libgtk-x11-2.0.so /home/ssp/vertigo/toolcheck/gtk+/gdk/.libs/libgdk-x11-2.0.so -lXrandr -lXext -lXinerama /usr/lib/libXft.so /usr/local/lib/libXrender.so /usr/lib/libfontconfig.so /usr/lib/libfreetype.so /usr/lib/libexpat.so -lX11 /usr/local/lib/libfreetype.so -lz -lXcursor /usr/lib/libpangoxft-1.0.so /usr/lib/libpangox-1.0.so /usr/lib/libpango-1.0.so /usr/lib/libgobject-2.0.so /usr/lib/libglib-2.0.so /home/ssp/vertigo/toolcheck/gtk+/gdk-pixbuf/.libs/libgdk_pixbuf-2.0.so /home/ssp/vertigo/usr/lib/libpangoxft-1.0.so /home/ssp/vertigo/usr/lib/libpangox-1.0.so /home/ssp/vertigo/usr/lib/libpango-1.0.so /home/ssp/vertigo/usr/lib/libatk-1.0.so /home/ssp/vertigo/usr/lib/libgobject-2.0.so /home/ssp/vertigo/usr/lib/libgmodule-2.0.so -ldl /home/ssp/vertigo/usr/lib/libglib-2.0.so -lm -Wl,--rpath -Wl,/home/ssp/vertigo/toolcheck/gtk+/gdk-pixbuf/.libs -Wl,--rpath -Wl,/home/ssp/vertigo/toolcheck/gtk+/gdk/.libs -Wl,--rpath -Wl,/home/ssp/vertigo/toolcheck/gtk+/gtk/.libs -Wl,--rpath -Wl,/usr/local/lib -Wl,--rpath -Wl,/home/ssp/vertigo/usr/lib -Wl,--rpath -Wl,/home/ssp/vertigo/usr/lib -Wl,--rpath -Wl,/usr/local/lib)" - -# This environment variable determines our operation mode. -if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then - # install mode needs the following variable: - notinst_deplibs=' ../gdk-pixbuf/libgdk_pixbuf-2.0.la ../gdk/libgdk-x11-2.0.la ../gtk/libgtk-x11-2.0.la /home/ssp/vertigo/toolcheck/gtk+/gdk/libgdk-x11-2.0.la /home/ssp/vertigo/toolcheck/gtk+/gdk-pixbuf/libgdk_pixbuf-2.0.la' -else - # When we are sourced in execute mode, $file and $echo are already set. - if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then - echo="echo" - file="$0" - # Make sure echo works. - if test "X$1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift - elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then - # Yippee, $echo works! - : - else - # Restart under the correct shell, and then maybe $echo will work. - exec /bin/sh "$0" --no-reexec ${1+"$@"} - fi - fi - - # Find the directory that this script lives in. - thisdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - test "x$thisdir" = "x$file" && thisdir=. - - # Follow symbolic links until we get to the real thisdir. - file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` - while test -n "$file"; do - destdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - - # If there was a directory component, then change thisdir. - if test "x$destdir" != "x$file"; then - case "$destdir" in - [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; - *) thisdir="$thisdir/$destdir" ;; - esac - fi - - file=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` - done - - # Try to get the absolute directory name. - absdir=`cd "$thisdir" && pwd` - test -n "$absdir" && thisdir="$absdir" - - program=lt-'stresstest-toolbar' - progdir="$thisdir/.libs" - - if test ! -f "$progdir/$program" || \ - { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ - test "X$file" != "X$progdir/$program"; }; then - - file="$$-$program" - - if test ! -d "$progdir"; then - mkdir "$progdir" - else - rm -f "$progdir/$file" - fi - - # relink executable if necessary - if test -n "$relink_command"; then - if relink_command_output=`eval $relink_command 2>&1`; then : - else - echo "$relink_command_output" >&2 - rm -f "$progdir/$file" - exit 1 - fi - fi - - mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || - { rm -f "$progdir/$program"; - mv -f "$progdir/$file" "$progdir/$program"; } - rm -f "$progdir/$file" - fi - - if test -f "$progdir/$program"; then - if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then - # Run the actual program with our arguments. - - exec $progdir/$program ${1+"$@"} - - $echo "$0: cannot exec $program ${1+"$@"}" - exit 1 - fi - else - # The program doesn't exist. - $echo "$0: error: $progdir/$program does not exist" 1>&2 - $echo "This script is just a wrapper for $program." 1>&2 - echo "See the libtool documentation for more information." 1>&2 - exit 1 - fi -fi diff --git a/tests/stresstest-toolbar.c b/tests/stresstest-toolbar.c new file mode 100644 index 0000000000..370acc1bd2 --- /dev/null +++ b/tests/stresstest-toolbar.c @@ -0,0 +1,151 @@ +/* stresstest-toolbar.c + * + * Copyright (C) 2003 Soeren Sandmann + * + * 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. + */ +#undef GTK_DISABLE_DEPRECATED +#include + +typedef struct _Info Info; +struct _Info +{ + GtkWindow *window; + GtkToolbar *toolbar; + gint counter; +}; + +static void +add_random (GtkToolbar *toolbar, gint n) +{ + gint position; + gchar *label = g_strdup_printf ("Button %d", n); + + GtkWidget *widget = gtk_button_new_with_label (label); + + g_free (label); + gtk_widget_show_all (widget); + + if (g_list_length (toolbar->children) == 0) + position = 0; + else + position = g_random_int_range (0, g_list_length (toolbar->children)); + + gtk_toolbar_insert_widget (toolbar, widget, "Bar", "Baz", position); +} + +static void +remove_random (GtkToolbar *toolbar) +{ + GtkToolbarChild *child; + gint position; + + if (!toolbar->children) + return; + + position = g_random_int_range (0, g_list_length (toolbar->children)); + + child = g_list_nth_data (toolbar->children, position); + + gtk_container_remove (GTK_CONTAINER (toolbar), child->widget); +} + +static gboolean +stress_test_old_api (gpointer data) +{ + typedef enum { + ADD_RANDOM, + REMOVE_RANDOM, + LAST_ACTION + } Action; + + Info *info = data; + Action action; + + if (info->counter++ == 200) + { + gtk_main_quit (); + return FALSE; + } + + if (!info->toolbar) + { + info->toolbar = GTK_TOOLBAR (gtk_toolbar_new ()); + gtk_container_add (GTK_CONTAINER (info->window), + GTK_WIDGET (info->toolbar)); + gtk_widget_show (GTK_WIDGET (info->toolbar)); + } + + if (!info->toolbar->children) + { + add_random (info->toolbar, info->counter); + return TRUE; + } + else if (g_list_length (info->toolbar->children) > 50) + { + int i; + for (i = 0; i < 25; i++) + remove_random (info->toolbar); + return TRUE; + } + + action = g_random_int_range (0, LAST_ACTION); + + switch (action) + { + case ADD_RANDOM: + add_random (info->toolbar, info->counter); + break; + + case REMOVE_RANDOM: + remove_random (info->toolbar); + break; + + default: + g_assert_not_reached(); + break; + } + + return TRUE; +} + + +gint +main (gint argc, gchar **argv) +{ + Info info; + + gtk_init (&argc, &argv); + + info.toolbar = NULL; + info.counter = 0; + info.window = GTK_WINDOW (gtk_window_new (GTK_WINDOW_TOPLEVEL)); + + gtk_widget_show (GTK_WIDGET (info.window)); + + g_idle_add (stress_test_old_api, &info); + + gtk_widget_show_all (GTK_WIDGET (info.window)); + + gtk_main (); + + gtk_widget_destroy (GTK_WIDGET (info.window)); + + info.toolbar = NULL; + info.window = NULL; + + return 0; +}