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
83
84
85
86
87
88
89
90
91
92
93
94
|
/*
* Copyright (C) 2021 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
*/
#include "config.h"
#include "tests/native-screen-cast.h"
#include <errno.h>
#include <gio/gio.h>
#include <unistd.h>
#include "meta/util.h"
static void
test_client_exited (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
GError *error = NULL;
if (!g_subprocess_wait_finish (G_SUBPROCESS (source_object),
result,
&error))
g_error ("Screen cast test client exited with an error: %s", error->message);
g_main_loop_quit (user_data);
}
static void
meta_test_screen_cast_record_virtual (void)
{
GSubprocessLauncher *launcher;
g_autofree char *test_client_path = NULL;
GError *error = NULL;
GSubprocess *subprocess;
GMainLoop *loop;
launcher = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_NONE);
meta_add_verbose_topic (META_DEBUG_SCREEN_CAST);
test_client_path = g_test_build_filename (G_TEST_BUILT,
"src",
"tests",
"mutter-screen-cast-client",
NULL);
g_subprocess_launcher_setenv (launcher,
"XDG_RUNTIME_DIR", getenv ("XDG_RUNTIME_DIR"),
TRUE);
g_subprocess_launcher_setenv (launcher,
"G_MESSAGES_DEBUG", "all",
TRUE);
subprocess = g_subprocess_launcher_spawn (launcher,
&error,
test_client_path,
NULL);
if (!subprocess)
g_error ("Failed to launch screen cast test client: %s", error->message);
loop = g_main_loop_new (NULL, FALSE);
g_subprocess_wait_check_async (subprocess,
NULL,
test_client_exited,
loop);
g_main_loop_run (loop);
g_assert_true (g_subprocess_get_successful (subprocess));
g_object_unref (subprocess);
meta_remove_verbose_topic (META_DEBUG_SCREEN_CAST);
}
void
init_screen_cast_tests (void)
{
g_test_add_func ("/backends/native/screen-cast/record-virtual",
meta_test_screen_cast_record_virtual);
}
|