summaryrefslogtreecommitdiff
path: root/src/tests/test-utils.h
blob: 61250a7982b3cd86b0d2fc82d5c861353ead894a (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */

/*
 * Copyright (C) 2017 Red Hat, Inc.
 *
 * This program 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 2 of the
 * License, or (at your option) any later version.
 *
 * This program 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 this program; if not, see <http://www.gnu.org/licenses/>.
 */

#ifndef TEST_UTILS_H
#define TEST_UTILS_H

#include <glib.h>
#include <X11/Xlib.h>
#include <X11/extensions/sync.h>

#include "meta/window.h"

#define TEST_RUNNER_ERROR test_runner_error_quark ()

typedef enum
{
  TEST_RUNNER_ERROR_BAD_COMMAND,
  TEST_RUNNER_ERROR_RUNTIME_ERROR,
  TEST_RUNNER_ERROR_ASSERTION_FAILED
} TestRunnerError;

GQuark test_runner_error_quark (void);

typedef struct _AsyncWaiter AsyncWaiter;
typedef struct _TestClient TestClient;

void test_init (int    argc,
                char **argv);

gboolean async_waiter_alarm_filter (AsyncWaiter           *waiter,
                                    MetaDisplay           *display,
                                    XSyncAlarmNotifyEvent *event);

void async_waiter_set_and_wait (AsyncWaiter *waiter);

AsyncWaiter * async_waiter_new (void);

void async_waiter_destroy (AsyncWaiter *waiter);

char * test_client_get_id (TestClient *client);

gboolean test_client_alarm_filter (TestClient            *client,
                                   MetaDisplay           *display,
                                   XSyncAlarmNotifyEvent *event);

gboolean test_client_wait (TestClient *client,
                           GError    **error);

gboolean test_client_do (TestClient *client,
                         GError   **error,
                         ...) G_GNUC_NULL_TERMINATED;

MetaWindow * test_client_find_window (TestClient *client,
                                      const char *window_id,
                                      GError    **error);

gboolean test_client_quit (TestClient *client,
                           GError    **error);

TestClient * test_client_new (const char          *id,
                              MetaWindowClientType type,
                              GError             **error);

void test_client_destroy (TestClient *client);

#endif /* TEST_UTILS_H */