VirtualBox

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

最後變更 在這個檔案從103681是 103363,由 vboxsync 提交於 13 月 前

Shared Clipboard: Added a dedicated VERR_SHCLPB_NO_DATA error code, to indicate that clipboard data for a format currently is not available.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 3.2 KB
 
1/* $Id: tstClipboardGH-X11Smoke.cpp 103363 2024-02-14 17:23:47Z vboxsync $ */
2/** @file
3 * Shared Clipboard guest/host X11 code smoke tests.
4 */
5
6/*
7 * Copyright (C) 2011-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.alldomusa.eu.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/test.h>
36
37#include <VBox/err.h>
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_SHCLPB_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 RTTEST_CHECK_RC_OK(hTest, ShClX11Init(&X11Ctx, &Callbacks, NULL /* pParent */, false /* fHeadless */));
93 RTTEST_CHECK_RC_OK(hTest, ShClX11ThreadStart(&X11Ctx, false /* fGrab */));
94
95 /* Give the clipboard time to synchronise. */
96 RTThreadSleep(500);
97
98 RTTEST_CHECK_RC_OK(hTest, ShClX11ThreadStop(&X11Ctx));
99 RTTEST_CHECK_RC_OK(hTest, ShClX11Destroy(&X11Ctx));
100
101 return RTTestSummaryAndDestroy(hTest);
102}
103
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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