| 1 |
/* Gtk+ testing utilities |
| 2 |
* Copyright (C) 2007 Imendio AB |
| 3 |
* Authors: Tim Janik |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU Lesser General Public |
| 16 |
* License along with this library; if not, write to the |
| 17 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 18 |
* Boston, MA 02111-1307, USA. |
| 19 |
*/ |
| 20 |
#include "config.h" |
| 21 |
#include <gdk/gdktestutils.h> |
| 22 |
#include <gdk/gdkkeysyms.h> |
| 23 |
#include <gdk/gdkinternals.h> |
| 24 |
|
| 25 |
/** |
| 26 |
* gdk_test_render_sync |
| 27 |
* @window: a mapped GdkWindow |
| 28 |
* |
| 29 |
* This function retrives a pixel from @window to force the windowing |
| 30 |
* system to carry out any pending rendering commands. |
| 31 |
* This function is intended to be used to syncronize with rendering |
| 32 |
* pipelines, to benchmark windowing system rendering operations. |
| 33 |
**/ |
| 34 |
void |
| 35 |
gdk_test_render_sync (GdkWindow *window) |
| 36 |
{ |
| 37 |
/* FIXME: Find out if there is a way to implement this on quartz. */ |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* gdk_test_simulate_key |
| 42 |
* @window: Gdk window to simulate a key event for. |
| 43 |
* @x: x coordinate within @window for the key event. |
| 44 |
* @y: y coordinate within @window for the key event. |
| 45 |
* @keyval: A Gdk keyboard value. |
| 46 |
* @modifiers: Keyboard modifiers the event is setup with. |
| 47 |
* @key_pressrelease: either %GDK_KEY_PRESS or %GDK_KEY_RELEASE |
| 48 |
* |
| 49 |
* This function is intended to be used in Gtk+ test programs. |
| 50 |
* If (@x,@y) are > (-1,-1), it will warp the mouse pointer to |
| 51 |
* the given (@x,@y) corrdinates within @window and simulate a |
| 52 |
* key press or release event. |
| 53 |
* When the mouse pointer is warped to the target location, use |
| 54 |
* of this function outside of test programs that run in their |
| 55 |
* own virtual windowing system (e.g. Xvfb) is not recommended. |
| 56 |
* If (@x,@y) are passed as (-1,-1), the mouse pointer will not |
| 57 |
* be warped and @window origin will be used as mouse pointer |
| 58 |
* location for the event. |
| 59 |
* Also, gtk_test_simulate_key() is a fairly low level function, |
| 60 |
* for most testing purposes, gtk_test_widget_send_key() is the |
| 61 |
* right function to call which will generate a key press event |
| 62 |
* followed by its accompanying key release event. |
| 63 |
* |
| 64 |
* Returns: wether all actions neccessary for a key event simulation were carried out successfully. |
| 65 |
**/ |
| 66 |
gboolean |
| 67 |
gdk_test_simulate_key (GdkWindow *window, |
| 68 |
gint x, |
| 69 |
gint y, |
| 70 |
guint keyval, |
| 71 |
GdkModifierType modifiers, |
| 72 |
GdkEventType key_pressrelease) |
| 73 |
{ |
| 74 |
g_return_val_if_fail (key_pressrelease == GDK_KEY_PRESS || key_pressrelease == GDK_KEY_RELEASE, FALSE); |
| 75 |
g_return_val_if_fail (window != NULL, FALSE); |
| 76 |
|
| 77 |
if (!GDK_WINDOW_IS_MAPPED (window)) |
| 78 |
return FALSE; |
| 79 |
|
| 80 |
/* FIXME: Implement. */ |
| 81 |
|
| 82 |
return FALSE; |
| 83 |
} |
| 84 |
|
| 85 |
/** |
| 86 |
* gdk_test_simulate_button |
| 87 |
* @window: Gdk window to simulate a button event for. |
| 88 |
* @x: x coordinate within @window for the button event. |
| 89 |
* @y: y coordinate within @window for the button event. |
| 90 |
* @button: Number of the pointer button for the event, usually 1, 2 or 3. |
| 91 |
* @modifiers: Keyboard modifiers the event is setup with. |
| 92 |
* @button_pressrelease: either %GDK_BUTTON_PRESS or %GDK_BUTTON_RELEASE |
| 93 |
* |
| 94 |
* This function is intended to be used in Gtk+ test programs. |
| 95 |
* It will warp the mouse pointer to the given (@x,@y) corrdinates |
| 96 |
* within @window and simulate a button press or release event. |
| 97 |
* Because the mouse pointer needs to be warped to the target |
| 98 |
* location, use of this function outside of test programs that |
| 99 |
* run in their own virtual windowing system (e.g. Xvfb) is not |
| 100 |
* recommended. |
| 101 |
* Also, gtk_test_simulate_button() is a fairly low level function, |
| 102 |
* for most testing purposes, gtk_test_widget_click() is the right |
| 103 |
* function to call which will generate a button press event followed |
| 104 |
* by its accompanying button release event. |
| 105 |
* |
| 106 |
* Returns: wether all actions neccessary for a button event simulation were carried out successfully. |
| 107 |
**/ |
| 108 |
gboolean |
| 109 |
gdk_test_simulate_button (GdkWindow *window, |
| 110 |
gint x, |
| 111 |
gint y, |
| 112 |
guint button, /*1..3*/ |
| 113 |
GdkModifierType modifiers, |
| 114 |
GdkEventType button_pressrelease) |
| 115 |
{ |
| 116 |
g_return_val_if_fail (button_pressrelease == GDK_BUTTON_PRESS || button_pressrelease == GDK_BUTTON_RELEASE, FALSE); |
| 117 |
g_return_val_if_fail (window != NULL, FALSE); |
| 118 |
|
| 119 |
if (!GDK_WINDOW_IS_MAPPED (window)) |
| 120 |
return FALSE; |
| 121 |
|
| 122 |
/* FIXME: Implement. */ |
| 123 |
|
| 124 |
return FALSE; |
| 125 |
} |