Changeset 100685 in vbox for trunk/src/VBox/GuestHost/SharedClipboard/testcase/tstClipboardGH-X11.cpp
- Timestamp:
- Jul 21, 2023 3:04:49 PM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/testcase/tstClipboardGH-X11.cpp
r100204 r100685 95 95 static void *g_tst_pvDataVBox = NULL; 96 96 static uint32_t g_tst_cbDataVBox = 0; 97 97 static SHCLEVENTSOURCE g_EventSource; 98 99 #if 0 98 100 /* Set empty data in the simulated VBox clipboard. */ 99 101 static void tstClipEmptyVBox(PSHCLX11CTX pCtx, int retval) … … 128 130 return VINF_SUCCESS; 129 131 } 132 #endif 130 133 131 134 Display *XtDisplay(Widget w) { NOREF(w); return (Display *) 0xffff; } … … 244 247 } 245 248 249 #if 0 246 250 static void tstClipInvalidateFormats(void) 247 251 { 248 252 g_tst_uX11Formats = ~0; 249 253 } 254 #endif 250 255 251 256 /* Does our clipboard code currently own the selection? */ … … 274 279 } 275 280 281 #if 0 276 282 void XtDisownSelection(Widget widget, Atom selection, Time time) 277 283 { … … 308 314 return true; 309 315 } 316 #endif 310 317 311 318 /* Set the current X selection data */ … … 331 338 } 332 339 340 #if 0 333 341 /* Configure if and how the X11 TARGETS clipboard target will fail. */ 334 342 static void tstClipSetTargetsFailure(void) … … 336 344 g_tst_cTargets = 0; 337 345 } 346 #endif 338 347 339 348 char *XtMalloc(Cardinal size) … … 385 394 static int g_tst_rcCompleted = VINF_SUCCESS; 386 395 static int g_tst_cbCompleted = 0; 387 static SHCLX11REQUEST *g_tst_pCompletedReq = NULL;396 //static SHCLX11REQUEST *g_tst_pCompletedReq = NULL; 388 397 static char g_tst_abCompletedBuf[TESTCASE_MAX_BUF_SIZE]; 389 398 … … 424 433 g_tst_rcCompleted = VERR_BUFFER_OVERFLOW; 425 434 g_tst_cbCompleted = cb; 426 g_tst_pCompletedReq = pData->pReq;435 //g_tst_pCompletedReq = pData->pReq; 427 436 428 437 return VINF_SUCCESS; … … 447 456 } 448 457 458 #if 0 449 459 static bool tstClipTextFormatConversion(PSHCLX11CTX pCtx) 450 460 { … … 464 474 return fSuccess; 465 475 } 466 476 #endif 477 478 /* 467 479 static void tstClipGetCompletedRequest(int *prc, char ** ppc, uint32_t *pcb, SHCLX11REQREAD **ppReq) 468 480 { … … 472 484 *ppReq = g_tst_pCompletedReq; 473 485 } 486 */ 474 487 475 488 static void tstStringFromX11(RTTEST hTest, PSHCLX11CTX pCtx, … … 484 497 else 485 498 { 486 char *pc;487 SHCLX11REQREAD *pReq = (SHCLX11REQREAD *)&pReq, *pReqRet = NULL;488 ShClX11ReadDataFromX11Async(pCtx, VBOX_SHCL_FMT_UNICODETEXT, pReq);489 int rc = VINF_SUCCESS;490 499 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); 492 502 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); 498 504 else if (RT_FAILURE(rcExp)) 499 505 retval = true; … … 503 509 RTUTF16 *pwcExp = wcExp; 504 510 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); 507 513 size_t cbExp = cwc * 2 + 2; 508 AssertRC(rc);509 514 if (RT_SUCCESS(rc)) 510 515 { 511 516 if (cbActual != cbExp) 512 517 { 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); 516 519 } 517 520 else 518 521 { 519 if (memcmp( pc, wcExp, cbExp) == 0)522 if (memcmp(abBuf, wcExp, cbExp) == 0) 520 523 retval = true; 521 524 else 522 525 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); 524 527 } 525 528 } … … 531 534 } 532 535 536 #if 0 533 537 static void tstLatin1FromX11(RTTEST hTest, PSHCLX11CTX pCtx, 534 538 const char *pcszExp, int rcExp) … … 669 673 } 670 674 } 675 #endif 671 676 672 677 int main() … … 694 699 AssertRCReturn(rc, RTEXITCODE_FAILURE); 695 700 696 char *pc; 697 uint32_t cbActual; 698 SHCLX11REQREAD *pReq = (SHCLX11REQREAD *)&pReq, *pReqRet = NULL; 701 RTTESTI_CHECK_RC_OK(ShClEventSourceCreate(&g_EventSource, 0 /* ID */)); 699 702 700 703 /* UTF-8 from X11 */ 701 704 RTTestSub(hTest, "reading UTF-8 from X11"); 702 705 /* 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); 705 707 tstStringFromX11(hTest, &X11Ctx, "hello world", VINF_SUCCESS); 708 709 #if 0 706 710 /* With an embedded carriage return */ 707 711 tstClipSetSelectionValues("text/plain;charset=UTF-8", XA_STRING, … … 934 938 sizeof("hello world") * 2); 935 939 tstNoSelectionOwnership(&X11Ctx, "reading from VBox, headless clipboard"); 936 940 #endif 937 941 ShClX11Destroy(&X11Ctx); 942 ShClEventSourceDestroy(&g_EventSource); 938 943 939 944 return RTTestSummaryAndDestroy(hTest);
Note:
See TracChangeset
for help on using the changeset viewer.