summaryrefslogtreecommitdiff
path: root/src/driclient/src/test.c
blob: 15f75d928b683aba5f7039b94bbd3634a699b1d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <assert.h>
#include <stdio.h>
#include "driclient.h"

int main(int argc, char **argv)
{
	Display		*dpy;
	Window		root, window;
	
	dri_screen_t	*screen;
	dri_drawable_t	*dri_drawable;
	dri_context_t	*context;
	
	dpy = XOpenDisplay(NULL);
	root = XDefaultRootWindow(dpy);
	window = XCreateSimpleWindow(dpy, root, 0, 0, 100, 100, 0, 0, 0);

	XSelectInput(dpy, window, 0);
	XMapWindow(dpy, window);
	XSync(dpy, 0);
	
	assert(driCreateScreen(dpy, 0, &screen, NULL) == 0);
	assert(driCreateDrawable(screen, window, &dri_drawable) == 0);
	assert(driCreateContext(screen, XDefaultVisual(dpy, 0), &context) == 0);
	assert(driUpdateDrawableInfo(dri_drawable) == 0);
	
	DRI_VALIDATE_DRAWABLE_INFO(screen, dri_drawable);
	
	assert(drmGetLock(screen->fd, context->drm_context, 0) == 0);
	assert(drmUnlock(screen->fd, context->drm_context) == 0);
	
	assert(driDestroyContext(context) == 0);
	assert(driDestroyDrawable(dri_drawable) == 0);
	assert(driDestroyScreen(screen) == 0);
	
	XDestroyWindow(dpy, window);
	XCloseDisplay(dpy);
	
	return 0;
}