|
Packit Service |
fb6fa5 |
/* Gtk+ testing utilities
|
|
Packit Service |
fb6fa5 |
* Copyright (C) 2007 Imendio AB
|
|
Packit Service |
fb6fa5 |
* Authors: Tim Janik
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* This library is free software; you can redistribute it and/or
|
|
Packit Service |
fb6fa5 |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
fb6fa5 |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
fb6fa5 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* This library is distributed in the hope that it will be useful,
|
|
Packit Service |
fb6fa5 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
fb6fa5 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
fb6fa5 |
* Lesser General Public License for more details.
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
fb6fa5 |
* License along with this library; if not, write to the
|
|
Packit Service |
fb6fa5 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
Packit Service |
fb6fa5 |
* Boston, MA 02111-1307, USA.
|
|
Packit Service |
fb6fa5 |
*/
|
|
Packit Service |
fb6fa5 |
#include "config.h"
|
|
Packit Service |
fb6fa5 |
#include <gdk/gdktestutils.h>
|
|
Packit Service |
fb6fa5 |
#include <gdk/gdkkeysyms.h>
|
|
Packit Service |
fb6fa5 |
#include <gdk/gdkinternals.h>
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/**
|
|
Packit Service |
fb6fa5 |
* gdk_test_render_sync
|
|
Packit Service |
fb6fa5 |
* @window: a mapped GdkWindow
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* This function retrives a pixel from @window to force the windowing
|
|
Packit Service |
fb6fa5 |
* system to carry out any pending rendering commands.
|
|
Packit Service |
fb6fa5 |
* This function is intended to be used to syncronize with rendering
|
|
Packit Service |
fb6fa5 |
* pipelines, to benchmark windowing system rendering operations.
|
|
Packit Service |
fb6fa5 |
**/
|
|
Packit Service |
fb6fa5 |
void
|
|
Packit Service |
fb6fa5 |
gdk_test_render_sync (GdkWindow *window)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
/* FIXME: Find out if there is a way to implement this on quartz. */
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/**
|
|
Packit Service |
fb6fa5 |
* gdk_test_simulate_key
|
|
Packit Service |
fb6fa5 |
* @window: Gdk window to simulate a key event for.
|
|
Packit Service |
fb6fa5 |
* @x: x coordinate within @window for the key event.
|
|
Packit Service |
fb6fa5 |
* @y: y coordinate within @window for the key event.
|
|
Packit Service |
fb6fa5 |
* @keyval: A Gdk keyboard value.
|
|
Packit Service |
fb6fa5 |
* @modifiers: Keyboard modifiers the event is setup with.
|
|
Packit Service |
fb6fa5 |
* @key_pressrelease: either %GDK_KEY_PRESS or %GDK_KEY_RELEASE
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* This function is intended to be used in Gtk+ test programs.
|
|
Packit Service |
fb6fa5 |
* If (@x,@y) are > (-1,-1), it will warp the mouse pointer to
|
|
Packit Service |
fb6fa5 |
* the given (@x,@y) corrdinates within @window and simulate a
|
|
Packit Service |
fb6fa5 |
* key press or release event.
|
|
Packit Service |
fb6fa5 |
* When the mouse pointer is warped to the target location, use
|
|
Packit Service |
fb6fa5 |
* of this function outside of test programs that run in their
|
|
Packit Service |
fb6fa5 |
* own virtual windowing system (e.g. Xvfb) is not recommended.
|
|
Packit Service |
fb6fa5 |
* If (@x,@y) are passed as (-1,-1), the mouse pointer will not
|
|
Packit Service |
fb6fa5 |
* be warped and @window origin will be used as mouse pointer
|
|
Packit Service |
fb6fa5 |
* location for the event.
|
|
Packit Service |
fb6fa5 |
* Also, gtk_test_simulate_key() is a fairly low level function,
|
|
Packit Service |
fb6fa5 |
* for most testing purposes, gtk_test_widget_send_key() is the
|
|
Packit Service |
fb6fa5 |
* right function to call which will generate a key press event
|
|
Packit Service |
fb6fa5 |
* followed by its accompanying key release event.
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* Returns: wether all actions neccessary for a key event simulation were carried out successfully.
|
|
Packit Service |
fb6fa5 |
**/
|
|
Packit Service |
fb6fa5 |
gboolean
|
|
Packit Service |
fb6fa5 |
gdk_test_simulate_key (GdkWindow *window,
|
|
Packit Service |
fb6fa5 |
gint x,
|
|
Packit Service |
fb6fa5 |
gint y,
|
|
Packit Service |
fb6fa5 |
guint keyval,
|
|
Packit Service |
fb6fa5 |
GdkModifierType modifiers,
|
|
Packit Service |
fb6fa5 |
GdkEventType key_pressrelease)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
g_return_val_if_fail (key_pressrelease == GDK_KEY_PRESS || key_pressrelease == GDK_KEY_RELEASE, FALSE);
|
|
Packit Service |
fb6fa5 |
g_return_val_if_fail (window != NULL, FALSE);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
if (!GDK_WINDOW_IS_MAPPED (window))
|
|
Packit Service |
fb6fa5 |
return FALSE;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* FIXME: Implement. */
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
return FALSE;
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/**
|
|
Packit Service |
fb6fa5 |
* gdk_test_simulate_button
|
|
Packit Service |
fb6fa5 |
* @window: Gdk window to simulate a button event for.
|
|
Packit Service |
fb6fa5 |
* @x: x coordinate within @window for the button event.
|
|
Packit Service |
fb6fa5 |
* @y: y coordinate within @window for the button event.
|
|
Packit Service |
fb6fa5 |
* @button: Number of the pointer button for the event, usually 1, 2 or 3.
|
|
Packit Service |
fb6fa5 |
* @modifiers: Keyboard modifiers the event is setup with.
|
|
Packit Service |
fb6fa5 |
* @button_pressrelease: either %GDK_BUTTON_PRESS or %GDK_BUTTON_RELEASE
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* This function is intended to be used in Gtk+ test programs.
|
|
Packit Service |
fb6fa5 |
* It will warp the mouse pointer to the given (@x,@y) corrdinates
|
|
Packit Service |
fb6fa5 |
* within @window and simulate a button press or release event.
|
|
Packit Service |
fb6fa5 |
* Because the mouse pointer needs to be warped to the target
|
|
Packit Service |
fb6fa5 |
* location, use of this function outside of test programs that
|
|
Packit Service |
fb6fa5 |
* run in their own virtual windowing system (e.g. Xvfb) is not
|
|
Packit Service |
fb6fa5 |
* recommended.
|
|
Packit Service |
fb6fa5 |
* Also, gtk_test_simulate_button() is a fairly low level function,
|
|
Packit Service |
fb6fa5 |
* for most testing purposes, gtk_test_widget_click() is the right
|
|
Packit Service |
fb6fa5 |
* function to call which will generate a button press event followed
|
|
Packit Service |
fb6fa5 |
* by its accompanying button release event.
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* Returns: wether all actions neccessary for a button event simulation were carried out successfully.
|
|
Packit Service |
fb6fa5 |
**/
|
|
Packit Service |
fb6fa5 |
gboolean
|
|
Packit Service |
fb6fa5 |
gdk_test_simulate_button (GdkWindow *window,
|
|
Packit Service |
fb6fa5 |
gint x,
|
|
Packit Service |
fb6fa5 |
gint y,
|
|
Packit Service |
fb6fa5 |
guint button, /*1..3*/
|
|
Packit Service |
fb6fa5 |
GdkModifierType modifiers,
|
|
Packit Service |
fb6fa5 |
GdkEventType button_pressrelease)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
g_return_val_if_fail (button_pressrelease == GDK_BUTTON_PRESS || button_pressrelease == GDK_BUTTON_RELEASE, FALSE);
|
|
Packit Service |
fb6fa5 |
g_return_val_if_fail (window != NULL, FALSE);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
if (!GDK_WINDOW_IS_MAPPED (window))
|
|
Packit Service |
fb6fa5 |
return FALSE;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* FIXME: Implement. */
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
return FALSE;
|
|
Packit Service |
fb6fa5 |
}
|