test: switch the remaining wrapped functions to use the macros
dixLookupWindow and dixLookupClient have a test-global default implementation because overriding that in ever test doesn't make sense.
This commit is contained in:
parent
7e9d167c9c
commit
3c5eaedaf9
|
@ -44,12 +44,5 @@ const testfunc_t* protocol_xiwarppointer_test(void);
|
|||
const testfunc_t* protocol_eventconvert_test(void);
|
||||
const testfunc_t* xi2_test(void);
|
||||
|
||||
#ifndef INSIDE_PROTOCOL_COMMON
|
||||
|
||||
extern int enable_XISetEventMask_wrap;
|
||||
extern int enable_GrabButton_wrap;
|
||||
|
||||
#endif /* INSIDE_PROTOCOL_COMMON */
|
||||
|
||||
#endif /* TESTS_H */
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include "syncsrv.h"
|
||||
#include <X11/extensions/XI2.h>
|
||||
|
||||
#define INSIDE_PROTOCOL_COMMON
|
||||
#include "protocol-common.h"
|
||||
|
||||
struct devices devices;
|
||||
|
@ -46,13 +45,6 @@ WindowRec root;
|
|||
WindowRec window;
|
||||
static ClientRec server_client;
|
||||
|
||||
void *global_userdata;
|
||||
|
||||
void (*reply_handler) (ClientPtr client, int len, char *data, void *userdata);
|
||||
|
||||
int enable_GrabButton_wrap = 1;
|
||||
int enable_XISetEventMask_wrap = 1;
|
||||
|
||||
static void
|
||||
fake_init_sprite(DeviceIntPtr dev)
|
||||
{
|
||||
|
@ -292,13 +284,35 @@ WRAP_FUNCTION(WriteToClient, void, ClientPtr client, int len, void *data)
|
|||
IMPLEMENT_WRAP_FUNCTION(WriteToClient, client, len, data);
|
||||
}
|
||||
|
||||
WRAP_FUNCTION(XISetEventMask, int,
|
||||
DeviceIntPtr dev, WindowPtr win, ClientPtr client,
|
||||
int len, unsigned char *mask)
|
||||
{
|
||||
IMPLEMENT_WRAP_FUNCTION_WITH_RETURN(XISetEventMask, dev, win, client, len, mask);
|
||||
}
|
||||
|
||||
WRAP_FUNCTION(AddResource, Bool, XID id, RESTYPE type, void *value)
|
||||
{
|
||||
IMPLEMENT_WRAP_FUNCTION_WITH_RETURN(AddResource, id, type, value);
|
||||
}
|
||||
|
||||
WRAP_FUNCTION(GrabButton, int,
|
||||
ClientPtr client, DeviceIntPtr dev,
|
||||
DeviceIntPtr modifier_device, int button,
|
||||
GrabParameters *param, enum InputLevel grabtype,
|
||||
GrabMask *mask)
|
||||
{
|
||||
IMPLEMENT_WRAP_FUNCTION_WITH_RETURN(GrabButton, client, dev, modifier_device,
|
||||
button, param, grabtype, mask);
|
||||
}
|
||||
|
||||
/* dixLookupWindow requires a lot of setup not necessary for this test.
|
||||
* Simple wrapper that returns either one of the fake root window or the
|
||||
* fake client window. If the requested ID is neither of those wanted,
|
||||
* return whatever the real dixLookupWindow does.
|
||||
*/
|
||||
int
|
||||
__wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access)
|
||||
WRAP_FUNCTION(dixLookupWindow, int,
|
||||
WindowPtr *win, XID id, ClientPtr client, Mask access)
|
||||
{
|
||||
if (id == root.drawable.id) {
|
||||
*win = &root;
|
||||
|
@ -314,9 +328,8 @@ __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access)
|
|||
|
||||
extern ClientRec client_window;
|
||||
|
||||
int
|
||||
__wrap_dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client,
|
||||
Mask access)
|
||||
WRAP_FUNCTION(dixLookupClient, int,
|
||||
ClientPtr *pClient, XID rid, ClientPtr client, Mask access)
|
||||
{
|
||||
if (rid == ROOT_WINDOW_ID)
|
||||
return BadWindow;
|
||||
|
|
|
@ -90,17 +90,6 @@ struct devices {
|
|||
*/
|
||||
extern struct devices devices;
|
||||
|
||||
/**
|
||||
* test-specific userdata, passed into the reply handler.
|
||||
*/
|
||||
extern void *global_userdata;
|
||||
|
||||
/**
|
||||
* The reply handler called from WriteToClient. Set this handler if you need
|
||||
* to check the reply values.
|
||||
*/
|
||||
extern void (*reply_handler) (ClientPtr client, int len, char *data, void *userdata);
|
||||
|
||||
/**
|
||||
* The default screen used for the windows. Initialized by init_simple().
|
||||
*/
|
||||
|
@ -142,15 +131,4 @@ void init_window(WindowPtr window, WindowPtr parent, int id);
|
|||
*/
|
||||
void init_simple(void);
|
||||
|
||||
/* Declarations for various overrides in the test files. */
|
||||
int __wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
|
||||
int len, unsigned char *mask);
|
||||
int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client,
|
||||
Mask access);
|
||||
int __real_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client,
|
||||
Mask access);
|
||||
Bool __wrap_AddResource(XID id, RESTYPE type, void *value);
|
||||
int __wrap_dixLookupClient(ClientPtr *c, XID id, ClientPtr client, Mask access);
|
||||
int __real_dixLookupClient(ClientPtr *c, XID id, ClientPtr client, Mask access);
|
||||
|
||||
#endif /* PROTOCOL_COMMON_H */
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "protocol-common.h"
|
||||
|
||||
DECLARE_WRAP_FUNCTION(WriteToClient, void, ClientPtr client, int len, void *data);
|
||||
DECLARE_WRAP_FUNCTION(AddResource, Bool, XID id, RESTYPE type, void *value);
|
||||
|
||||
static void reply_XIGetSelectedEvents(ClientPtr client, int len, void *data);
|
||||
static void reply_XIGetSelectedEvents_data(ClientPtr client, int len, void *data);
|
||||
|
@ -66,8 +67,8 @@ static struct {
|
|||
extern ClientRec client_window;
|
||||
|
||||
/* AddResource is called from XISetSEventMask, we don't need this */
|
||||
Bool
|
||||
__wrap_AddResource(XID id, RESTYPE type, void *value)
|
||||
static Bool
|
||||
override_AddResource(XID id, RESTYPE type, void *value)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -148,9 +149,9 @@ test_XIGetSelectedEvents(void)
|
|||
unsigned char *mask;
|
||||
DeviceIntRec dev;
|
||||
|
||||
wrapped_AddResource = override_AddResource;
|
||||
|
||||
init_simple();
|
||||
enable_GrabButton_wrap = 0;
|
||||
enable_XISetEventMask_wrap = 0;
|
||||
client = init_client(0, NULL);
|
||||
|
||||
request_init(&request, XIGetSelectedEvents);
|
||||
|
|
|
@ -45,6 +45,11 @@
|
|||
#include "protocol-common.h"
|
||||
|
||||
DECLARE_WRAP_FUNCTION(WriteToClient, void, ClientPtr client, int len, void *data);
|
||||
DECLARE_WRAP_FUNCTION(GrabButton, int,
|
||||
ClientPtr client, DeviceIntPtr dev,
|
||||
DeviceIntPtr modifier_device, int button,
|
||||
GrabParameters *param, enum InputLevel grabtype,
|
||||
GrabMask *mask);
|
||||
|
||||
extern ClientRec client_window;
|
||||
static ClientRec client_request;
|
||||
|
@ -56,26 +61,16 @@ static struct test_data {
|
|||
int num_modifiers;
|
||||
} testdata;
|
||||
|
||||
int __wrap_GrabButton(ClientPtr client, DeviceIntPtr dev,
|
||||
DeviceIntPtr modifier_device, int button,
|
||||
GrabParameters *param, enum InputLevel grabtype,
|
||||
GrabMask *mask);
|
||||
int __real_GrabButton(ClientPtr client, DeviceIntPtr dev,
|
||||
DeviceIntPtr modifier_device, int button,
|
||||
GrabParameters *param, enum InputLevel grabtype,
|
||||
GrabMask *mask);
|
||||
|
||||
static void reply_XIPassiveGrabDevice_data(ClientPtr client, int len,
|
||||
void *data);
|
||||
|
||||
int
|
||||
__wrap_GrabButton(ClientPtr client, DeviceIntPtr dev,
|
||||
static int
|
||||
override_GrabButton(ClientPtr client, DeviceIntPtr dev,
|
||||
DeviceIntPtr modifier_device, int button,
|
||||
GrabParameters *param, enum InputLevel grabtype,
|
||||
GrabMask *mask)
|
||||
{
|
||||
if (!enable_GrabButton_wrap)
|
||||
__real_GrabButton(client, dev, modifier_device, button, param, grabtype, mask);
|
||||
|
||||
/* Fail every odd modifier */
|
||||
if (param->modifiers % 2)
|
||||
return BadAccess;
|
||||
|
@ -176,6 +171,8 @@ test_XIPassiveGrabDevice(void)
|
|||
xXIPassiveGrabDeviceReq *request = (xXIPassiveGrabDeviceReq *) data;
|
||||
unsigned char *mask;
|
||||
|
||||
wrapped_GrabButton = override_GrabButton;
|
||||
|
||||
init_simple();
|
||||
|
||||
request_init(request, XIPassiveGrabDevice);
|
||||
|
|
|
@ -63,21 +63,19 @@
|
|||
|
||||
#include "protocol-common.h"
|
||||
|
||||
DECLARE_WRAP_FUNCTION(XISetEventMask, int, DeviceIntPtr dev,
|
||||
WindowPtr win, ClientPtr client,
|
||||
int len, unsigned char *mask);
|
||||
|
||||
|
||||
static unsigned char *data[4096 * 20]; /* the request data buffer */
|
||||
|
||||
extern ClientRec client_window;
|
||||
|
||||
int
|
||||
__real_XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
|
||||
int len, unsigned char *mask);
|
||||
|
||||
int
|
||||
__wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
|
||||
int len, unsigned char *mask)
|
||||
static int
|
||||
override_XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
|
||||
int len, unsigned char *mask)
|
||||
{
|
||||
if (!enable_XISetEventMask_wrap)
|
||||
return __real_XISetEventMask(dev, win, client, len, mask);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
|
@ -288,6 +286,8 @@ test_XISelectEvents(void)
|
|||
xXIEventMask *mask;
|
||||
xXISelectEventsReq *req;
|
||||
|
||||
wrapped_XISetEventMask = override_XISetEventMask;
|
||||
|
||||
init_simple();
|
||||
|
||||
req = (xXISelectEventsReq *) data;
|
||||
|
|
Loading…
Reference in New Issue