Changeset 19506 in vbox
- Timestamp:
- May 7, 2009 8:52:26 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/x11-clipboard.cpp
r19505 r19506 388 388 unsigned cb, uint32_t *pcbActual) 389 389 { 390 unsigned cwDestLen = cbSourceLen + 1;390 unsigned cwDestLen = cbSourceLen; 391 391 char *pu8SourceText = reinterpret_cast<char *>(pValue); 392 392 PRTUTF16 pu16DestText = reinterpret_cast<PRTUTF16>(pv); … … 2027 2027 } 2028 2028 2029 static bool testLatin1FromX11(VBOXCLIPBOARDCONTEXTX11 *pCtx, uint32_t cbBuf, 2030 const char *pcszExp, int rcExp) 2031 { 2032 bool retval = false; 2033 AssertReturn(cbBuf <= MAX_BUF_SIZE, false); 2034 if (!clipPollTargets()) 2035 RTPrintf("Failed to poll for targets\n"); 2036 else if (clipQueryFormats() != VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT) 2037 RTPrintf("Wrong targets reported: %02X\n", clipQueryFormats()); 2038 else 2039 { 2040 char pc[MAX_BUF_SIZE]; 2041 uint32_t cbActual; 2042 int rc = VBoxX11ClipboardReadX11Data(pCtx, 2043 VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT, 2044 (void *) pc, cbBuf, &cbActual); 2045 if (rc != rcExp) 2046 RTPrintf("Wrong return code, expected %Rrc, got %Rrc\n", rcExp, 2047 rc); 2048 else if (RT_FAILURE(rcExp)) 2049 retval = true; 2050 else 2051 { 2052 RTUTF16 wcExp[MAX_BUF_SIZE / 2]; 2053 RTUTF16 *pwcExp = wcExp; 2054 size_t cwc; 2055 for (cwc = 0; cwc == 0 || pcszExp[cwc - 1] != '\0'; ++cwc) 2056 wcExp[cwc] = pcszExp[cwc]; 2057 size_t cbExp = cwc * 2; 2058 if (cbActual != cbExp) 2059 { 2060 RTPrintf("Returned string is the wrong size, string \"%.*ls\", size %u\n", 2061 RT_MIN(MAX_BUF_SIZE, cbActual), pc, cbActual); 2062 RTPrintf("Expected \"%s\", size %u\n", pcszExp, 2063 cbExp); 2064 } 2065 else 2066 { 2067 if (memcmp(pc, wcExp, cbExp) == 0) 2068 retval = true; 2069 else 2070 RTPrintf("Returned string \"%.*ls\" does not match expected string \"%s\"\n", 2071 MAX_BUF_SIZE, pc, pcszExp); 2072 } 2073 } 2074 } 2075 if (!retval) 2076 RTPrintf("Expected: string \"%s\", rc %Rrc (buffer size %u)\n", 2077 pcszExp, rcExp, cbBuf); 2078 return retval; 2079 } 2080 2029 2081 static bool testStringFromVBox(VBOXCLIPBOARDCONTEXTX11 *pCtx, 2030 2082 const char *pcszTarget, Atom typeExp, … … 2111 2163 "hello world\r\n", VINF_SUCCESS)) 2112 2164 ++cErrs; 2113 clipSetSelectionValues("UTF8_STRING", XA_STRING, "hello world\n",2114 sizeof("hello world\n"), 8);2115 if (!testStringFromX11(pCtx, sizeof("hello world\r\n") * 2,2116 "hello world\r\n", VINF_SUCCESS))2117 ++cErrs;2118 2165 clipSetSelectionValues("UTF8_STRING", XA_STRING, "", 2119 2166 sizeof(""), 8); … … 2147 2194 "hello world\r\n", VINF_SUCCESS)) 2148 2195 ++cErrs; 2149 clipSetSelectionValues("COMPOUND_TEXT", XA_STRING, "hello world\n",2150 sizeof("hello world\n"), 8);2151 if (!testStringFromX11(pCtx, sizeof("hello world\r\n") * 2,2152 "hello world\r\n", VINF_SUCCESS))2153 ++cErrs;2154 2196 clipSetSelectionValues("COMPOUND_TEXT", XA_STRING, "", 2155 2197 sizeof(""), 8); 2156 2198 if (!testStringFromX11(pCtx, sizeof("") * 2, "", VINF_SUCCESS)) 2199 ++cErrs; 2200 2201 /***********/ 2202 RTPrintf(TEST_NAME ": TESTING reading Latin1 from X11\n"); 2203 clipSetSelectionValues("STRING", XA_STRING, "Georges Dupr\xEA", 2204 sizeof("Georges Dupr\xEA"), 8); 2205 if (!testLatin1FromX11(pCtx, 256, "Georges Dupr\xEA", VINF_SUCCESS)) 2206 ++cErrs; 2207 if (!testLatin1FromX11(pCtx, sizeof("Georges Dupr\xEA") * 2, 2208 "Georges Dupr\xEA", VINF_SUCCESS)) 2209 ++cErrs; 2210 if (!testLatin1FromX11(pCtx, sizeof("Georges Dupr\xEA") * 2 - 1, 2211 "Georges Dupr\xEA", VERR_BUFFER_OVERFLOW)) 2212 ++cErrs; 2213 if (!testLatin1FromX11(pCtx, 0, "Georges Dupr\xEA", VERR_BUFFER_OVERFLOW)) 2214 ++cErrs; 2215 clipSetSelectionValues("TEXT", XA_STRING, "Georges Dupr\xEA\n", 2216 sizeof("Georges Dupr\xEA\n"), 8); 2217 if (!testLatin1FromX11(pCtx, sizeof("Georges Dupr\xEA\r\n") * 2, 2218 "Georges Dupr\xEA\r\n", VINF_SUCCESS)) 2157 2219 ++cErrs; 2158 2220
Note:
See TracChangeset
for help on using the changeset viewer.