spice/server/tests/test-display-resolution-changes.c
Frediano Ziglio 030ae7bbdc tests: Apply same warning level as main server code
Allow to catch minor issue with test code.
Although test usually are coded with less care than production
code the current changes required are not so extensive and
can catch different issues.
Most of the patch is making functions static to avoid warnings for
undeclared functions.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-12-06 16:16:19 +00:00

87 lines
2.2 KiB
C

/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
Copyright (C) 2009-2015 Red Hat, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
/**
* Recreate the primary surface endlessly.
*/
#include <config.h>
#include <math.h>
#include <stdlib.h>
#include "test-display-base.h"
SpiceTimer *ping_timer;
void show_channels(SpiceServer *server);
int ping_ms = 100;
static 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 void
set_primary_params(SPICE_GNUC_UNUSED Test *test, Command *command)
{
#if 0
static int toggle = 0;
if (toggle) {
*arg1 = 800;
*arg2 = 600;
} else {
*arg1 = 1024;
*arg2 = 768;
}
toggle = 1 - toggle;
#endif
static int count = 0;
command->create_primary.width = 800 + sin((float)count / 6) * 200;
command->create_primary.height = 600 + cos((float)count / 6) * 200;
count++;
}
static Command commands[] = {
{DESTROY_PRIMARY, NULL, .cb_opaque = NULL,},
{CREATE_PRIMARY, set_primary_params, .cb_opaque = NULL},
};
int main(void)
{
SpiceCoreInterface *core;
Test *test;
core = basic_event_loop_init();
test = test_new(core);
//spice_server_set_image_compression(server, SPICE_IMAGE_COMPRESSION_OFF);
test_add_display_interface(test);
test_set_command_list(test, commands, COUNT(commands));
ping_timer = core->timer_add(pinger, test);
core->timer_start(ping_timer, ping_ms);
basic_event_loop_mainloop();
return 0;
}