VirtualBox

Changeset 93504 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jan 31, 2022 4:17:01 PM (3 years ago)
Author:
vboxsync
Message:

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].

Location:
trunk/src/VBox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp

    r93497 r93504  
    18361836                                  pValReturn, pcLenReturn, piFormatReturn);
    18371837
    1838 #ifdef LOG_ENABLED
     1838#if 0 /** @todo Disabled -- crashes when running with tstClipboardGH-X11. */
    18391839    XSelectionRequestEvent* pReq =
    18401840        XtGetSelectionRequest(widget, *atomSelection, (XtRequestId)NULL);
  • trunk/src/VBox/GuestHost/SharedClipboard/testcase/tstClipboardGH-X11.cpp

    r93496 r93504  
    119119}
    120120
    121 DECLCALLBACK(int) ShClX11RequestDataCallback(PSHCLCONTEXT pCtx, SHCLFORMAT uFmt, void **ppv, uint32_t *pcb)
    122 {
    123     RT_NOREF(pCtx, uFmt);
    124     *pcb = g_tst_cbDataVBox;
    125     if (g_tst_pvDataVBox != NULL)
    126     {
    127         void *pv = RTMemDup(g_tst_pvDataVBox, g_tst_cbDataVBox);
    128         *ppv = pv;
    129         return pv != NULL ? g_tst_rcDataVBox : VERR_NO_MEMORY;
    130     }
    131     *ppv = NULL;
    132     return g_tst_rcDataVBox;
    133 }
    134 
    135121Display *XtDisplay(Widget w) { NOREF(w); return (Display *) 0xffff; }
    136122
     
    242228/* The formats currently on offer from X11 via the shared clipboard. */
    243229static uint32_t g_tst_uX11Formats = 0;
    244 
    245 DECLCALLBACK(void) ShClX11ReportFormatsCallback(PSHCLCONTEXT pCtx, SHCLFORMATS fFormats)
    246 {
    247     RT_NOREF(pCtx);
    248     g_tst_uX11Formats = fFormats;
    249 }
    250230
    251231static uint32_t tstClipQueryFormats(void)
     
    398378static char g_tst_abCompletedBuf[TESTCASE_MAX_BUF_SIZE];
    399379
    400 DECLCALLBACK(void) ShClX11ReportDataCallback(PSHCLCONTEXT pCtx, int rcCompletion,
    401                                              CLIPREADCBREQ *pReq, void *pv, uint32_t cb)
     380static DECLCALLBACK(int) tstShClReportFormatsCallback(PSHCLCONTEXT pCtx, uint32_t fFormats, void *pvUser)
     381{
     382    RT_NOREF(pCtx, pvUser);
     383    g_tst_uX11Formats = fFormats;
     384    return VINF_SUCCESS;
     385}
     386
     387static DECLCALLBACK(int) tstShClOnRequestDataFromSourceCallback(PSHCLCONTEXT pCtx, SHCLFORMAT uFmt, void **ppv, uint32_t *pcb, void *pvUser)
     388{
     389    RT_NOREF(pCtx, uFmt, pvUser);
     390    *pcb = g_tst_cbDataVBox;
     391    if (g_tst_pvDataVBox != NULL)
     392    {
     393        void *pv = RTMemDup(g_tst_pvDataVBox, g_tst_cbDataVBox);
     394        *ppv = pv;
     395        return pv != NULL ? g_tst_rcDataVBox : VERR_NO_MEMORY;
     396    }
     397    *ppv = NULL;
     398    return g_tst_rcDataVBox;
     399}
     400
     401static DECLCALLBACK(int) tstShClOnSendDataToDestCallback(PSHCLCONTEXT pCtx, void *pv, uint32_t cb, void *pvUser)
    402402{
    403403    RT_NOREF(pCtx);
     404
     405    PSHCLX11READDATAREQ pData = (PSHCLX11READDATAREQ)pvUser;
     406
    404407    if (cb <= TESTCASE_MAX_BUF_SIZE)
    405408    {
    406         g_tst_rcCompleted = rcCompletion;
     409        g_tst_rcCompleted = pData->rcCompletion;
    407410        if (cb != 0)
    408411            memcpy(g_tst_abCompletedBuf, pv, cb);
     
    411414        g_tst_rcCompleted = VERR_BUFFER_OVERFLOW;
    412415    g_tst_cbCompleted = cb;
    413     g_tst_pCompletedReq = pReq;
     416    g_tst_pCompletedReq = pData->pReq;
     417
     418    return VINF_SUCCESS;
    414419}
    415420
     
    669674     * Run the tests.
    670675     */
     676    SHCLCALLBACKS Callbacks;
     677    RT_ZERO(Callbacks);
     678    Callbacks.pfnReportFormats           = tstShClReportFormatsCallback;
     679    Callbacks.pfnOnRequestDataFromSource = tstShClOnRequestDataFromSourceCallback;
     680    Callbacks.pfnOnSendDataToDest        = tstShClOnSendDataToDestCallback;
     681
    671682    SHCLX11CTX X11Ctx;
    672     rc = ShClX11Init(&X11Ctx, NULL /* pCallbacks */, NULL /* pParent */, false /* fHeadless */);
     683    rc = ShClX11Init(&X11Ctx, &Callbacks, NULL /* pParent */, false /* fHeadless */);
    673684    AssertRCReturn(rc, RTEXITCODE_FAILURE);
    674685
     
    893904     * Headless clipboard tests
    894905     */
    895     rc = ShClX11Init(&X11Ctx, NULL /* pCallbacks */, NULL /* pParent */, true /* fHeadless */);
     906    rc = ShClX11Init(&X11Ctx, &Callbacks, NULL /* pParent */, true /* fHeadless */);
    896907    AssertRCReturn(rc, RTEXITCODE_FAILURE);
    897908
  • trunk/src/VBox/GuestHost/SharedClipboard/testcase/tstClipboardGH-X11Smoke.cpp

    r93496 r93504  
    3131
    3232
    33 DECLCALLBACK(int) ShClX11RequestDataCallback(PSHCLCONTEXT pCtx, SHCLFORMAT uFmt, void **ppv, uint32_t *pcb)
     33static DECLCALLBACK(int) tstShClReportFormatsCallback(PSHCLCONTEXT pCtx, uint32_t fFormats, void *pvUser)
    3434{
    35     RT_NOREF(pCtx, uFmt, ppv, pcb);
     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);
    3642    return VERR_NO_DATA;
    3743}
    3844
    39 DECLCALLBACK(void) ShClX11ReportFormatsCallback(PSHCLCONTEXT pCtx, SHCLFORMATS fFormats)
     45static DECLCALLBACK(int) tstShClOnSendDataToDest(PSHCLCONTEXT pCtx, void *pv, uint32_t cb, void *pvUser)
    4046{
    41     RT_NOREF(pCtx, fFormats);
    42 }
    43 
    44 DECLCALLBACK(void) ShClX11ReportDataCallback(PSHCLCONTEXT pCtx, int rcCompletion,
    45                                              CLIPREADCBREQ *pReq, void *pv, uint32_t cb)
    46 {
    47     RT_NOREF(pCtx, rcCompletion, pReq, pv, cb);
     47    RT_NOREF(pCtx, pv, cb, pvUser);
     48    return VINF_SUCCESS;
    4849}
    4950
     
    7172        return RTTestSummaryAndDestroy(hTest);
    7273    }
     74
     75    SHCLCALLBACKS Callbacks;
     76    RT_ZERO(Callbacks);
     77    Callbacks.pfnReportFormats           = tstShClReportFormatsCallback;
     78    Callbacks.pfnOnRequestDataFromSource = tstShClOnRequestDataFromSourceCallback;
     79    Callbacks.pfnOnSendDataToDest        = tstShClOnSendDataToDest;
     80
    7381    SHCLX11CTX X11Ctx;
    74     rc = ShClX11Init(&X11Ctx, NULL /* pCallbacks */, NULL /* pParent */, false);
     82    rc = ShClX11Init(&X11Ctx, &Callbacks, NULL /* pParent */, false);
    7583    AssertRCReturn(rc, 1);
    7684    rc = ShClX11ThreadStart(&X11Ctx, false /* fGrab */);
  • trunk/src/VBox/HostServices/SharedClipboard/testcase/tstClipboardMockHGCM.cpp

    r93495 r93504  
    11791179    SHCLCALLBACKS Callbacks;
    11801180    RT_ZERO(Callbacks);
    1181     Callbacks.pfnReportFormats = tstShClUserMockReportFormatsCallback;
    1182     Callbacks.pfnOnClipboardRead     = tstShClUserMockOnGetDataCallback;
     1181    Callbacks.pfnReportFormats   = tstShClUserMockReportFormatsCallback;
     1182    Callbacks.pfnOnClipboardRead = tstShClUserMockOnGetDataCallback;
    11831183
    11841184    pUsrMock->pCtx = (PSHCLCONTEXT)RTMemAllocZ(sizeof(SHCLCONTEXT));
Note: See TracChangeset for help on using the changeset viewer.

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