VirtualBox

Ignore:
Timestamp:
Jul 21, 2023 3:04:49 PM (18 months ago)
Author:
vboxsync
Message:

Shared Clipboard/X11: Enabled a minimal subset of the testcases again, to have at least a tiny bit of testing. bugref:9437

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/SharedClipboard/testcase/tstClipboardGH-X11.cpp

    r100204 r100685  
    9595static void *g_tst_pvDataVBox = NULL;
    9696static uint32_t g_tst_cbDataVBox = 0;
    97 
     97static SHCLEVENTSOURCE g_EventSource;
     98
     99#if 0
    98100/* Set empty data in the simulated VBox clipboard. */
    99101static void tstClipEmptyVBox(PSHCLX11CTX pCtx, int retval)
     
    128130    return VINF_SUCCESS;
    129131}
     132#endif
    130133
    131134Display *XtDisplay(Widget w) { NOREF(w); return (Display *) 0xffff; }
     
    244247}
    245248
     249#if 0
    246250static void tstClipInvalidateFormats(void)
    247251{
    248252    g_tst_uX11Formats = ~0;
    249253}
     254#endif
    250255
    251256/* Does our clipboard code currently own the selection? */
     
    274279}
    275280
     281#if 0
    276282void XtDisownSelection(Widget widget, Atom selection, Time time)
    277283{
     
    308314    return true;
    309315}
     316#endif
    310317
    311318/* Set the current X selection data */
     
    331338}
    332339
     340#if 0
    333341/* Configure if and how the X11 TARGETS clipboard target will fail. */
    334342static void tstClipSetTargetsFailure(void)
     
    336344    g_tst_cTargets = 0;
    337345}
     346#endif
    338347
    339348char *XtMalloc(Cardinal size)
     
    385394static int g_tst_rcCompleted = VINF_SUCCESS;
    386395static int g_tst_cbCompleted = 0;
    387 static SHCLX11REQUEST *g_tst_pCompletedReq = NULL;
     396//static SHCLX11REQUEST *g_tst_pCompletedReq = NULL;
    388397static char g_tst_abCompletedBuf[TESTCASE_MAX_BUF_SIZE];
    389398
     
    424433        g_tst_rcCompleted = VERR_BUFFER_OVERFLOW;
    425434    g_tst_cbCompleted = cb;
    426     g_tst_pCompletedReq = pData->pReq;
     435    //g_tst_pCompletedReq = pData->pReq;
    427436
    428437    return VINF_SUCCESS;
     
    447456}
    448457
     458#if 0
    449459static bool tstClipTextFormatConversion(PSHCLX11CTX pCtx)
    450460{
     
    464474    return fSuccess;
    465475}
    466 
     476#endif
     477
     478/*
    467479static void tstClipGetCompletedRequest(int *prc, char ** ppc, uint32_t *pcb, SHCLX11REQREAD **ppReq)
    468480{
     
    472484    *ppReq = g_tst_pCompletedReq;
    473485}
     486*/
    474487
    475488static void tstStringFromX11(RTTEST hTest, PSHCLX11CTX pCtx,
     
    484497    else
    485498    {
    486         char *pc;
    487         SHCLX11REQREAD *pReq = (SHCLX11REQREAD *)&pReq, *pReqRet = NULL;
    488         ShClX11ReadDataFromX11Async(pCtx, VBOX_SHCL_FMT_UNICODETEXT, pReq);
    489         int rc = VINF_SUCCESS;
    490499        uint32_t cbActual = 0;
    491         tstClipGetCompletedRequest(&rc, &pc, &cbActual, &pReqRet);
     500        uint8_t  abBuf[TESTCASE_MAX_BUF_SIZE];
     501        int rc = ShClX11ReadDataFromX11(pCtx, &g_EventSource, RT_MS_30SEC, VBOX_SHCL_FMT_UNICODETEXT, abBuf, sizeof(abBuf), &cbActual);
    492502        if (rc != rcExp)
    493             RTTestFailed(hTest, "Wrong return code, expected %Rrc, got %Rrc\n",
    494                          rcExp, rc);
    495         else if (pReqRet != pReq)
    496             RTTestFailed(hTest, "Wrong returned request data, expected %p, got %p\n",
    497                          pReq, pReqRet);
     503            RTTestFailed(hTest, "Wrong return code, expected %Rrc, got %Rrc\n", rcExp, rc);
    498504        else if (RT_FAILURE(rcExp))
    499505            retval = true;
     
    503509            RTUTF16 *pwcExp = wcExp;
    504510            size_t cwc = 0;
    505             rc = RTStrToUtf16Ex(pcszExp, RTSTR_MAX, &pwcExp,
    506                                 RT_ELEMENTS(wcExp), &cwc);
     511            rc = RTStrToUtf16Ex(pcszExp, RTSTR_MAX, &pwcExp, RT_ELEMENTS(wcExp), &cwc);
     512            AssertRC(rc);
    507513            size_t cbExp = cwc * 2 + 2;
    508             AssertRC(rc);
    509514            if (RT_SUCCESS(rc))
    510515            {
    511516                if (cbActual != cbExp)
    512517                {
    513                     RTTestFailed(hTest, "Returned string is the wrong size, string \"%.*ls\", size %u, expected \"%s\", size %u\n",
    514                                  RT_MIN(TESTCASE_MAX_BUF_SIZE, cbActual), pc, cbActual,
    515                                  pcszExp, cbExp);
     518                    RTTestFailed(hTest, "Returned string is the wrong size: got size %u, expected %u\n", cbActual, cbActual);
    516519                }
    517520                else
    518521                {
    519                     if (memcmp(pc, wcExp, cbExp) == 0)
     522                    if (memcmp(abBuf, wcExp, cbExp) == 0)
    520523                        retval = true;
    521524                    else
    522525                        RTTestFailed(hTest, "Returned string \"%.*ls\" does not match expected string \"%s\"\n",
    523                                      TESTCASE_MAX_BUF_SIZE, pc, pcszExp);
     526                                     TESTCASE_MAX_BUF_SIZE, abBuf, pcszExp);
    524527                }
    525528            }
     
    531534}
    532535
     536#if 0
    533537static void tstLatin1FromX11(RTTEST hTest, PSHCLX11CTX pCtx,
    534538                             const char *pcszExp, int rcExp)
     
    669673    }
    670674}
     675#endif
    671676
    672677int main()
     
    694699    AssertRCReturn(rc, RTEXITCODE_FAILURE);
    695700
    696     char *pc;
    697     uint32_t cbActual;
    698     SHCLX11REQREAD *pReq = (SHCLX11REQREAD *)&pReq, *pReqRet = NULL;
     701    RTTESTI_CHECK_RC_OK(ShClEventSourceCreate(&g_EventSource, 0 /* ID */));
    699702
    700703    /* UTF-8 from X11 */
    701704    RTTestSub(hTest, "reading UTF-8 from X11");
    702705    /* Simple test */
    703     tstClipSetSelectionValues("UTF8_STRING", XA_STRING, "hello world",
    704                               sizeof("hello world"), 8);
     706    tstClipSetSelectionValues("UTF8_STRING", XA_STRING, "hello world", sizeof("hello world"), 8);
    705707    tstStringFromX11(hTest, &X11Ctx, "hello world", VINF_SUCCESS);
     708
     709#if 0
    706710    /* With an embedded carriage return */
    707711    tstClipSetSelectionValues("text/plain;charset=UTF-8", XA_STRING,
     
    934938                        sizeof("hello world") * 2);
    935939    tstNoSelectionOwnership(&X11Ctx, "reading from VBox, headless clipboard");
    936 
     940#endif
    937941    ShClX11Destroy(&X11Ctx);
     942    ShClEventSourceDestroy(&g_EventSource);
    938943
    939944    return RTTestSummaryAndDestroy(hTest);
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