diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2024-01-04 12:30:20 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2024-01-09 09:49:54 +1000 |
commit | b6931f2f5fab52dbb0c09e02ebb8315b3516e01b (patch) | |
tree | 00b2f97be4a778aeeff40c1427eedee58d7d9aac /test | |
parent | 2cee5fb36cdf98488422d6c85f0076e3a70a3ca4 (diff) |
test: fix the xtest device test to show the dependency
These two tests were dependent on each other, the second test relied on
the xtest devices created in the first test. Let's move the bits that
are shared out into the main function instead to illustrate this better.
This lets us add a call to CloseDownDevices() that will remove the leaks
in this set of tests.
Diffstat (limited to 'test')
-rw-r--r-- | test/xtest.c | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/test/xtest.c b/test/xtest.c index 12433afc4..171f285f6 100644 --- a/test/xtest.c +++ b/test/xtest.c @@ -62,34 +62,6 @@ device_cursor_cleanup(DeviceIntPtr dev, ScreenPtr screen) static void xtest_init_devices(void) { - ScreenRec screen = {0}; - ClientRec server_client = {0}; - WindowRec root = {{0}}; - WindowOptRec optional = {0}; - - /* random stuff that needs initialization */ - root.drawable.id = 0xab; - root.optional = &optional; - screen.root = &root; - screenInfo.numScreens = 1; - screenInfo.screens[0] = &screen; - screen.myNum = 0; - screen.id = 100; - screen.width = 640; - screen.height = 480; - screen.DeviceCursorInitialize = device_cursor_init; - screen.DeviceCursorCleanup = device_cursor_cleanup; - dixResetPrivates(); - serverClient = &server_client; - InitClient(serverClient, 0, (void *) NULL); - if (!InitClientResources(serverClient)) /* for root resources */ - FatalError("couldn't init server resources"); - InitAtoms(); - SyncExtensionInit(); - - /* this also inits the xtest devices */ - InitCoreDevices(); - assert(xtestpointer); assert(xtestkeyboard); assert(IsXTestDevice(xtestpointer, NULL)); @@ -135,8 +107,38 @@ xtest_properties(void) int xtest_test(void) { + ScreenRec screen = {0}; + ClientRec server_client = {0}; + WindowRec root = {{0}}; + WindowOptRec optional = {0}; + + /* random stuff that needs initialization */ + root.drawable.id = 0xab; + root.optional = &optional; + screen.root = &root; + screenInfo.numScreens = 1; + screenInfo.screens[0] = &screen; + screen.myNum = 0; + screen.id = 100; + screen.width = 640; + screen.height = 480; + screen.DeviceCursorInitialize = device_cursor_init; + screen.DeviceCursorCleanup = device_cursor_cleanup; + dixResetPrivates(); + serverClient = &server_client; + InitClient(serverClient, 0, (void *) NULL); + if (!InitClientResources(serverClient)) /* for root resources */ + FatalError("couldn't init server resources"); + InitAtoms(); + SyncExtensionInit(); + + /* this also inits the xtest devices */ + InitCoreDevices(); + xtest_init_devices(); xtest_properties(); + CloseDownDevices(); + return 0; } |