From bcd7c4e0977a80059193819fe28832c50678eefc Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Fri, 17 May 2013 10:36:17 -0400 Subject: server/tests: test_display_width_stride --- server/tests/test_display_width_stride.c | 92 ++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 server/tests/test_display_width_stride.c (limited to 'server/tests/test_display_width_stride.c') diff --git a/server/tests/test_display_width_stride.c b/server/tests/test_display_width_stride.c new file mode 100644 index 00000000..20de57a5 --- /dev/null +++ b/server/tests/test_display_width_stride.c @@ -0,0 +1,92 @@ +/** + * Recreate the primary surface endlessly. + */ + +#include +#include +#include +#include "test_display_base.h" + +SpiceTimer *ping_timer; + +void show_channels(SpiceServer *server); + +int ping_ms = 100; + +void pinger(void *opaque) +{ + Test *test = opaque; + // show_channels is not thread safe - fails if disconnections / connections occur + //show_channels(server); + + test->core->timer_start(ping_timer, ping_ms); +} + +static int g_surface_id = 1; +static uint8_t *g_surface_data; + +void set_draw_parameters(Test *test, Command *command) +{ + static int count = 17; + CommandDrawSolid *solid = &command->solid; + + solid->bbox.top = 0; + solid->bbox.left = 0; + solid->bbox.bottom = 20; + solid->bbox.right = count; + solid->surface_id = g_surface_id; + count++; +} + +void set_surface_params(Test *test, Command *command) +{ + CommandCreateSurface *create = &command->create_surface; + + // UGLY + if (g_surface_data) { + exit(0); + } + create->format = SPICE_SURFACE_FMT_8_A; + create->width = 128; + create->height = 128; + g_surface_data = realloc(g_surface_data, create->width * create->height * 1); + create->surface_id = g_surface_id; + create->data = g_surface_data; +} + +static Command commands[] = { + {SIMPLE_CREATE_SURFACE, set_surface_params}, + {SIMPLE_DRAW_SOLID, set_draw_parameters}, + {SIMPLE_DRAW_SOLID, set_draw_parameters}, + {SIMPLE_DRAW_SOLID, set_draw_parameters}, + {SIMPLE_DRAW_SOLID, set_draw_parameters}, + {SIMPLE_DRAW_SOLID, set_draw_parameters}, + {SIMPLE_DRAW_SOLID, set_draw_parameters}, + {SIMPLE_DRAW_SOLID, set_draw_parameters}, + {SIMPLE_DRAW_SOLID, set_draw_parameters}, + {SIMPLE_DRAW_SOLID, set_draw_parameters}, +}; + +void on_client_connected(Test *test) +{ + test_set_command_list(test, commands, COUNT(commands)); +} + +int main(void) +{ + SpiceCoreInterface *core; + Test *test; + + core = basic_event_loop_init(); + test = test_new(core); + test->on_client_connected = on_client_connected; + //spice_server_set_image_compression(server, SPICE_IMAGE_COMPRESS_OFF); + test_add_display_interface(test); + + ping_timer = core->timer_add(pinger, test); + core->timer_start(ping_timer, ping_ms); + + basic_event_loop_mainloop(); + + return 0; +} -- cgit