test: expose the default screen to tests, some cleanup work.
Provide common #define for invalid window IDs. Init the sprite's hotPhys, provide a common #define for the initial sprite position. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
61a6e1f074
commit
1b7858e846
|
@ -32,6 +32,7 @@
|
|||
#include "protocol-common.h"
|
||||
|
||||
struct devices devices;
|
||||
ScreenRec screen;
|
||||
WindowRec root;
|
||||
WindowRec window;
|
||||
|
||||
|
@ -49,11 +50,16 @@ static void fake_init_sprite(DeviceIntPtr dev)
|
|||
sprite->spriteTrace = xcalloc(sprite->spriteTraceSize, sizeof(WindowPtr));
|
||||
sprite->spriteTraceGood = 1;
|
||||
sprite->spriteTrace[0] = &root;
|
||||
sprite->hot.x = 100;
|
||||
sprite->hot.y = 200;
|
||||
sprite->hotPhys.x = 100;
|
||||
sprite->hotPhys.y = 200;
|
||||
sprite->hot.x = SPRITE_X;
|
||||
sprite->hot.y = SPRITE_Y;
|
||||
sprite->hotPhys.x = sprite->hot.x;
|
||||
sprite->hotPhys.y = sprite->hot.y;
|
||||
sprite->win = &window;
|
||||
sprite->hotPhys.pScreen = &screen;
|
||||
sprite->physLimits.x1 = 0;
|
||||
sprite->physLimits.y1 = 0;
|
||||
sprite->physLimits.x2 = screen.width;
|
||||
sprite->physLimits.y2 = screen.height;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -132,10 +138,9 @@ void init_window(WindowPtr window, WindowPtr parent, int id)
|
|||
|
||||
/* Needed for the screen setup, otherwise we crash during sprite initialization */
|
||||
static Bool device_cursor_init(DeviceIntPtr dev, ScreenPtr screen) { return TRUE; }
|
||||
static Bool set_cursor_pos(DeviceIntPtr dev, ScreenPtr screen, int x, int y, Bool event) { return TRUE; };
|
||||
void init_simple(void)
|
||||
{
|
||||
static ScreenRec screen;
|
||||
|
||||
screenInfo.arraySize = MAXSCREENS;
|
||||
screenInfo.numScreens = 1;
|
||||
screenInfo.screens[0] = &screen;
|
||||
|
@ -145,6 +150,7 @@ void init_simple(void)
|
|||
screen.width = 640;
|
||||
screen.height = 480;
|
||||
screen.DeviceCursorInitialize = device_cursor_init;
|
||||
screen.SetCursorPosition = set_cursor_pos;
|
||||
|
||||
dixResetPrivates();
|
||||
XInputExtensionInit();
|
||||
|
|
|
@ -66,6 +66,12 @@ extern int BadDevice;
|
|||
#define ROOT_WINDOW_ID 0x10
|
||||
/* default client window id */
|
||||
#define CLIENT_WINDOW_ID 0x100001
|
||||
/* invalid window ID. use for BadWindow checks. */
|
||||
#define INVALID_WINDOW_ID 0x111111
|
||||
/* initial fake sprite position */
|
||||
#define SPRITE_X 100
|
||||
#define SPRITE_Y 200
|
||||
|
||||
|
||||
/* Various structs used throughout the tests */
|
||||
|
||||
|
@ -97,6 +103,10 @@ extern void *userdata;
|
|||
*/
|
||||
void (*reply_handler)(ClientPtr client, int len, char *data, void *userdata);
|
||||
|
||||
/**
|
||||
* The default screen used for the windows. Initialized by init_simple().
|
||||
*/
|
||||
extern ScreenRec screen;
|
||||
/**
|
||||
* Semi-initialized root window. initialized by init().
|
||||
*/
|
||||
|
|
|
@ -41,8 +41,6 @@
|
|||
#include "protocol-common.h"
|
||||
#include <glib.h>
|
||||
|
||||
#define FAKE_WINDOW_ID 12345
|
||||
|
||||
struct {
|
||||
int cp_is_set;
|
||||
DeviceIntPtr dev;
|
||||
|
@ -123,8 +121,8 @@ static void test_XIGetClientPointer(void)
|
|||
|
||||
client_request = init_client(request.length, &request);
|
||||
|
||||
g_test_message("Testing invalid window 12345");
|
||||
request.win = FAKE_WINDOW_ID;
|
||||
g_test_message("Testing invalid window");
|
||||
request.win = INVALID_WINDOW_ID;
|
||||
request_XIGetClientPointer(&client_request, &request, BadWindow);
|
||||
|
||||
test_data.cp_is_set = FALSE;
|
||||
|
|
|
@ -127,8 +127,8 @@ static void test_XISetClientPointer(void)
|
|||
request_XISetClientPointer(&request, Success);
|
||||
g_assert(client_request.clientPtr->id == 2);
|
||||
|
||||
g_test_message("Testing invalid window 12345");
|
||||
request.win = 12345;
|
||||
g_test_message("Testing invalid window");
|
||||
request.win = INVALID_WINDOW_ID;
|
||||
request.deviceid = devices.vcp->id;
|
||||
request_XISetClientPointer(&request, BadWindow);
|
||||
|
||||
|
|
Loading…
Reference in New Issue