VirtualBox

Changeset 97283 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 24, 2022 4:27:51 PM (2 years ago)
Author:
vboxsync
Message:

Shared Clipboard/testcase: Make use of now-available SharedClipboardWinDataWrite() with the HGCM mocking framework on Windows. Also contains some Windows-related test data adjustments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedClipboard/testcase/tstClipboardMockHGCM.cpp

    r97275 r97283  
    3232#ifdef RT_OS_LINUX
    3333# include <VBox/GuestHost/SharedClipboard-x11.h>
     34#endif
     35#ifdef RT_OS_WINDOWS
     36# include <VBox/GuestHost/SharedClipboard-win.h>
    3437#endif
    3538
     
    458461    {
    459462        case VBOX_SHCL_FMT_UNICODETEXT:
     463#ifndef RT_OS_WINDOWS /** @todo Not sure about OS/2. */
    460464            cbToRead *= sizeof(RTUTF16);
     465#endif
    461466            break;
    462467
     
    501506    if (cbRead == cbToRead)
    502507    {
    503         PRTUTF16 pwszSrc;
     508#ifndef RT_OS_WINDOWS /** @todo Not sure about OS/2. */
     509        PRTUTF16 pwszSrc = NULL;
    504510        RTTEST_CHECK(g_hTest, RT_SUCCESS(RTStrToUtf16((const char *)pTask->pvData, &pwszSrc)));
    505511        RTTEST_CHECK_MSG(g_hTest, memcmp(pwszSrc, pabDst, cbRead) == 0, (g_hTest, "Read data does not match host data\n"));
    506512        RTUtf16Free(pwszSrc);
     513#else
     514        RTTEST_CHECK_MSG(g_hTest, memcmp(pTask->pvData, pabDst, cbRead) == 0, (g_hTest, "Read data does not match host data\n"));
     515#endif
    507516    }
    508517
     
    553562{
    554563    RT_NOREF(ppvCtx);
    555 
    556 #if defined (RT_OS_LINUX) || defined (RT_OS_SOLARIS)
    557     /* Initialize the Shared Clipboard backend callbacks. */
    558     PSHCLBACKEND pBackend = ShClSvcGetBackend();
    559 
    560     SHCLCALLBACKS ShClCallbacks;
    561     RT_ZERO(ShClCallbacks);
    562     ShClCallbacks.pfnReportFormats   = tstTestReadFromHost_ReportFormatsCallback;
    563     ShClCallbacks.pfnOnClipboardRead = tstTestReadFromHost_OnClipboardReadCallback;
    564     ShClBackendSetCallbacks(pBackend, &ShClCallbacks);
    565 #endif /* defined (RT_OS_LINUX) || defined (RT_OS_SOLARIS) */
    566564
    567565    /* Set the right clipboard mode, so that the guest can read from the host. */
     
    585583    pTask->cbData++; /* Add terminating zero. */
    586584#else
    587     pTask->pvData      = tstGenerateUtf16StringA((uint32_t)(pTask->cbData / sizeof(RTUTF16)));
     585    pTask->pvData      = tstGenerateUtf16StringA((uint32_t)(pTask->cbData /* We use bytes == chars here */));
     586    pTask->cbData     *= sizeof(RTUTF16);
    588587    pTask->cbData     += sizeof(RTUTF16); /* Add terminating zero. */
    589588#endif
    590589    pTask->cbProcessed = 0;
    591590
     591    int rc = VINF_SUCCESS;
     592
     593#if defined (RT_OS_LINUX) || defined (RT_OS_SOLARIS)
     594    /* Initialize the Shared Clipboard backend callbacks. */
     595    PSHCLBACKEND pBackend = ShClSvcGetBackend();
     596
     597    SHCLCALLBACKS ShClCallbacks;
     598    RT_ZERO(ShClCallbacks);
     599    ShClCallbacks.pfnReportFormats   = tstTestReadFromHost_ReportFormatsCallback;
     600    ShClCallbacks.pfnOnClipboardRead = tstTestReadFromHost_OnClipboardReadCallback;
     601    ShClBackendSetCallbacks(pBackend, &ShClCallbacks);
     602#elif defined (RT_OS_WINDOWS)
     603    rc = SharedClipboardWinOpen(GetDesktopWindow());
     604    if (RT_SUCCESS(rc))
     605    {
     606        rc = SharedClipboardWinDataWrite(CF_UNICODETEXT, pTask->pvData, (uint32_t)pTask->cbData);
     607        SharedClipboardWinClose();
     608    }
     609#endif /* defined (RT_OS_LINUX) || defined (RT_OS_SOLARIS) */
     610
    592611    RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Host data (%RU32):\n%.*Rhxd\n", pTask->cbData, pTask->cbData, pTask->pvData);
    593     return VINF_SUCCESS;
     612    return rc;
    594613}
    595614
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