summaryrefslogtreecommitdiff
path: root/server/tests/test_display_streaming.c
blob: b4fe01368702d1cf8a9e5bb2af0ac57086a51b65 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* Do repeated updates to the same rectangle to trigger stream creation.
 *
 * TODO: check that stream actually starts programatically (maybe stap?)
 * TODO: stop updating same rect, check (prog) that stream stops
 */

#include <config.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
#include "test_display_base.h"

static int sized;

void create_update(Command *command)
{
    static int count = 0;
    CommandDrawSolid *cmd = &command->solid;
    cmd->surface_id = 0;

    cmd->bbox.left = 0;
    cmd->bbox.right = test_get_width();
    cmd->bbox.top = 0;
    cmd->color = 0xffff00 + ((count * 10) % 256);
    assert(test_get_height() > 50);
    cmd->bbox.bottom = test_get_height() - 50;
    if (count < 20) {
    } else if (sized && count % 5 == 0) {
        cmd->bbox.bottom = test_get_height();
        cmd->color = 0xff;
    }
    count++;
    printf("%d %d\n", count, cmd->bbox.bottom);
}

static Command commands[] = {
    {SIMPLE_DRAW_SOLID, create_update},
};

SpiceCoreInterface *core;
SpiceServer *server;

int main(int argc, char **argv)
{
    int i;
    spice_test_config_parse_args(argc, argv);
    sized = 0;
    for (i = 1 ; i < argc; ++i) {
        if (strcmp(argv[i], "sized") == 0) {
            sized = 1;
        }
    }
    core = basic_event_loop_init();
    server = test_init(core);
    spice_server_set_streaming_video(server, SPICE_STREAM_VIDEO_ALL);
    test_add_display_interface(server);
    test_set_command_list(commands, COUNT(commands));
    basic_event_loop_mainloop();
    return 0;
}