VirtualBox

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

Last change on this file since 95012 was 93504, checked in by vboxsync, 3 years ago

Shared Clipboard: Implemented backend callbacks and a dedicated backend context, together with a new testcase which mocks HGCM to also test the guest-side clipboard code (disabled by default for now). Work in progress, only tested on Linux so far [testcase fixes].

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

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