12to11/tests/test_harness.h
hujianwei 5d033bc93f Add new damage test and unify buffer release code in xdg_surface
* 12to11-test.xml (test_surface): <description>: Document when
frame callbacks are run.
* 12to11.c (HandleCmdline): Accept new arg `printsocket'.
(XLMain): Pass socket to HandleCmdline.
* 12to11.man: Document new `printsocket' option.
* mime0.awk:
* mime1.awk:
* mime2.awk:
* mime3.awk:
* mime4.awk: Fix typos in copyright blurb.
* test.c (NoteBounds): Sync with X server after XResizeWindow.
(Commit): Run frame callbacks after unmap as well.
(GetTestSurface): Make windows override redirect.

* tests/Imakefile (SRCS2, OBJS2): New program.
(PROGRAMS): Add damage_test.
(damage_test): New program.  Depend on SRCS2.
* tests/README: Improve documentation on how to run tests.
* tests/simple_test.c (test_names): New list.
(LAST_TEST): New define.
(verify_single_step): Complete test upon last test being run.
(test_single_step): Submit correct surface damage.
(test_next_step): New function.  Does nothing here.
(handle_wl_callback_done): Run the next test.
(submit_surface_damage): New function.
* tests/svnignore.txt: Add damage_test and Makefile.bak.
* tests/test_harness.c (test_complete): New function.
* tests/test_harness.h: New prototypes.
* xdg_surface.c (struct _XdgRole): Use a buffer release helper.
(struct _ReleaseLaterRecord, DeleteRecord, FreeRecords)
(AddRecordAfter): Delete unused structs and functions.
(RunFrameCallbacksConditionally, BufferIdleCallback)
(ReleaseBacking, ReleaseBuffer, XLGetXdgSurface): Use and free
buffer release helper; run frame callbacks from its callback.
2022-11-04 05:36:10 +00:00

93 lines
2.7 KiB
C

/* Tests for the Wayland compositor running on the X server.
Copyright (C) 2022 to various contributors.
This file is part of 12to11.
12to11 is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
12to11 is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with 12to11. If not, see <https://www.gnu.org/licenses/>. */
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
#include <limits.h>
#include <wayland-client.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "12to11-test.h"
struct test_display
{
/* The wayland display. */
struct wl_display *display;
/* The X display. */
Display *x_display;
/* List of pixmap formats. */
XPixmapFormatValues *pixmap_formats;
/* Number of pixmap formats. */
int num_pixmap_formats;
/* The registry and various Wayland interfaces. */
struct wl_registry *registry;
struct wl_compositor *compositor;
struct wl_shm *shm;
struct test_manager *test_manager;
/* Test interfaces. */
struct test_interface *interfaces;
/* The number of such interfaces. */
int num_test_interfaces;
};
struct test_interface
{
/* The name of the interface. */
const char *interface;
/* Pointer to the interface data. */
void *data;
/* Pointer to the interface. */
struct wl_interface *c_interface;
/* The wanted version. */
uint32_t version;
};
extern void die (const char *) __attribute__ ((noreturn));
extern struct test_display *open_test_display (struct test_interface *, int);
extern int get_shm_file_descriptor (void);
extern size_t get_image_stride (struct test_display *, int, int);
extern struct wl_buffer *upload_image_data (struct test_display *,
const char *, int, int,
int);
extern void report_test_failure (const char *, ...)
__attribute__ ((noreturn, format (gnu_printf, 1, 2)));
extern void test_log (const char *, ...)
__attribute__ ((format (gnu_printf, 1, 2)));
extern bool make_test_surface (struct test_display *, struct wl_surface **,
struct test_surface **);
extern struct wl_buffer *load_png_image (struct test_display *, const char *);
extern void verify_image_data (struct test_display *, Window, const char *);
extern void test_init (void);
extern void test_complete (void) __attribute__ ((noreturn));
#define ARRAYELTS(arr) (sizeof (arr) / sizeof (arr)[0])