VirtualBox

source: vbox/trunk/src/VBox/GuestHost/SharedClipboard/testcase/tstClipboardGH-X11Smoke.cpp@ 96407

Last change on this file since 96407 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1/* $Id: tstClipboardGH-X11Smoke.cpp 96407 2022-08-22 17:43:14Z vboxsync $ */
2/** @file
3 * Shared Clipboard guest/host X11 code smoke tests.
4 */
5
6/*
7 * Copyright (C) 2011-2022 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28/* This is a simple test case that just starts a copy of the X11 clipboard
29 * backend, checks the X11 clipboard and exits. If ever needed I will add an
30 * interactive mode in which the user can read and copy to the clipboard from
31 * the command line. */
32
33#include <iprt/assert.h>
34#include <iprt/env.h>
35#include <iprt/err.h>
36#include <iprt/test.h>
37
38#include <VBox/GuestHost/SharedClipboard.h>
39#include <VBox/GuestHost/SharedClipboard-x11.h>
40#include <VBox/GuestHost/clipboard-helper.h>
41
42
43static DECLCALLBACK(int) tstShClReportFormatsCallback(PSHCLCONTEXT pCtx, uint32_t fFormats, void *pvUser)
44{
45 RT_NOREF(pCtx, fFormats, pvUser);
46 return VINF_SUCCESS;
47}
48
49static DECLCALLBACK(int) tstShClOnRequestDataFromSourceCallback(PSHCLCONTEXT pCtx, SHCLFORMAT uFmt, void **ppv, uint32_t *pcb, void *pvUser)
50{
51 RT_NOREF(pCtx, uFmt, ppv, pcb, pvUser);
52 return VERR_NO_DATA;
53}
54
55static DECLCALLBACK(int) tstShClOnSendDataToDest(PSHCLCONTEXT pCtx, void *pv, uint32_t cb, void *pvUser)
56{
57 RT_NOREF(pCtx, pv, cb, pvUser);
58 return VINF_SUCCESS;
59}
60
61int main()
62{
63 /*
64 * Init the runtime, test and say hello.
65 */
66 RTTEST hTest;
67 int rc = RTTestInitAndCreate("tstClipboardGH-X11Smoke", &hTest);
68 if (rc)
69 return rc;
70 RTTestBanner(hTest);
71
72 /*
73 * Run the test.
74 */
75 rc = VINF_SUCCESS;
76 /* We can't test anything without an X session, so just return success
77 * in that case. */
78 if (!RTEnvExist("DISPLAY"))
79 {
80 RTTestPrintf(hTest, RTTESTLVL_INFO,
81 "X11 not available, not running test\n");
82 return RTTestSummaryAndDestroy(hTest);
83 }
84
85 SHCLCALLBACKS Callbacks;
86 RT_ZERO(Callbacks);
87 Callbacks.pfnReportFormats = tstShClReportFormatsCallback;
88 Callbacks.pfnOnRequestDataFromSource = tstShClOnRequestDataFromSourceCallback;
89 Callbacks.pfnOnSendDataToDest = tstShClOnSendDataToDest;
90
91 SHCLX11CTX X11Ctx;
92 rc = ShClX11Init(&X11Ctx, &Callbacks, NULL /* pParent */, false);
93 AssertRCReturn(rc, 1);
94 rc = ShClX11ThreadStart(&X11Ctx, false /* fGrab */);
95 AssertRCReturn(rc, 1);
96 /* Give the clipboard time to synchronise. */
97 RTThreadSleep(500);
98 rc = ShClX11ThreadStop(&X11Ctx);
99 AssertRCReturn(rc, 1);
100 ShClX11Destroy(&X11Ctx);
101 return RTTestSummaryAndDestroy(hTest);
102}
103
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette