Changeset 82157 in vbox
- Timestamp:
- Nov 25, 2019 8:59:10 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 134967
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp
r82156 r82157 2886 2886 * Run the test. 2887 2887 */ 2888 PSHCLX11CTX pCtx = ShClX11Init(NULL, false); 2888 SHCLX11CTX X11Ctx; 2889 rc = ShClX11Init(&X11Ctx, NULL, false); 2890 AssertRCReturn(rc, 1); 2889 2891 char *pc; 2890 2892 uint32_t cbActual; 2891 2893 CLIPREADCBREQ *pReq = (CLIPREADCBREQ *)&pReq, *pReqRet = NULL; 2892 rc = ShClX11ThreadStart( pCtx, false /* fGrab */);2894 rc = ShClX11ThreadStart(&X11Ctx, false /* fGrab */); 2893 2895 AssertRCReturn(rc, 1); 2894 2896 … … 2898 2900 tstClipSetSelectionValues("UTF8_STRING", XA_STRING, "hello world", 2899 2901 sizeof("hello world"), 8); 2900 tstStringFromX11(hTest, pCtx, "hello world", VINF_SUCCESS);2902 tstStringFromX11(hTest, &X11Ctx, "hello world", VINF_SUCCESS); 2901 2903 /* With an embedded carriage return */ 2902 2904 tstClipSetSelectionValues("text/plain;charset=UTF-8", XA_STRING, 2903 2905 "hello\nworld", sizeof("hello\nworld"), 8); 2904 tstStringFromX11(hTest, pCtx, "hello\r\nworld", VINF_SUCCESS);2906 tstStringFromX11(hTest, &X11Ctx, "hello\r\nworld", VINF_SUCCESS); 2905 2907 /* With an embedded CRLF */ 2906 2908 tstClipSetSelectionValues("text/plain;charset=UTF-8", XA_STRING, 2907 2909 "hello\r\nworld", sizeof("hello\r\nworld"), 8); 2908 tstStringFromX11(hTest, pCtx, "hello\r\r\nworld", VINF_SUCCESS);2910 tstStringFromX11(hTest, &X11Ctx, "hello\r\r\nworld", VINF_SUCCESS); 2909 2911 /* With an embedded LFCR */ 2910 2912 tstClipSetSelectionValues("text/plain;charset=UTF-8", XA_STRING, 2911 2913 "hello\n\rworld", sizeof("hello\n\rworld"), 8); 2912 tstStringFromX11(hTest, pCtx, "hello\r\n\rworld", VINF_SUCCESS);2914 tstStringFromX11(hTest, &X11Ctx, "hello\r\n\rworld", VINF_SUCCESS); 2913 2915 /* An empty string */ 2914 2916 tstClipSetSelectionValues("text/plain;charset=utf-8", XA_STRING, "", 2915 2917 sizeof(""), 8); 2916 tstStringFromX11(hTest, pCtx, "", VINF_SUCCESS);2918 tstStringFromX11(hTest, &X11Ctx, "", VINF_SUCCESS); 2917 2919 /* With an embedded UTF-8 character. */ 2918 2920 tstClipSetSelectionValues("STRING", XA_STRING, 2919 2921 "100\xE2\x82\xAC" /* 100 Euro */, 2920 2922 sizeof("100\xE2\x82\xAC"), 8); 2921 tstStringFromX11(hTest, pCtx, "100\xE2\x82\xAC", VINF_SUCCESS);2923 tstStringFromX11(hTest, &X11Ctx, "100\xE2\x82\xAC", VINF_SUCCESS); 2922 2924 /* A non-zero-terminated string */ 2923 2925 tstClipSetSelectionValues("TEXT", XA_STRING, 2924 2926 "hello world", sizeof("hello world") - 1, 8); 2925 tstStringFromX11(hTest, pCtx, "hello world", VINF_SUCCESS);2927 tstStringFromX11(hTest, &X11Ctx, "hello world", VINF_SUCCESS); 2926 2928 2927 2929 /*** Latin1 from X11 ***/ … … 2930 2932 tstClipSetSelectionValues("STRING", XA_STRING, "Georges Dupr\xEA", 2931 2933 sizeof("Georges Dupr\xEA"), 8); 2932 tstLatin1FromX11(hTest, pCtx, "Georges Dupr\xEA", VINF_SUCCESS);2934 tstLatin1FromX11(hTest, &X11Ctx, "Georges Dupr\xEA", VINF_SUCCESS); 2933 2935 /* With an embedded carriage return */ 2934 2936 tstClipSetSelectionValues("TEXT", XA_STRING, "Georges\nDupr\xEA", 2935 2937 sizeof("Georges\nDupr\xEA"), 8); 2936 tstLatin1FromX11(hTest, pCtx, "Georges\r\nDupr\xEA", VINF_SUCCESS);2938 tstLatin1FromX11(hTest, &X11Ctx, "Georges\r\nDupr\xEA", VINF_SUCCESS); 2937 2939 /* With an embedded CRLF */ 2938 2940 tstClipSetSelectionValues("TEXT", XA_STRING, "Georges\r\nDupr\xEA", 2939 2941 sizeof("Georges\r\nDupr\xEA"), 8); 2940 tstLatin1FromX11(hTest, pCtx, "Georges\r\r\nDupr\xEA", VINF_SUCCESS);2942 tstLatin1FromX11(hTest, &X11Ctx, "Georges\r\r\nDupr\xEA", VINF_SUCCESS); 2941 2943 /* With an embedded LFCR */ 2942 2944 tstClipSetSelectionValues("TEXT", XA_STRING, "Georges\n\rDupr\xEA", 2943 2945 sizeof("Georges\n\rDupr\xEA"), 8); 2944 tstLatin1FromX11(hTest, pCtx, "Georges\r\n\rDupr\xEA", VINF_SUCCESS);2946 tstLatin1FromX11(hTest, &X11Ctx, "Georges\r\n\rDupr\xEA", VINF_SUCCESS); 2945 2947 /* A non-zero-terminated string */ 2946 2948 tstClipSetSelectionValues("text/plain", XA_STRING, 2947 2949 "Georges Dupr\xEA!", 2948 2950 sizeof("Georges Dupr\xEA!") - 1, 8); 2949 tstLatin1FromX11(hTest, pCtx, "Georges Dupr\xEA!", VINF_SUCCESS);2951 tstLatin1FromX11(hTest, &X11Ctx, "Georges Dupr\xEA!", VINF_SUCCESS); 2950 2952 2951 2953 /*** Unknown X11 format ***/ … … 2954 2956 tstClipSetSelectionValues("CLIPBOARD", XA_STRING, "Test", 2955 2957 sizeof("Test"), 8); 2956 tstClipSendTargetUpdate( pCtx);2958 tstClipSendTargetUpdate(&X11Ctx); 2957 2959 RTTEST_CHECK_MSG(hTest, tstClipQueryFormats() == 0, 2958 2960 (hTest, "Failed to send a format update notification\n")); … … 2961 2963 RTTestSub(hTest, "X11 timeout"); 2962 2964 tstClipSetSelectionValues("UTF8_STRING", XT_CONVERT_FAIL, NULL,0, 8); 2963 tstStringFromX11(hTest, pCtx, "", VERR_NO_DATA);2965 tstStringFromX11(hTest, &X11Ctx, "", VERR_NO_DATA); 2964 2966 2965 2967 /*** No data in X11 clipboard ***/ … … 2967 2969 tstClipSetSelectionValues("UTF8_STRING", XA_STRING, NULL, 2968 2970 0, 8); 2969 ShClX11ReadDataFromX11( pCtx, VBOX_SHCL_FMT_UNICODETEXT, pReq);2971 ShClX11ReadDataFromX11(&X11Ctx, VBOX_SHCL_FMT_UNICODETEXT, pReq); 2970 2972 tstClipGetCompletedRequest(&rc, &pc, &cbActual, &pReqRet); 2971 2973 RTTEST_CHECK_MSG(hTest, rc == VERR_NO_DATA, … … 2979 2981 RTTestSub(hTest, "notification of switch to X11 clipboard"); 2980 2982 tstClipInvalidateFormats(); 2981 clipReportEmptyX11CB( pCtx);2983 clipReportEmptyX11CB(&X11Ctx); 2982 2984 RTTEST_CHECK_MSG(hTest, tstClipQueryFormats() == 0, 2983 2985 (hTest, "Failed to send a format update (release) notification\n")); … … 2985 2987 /*** request for an invalid VBox format from X11 ***/ 2986 2988 RTTestSub(hTest, "a request for an invalid VBox format from X11"); 2987 ShClX11ReadDataFromX11( pCtx, 0xffff, pReq);2989 ShClX11ReadDataFromX11(&X11Ctx, 0xffff, pReq); 2988 2990 tstClipGetCompletedRequest(&rc, &pc, &cbActual, &pReqRet); 2989 2991 RTTEST_CHECK_MSG(hTest, rc == VERR_NOT_IMPLEMENTED, … … 3002 3004 long unsigned int cLen = 0; 3003 3005 int format = 8; 3004 clipConvertX11TargetsCallback(NULL, (XtPointer) pCtx, NULL, &atom, NULL, &cLen,3006 clipConvertX11TargetsCallback(NULL, (XtPointer) &X11Ctx, NULL, &atom, NULL, &cLen, 3005 3007 &format); 3006 3008 RTTEST_CHECK_MSG(hTest, tstClipQueryFormats() == 0, … … 3010 3012 /*** X11 text format conversion ***/ 3011 3013 RTTestSub(hTest, "handling of X11 selection targets"); 3012 RTTEST_CHECK_MSG(hTest, tstClipTextFormatConversion( pCtx),3014 RTTEST_CHECK_MSG(hTest, tstClipTextFormatConversion(&X11Ctx), 3013 3015 (hTest, "failed to select the right X11 text formats\n")); 3014 3016 … … 3016 3018 RTTestSub(hTest, "reading UTF-8 from VBox"); 3017 3019 /* Simple test */ 3018 tstClipSetVBoxUtf16( pCtx, VINF_SUCCESS, "hello world",3020 tstClipSetVBoxUtf16(&X11Ctx, VINF_SUCCESS, "hello world", 3019 3021 sizeof("hello world") * 2); 3020 tstStringFromVBox(hTest, pCtx, "UTF8_STRING",3021 clipGetAtom( pCtx, "UTF8_STRING"), "hello world");3022 tstStringFromVBox(hTest, &X11Ctx, "UTF8_STRING", 3023 clipGetAtom(&X11Ctx, "UTF8_STRING"), "hello world"); 3022 3024 /* With an embedded carriage return */ 3023 tstClipSetVBoxUtf16( pCtx, VINF_SUCCESS, "hello\r\nworld",3025 tstClipSetVBoxUtf16(&X11Ctx, VINF_SUCCESS, "hello\r\nworld", 3024 3026 sizeof("hello\r\nworld") * 2); 3025 tstStringFromVBox(hTest, pCtx, "text/plain;charset=UTF-8",3026 clipGetAtom( pCtx, "text/plain;charset=UTF-8"),3027 tstStringFromVBox(hTest, &X11Ctx, "text/plain;charset=UTF-8", 3028 clipGetAtom(&X11Ctx, "text/plain;charset=UTF-8"), 3027 3029 "hello\nworld"); 3028 3030 /* With an embedded CRCRLF */ 3029 tstClipSetVBoxUtf16( pCtx, VINF_SUCCESS, "hello\r\r\nworld",3031 tstClipSetVBoxUtf16(&X11Ctx, VINF_SUCCESS, "hello\r\r\nworld", 3030 3032 sizeof("hello\r\r\nworld") * 2); 3031 tstStringFromVBox(hTest, pCtx, "text/plain;charset=UTF-8",3032 clipGetAtom( pCtx, "text/plain;charset=UTF-8"),3033 tstStringFromVBox(hTest, &X11Ctx, "text/plain;charset=UTF-8", 3034 clipGetAtom(&X11Ctx, "text/plain;charset=UTF-8"), 3033 3035 "hello\r\nworld"); 3034 3036 /* With an embedded CRLFCR */ 3035 tstClipSetVBoxUtf16( pCtx, VINF_SUCCESS, "hello\r\n\rworld",3037 tstClipSetVBoxUtf16(&X11Ctx, VINF_SUCCESS, "hello\r\n\rworld", 3036 3038 sizeof("hello\r\n\rworld") * 2); 3037 tstStringFromVBox(hTest, pCtx, "text/plain;charset=UTF-8",3038 clipGetAtom( pCtx, "text/plain;charset=UTF-8"),3039 tstStringFromVBox(hTest, &X11Ctx, "text/plain;charset=UTF-8", 3040 clipGetAtom(&X11Ctx, "text/plain;charset=UTF-8"), 3039 3041 "hello\n\rworld"); 3040 3042 /* An empty string */ 3041 tstClipSetVBoxUtf16( pCtx, VINF_SUCCESS, "", 2);3042 tstStringFromVBox(hTest, pCtx, "text/plain;charset=utf-8",3043 clipGetAtom( pCtx, "text/plain;charset=utf-8"), "");3043 tstClipSetVBoxUtf16(&X11Ctx, VINF_SUCCESS, "", 2); 3044 tstStringFromVBox(hTest, &X11Ctx, "text/plain;charset=utf-8", 3045 clipGetAtom(&X11Ctx, "text/plain;charset=utf-8"), ""); 3044 3046 /* With an embedded UTF-8 character. */ 3045 tstClipSetVBoxUtf16( pCtx, VINF_SUCCESS, "100\xE2\x82\xAC" /* 100 Euro */,3047 tstClipSetVBoxUtf16(&X11Ctx, VINF_SUCCESS, "100\xE2\x82\xAC" /* 100 Euro */, 3046 3048 10); 3047 tstStringFromVBox(hTest, pCtx, "STRING",3048 clipGetAtom( pCtx, "STRING"), "100\xE2\x82\xAC");3049 tstStringFromVBox(hTest, &X11Ctx, "STRING", 3050 clipGetAtom(&X11Ctx, "STRING"), "100\xE2\x82\xAC"); 3049 3051 /* A non-zero-terminated string */ 3050 tstClipSetVBoxUtf16( pCtx, VINF_SUCCESS, "hello world",3052 tstClipSetVBoxUtf16(&X11Ctx, VINF_SUCCESS, "hello world", 3051 3053 sizeof("hello world") * 2 - 2); 3052 tstStringFromVBox(hTest, pCtx, "TEXT", clipGetAtom(pCtx, "TEXT"),3054 tstStringFromVBox(hTest, &X11Ctx, "TEXT", clipGetAtom(&X11Ctx, "TEXT"), 3053 3055 "hello world"); 3054 3056 3055 3057 /*** Timeout from VBox ***/ 3056 3058 RTTestSub(hTest, "reading from VBox with timeout"); 3057 tstClipEmptyVBox( pCtx, VERR_TIMEOUT);3058 tstStringFromVBoxFailed(hTest, pCtx, "UTF8_STRING");3059 tstClipEmptyVBox(&X11Ctx, VERR_TIMEOUT); 3060 tstStringFromVBoxFailed(hTest, &X11Ctx, "UTF8_STRING"); 3059 3061 3060 3062 /*** No data in VBox clipboard ***/ 3061 3063 RTTestSub(hTest, "an empty VBox clipboard"); 3062 3064 tstClipSetSelectionValues("TEXT", XA_STRING, "", sizeof(""), 8); 3063 tstClipEmptyVBox( pCtx, VINF_SUCCESS);3065 tstClipEmptyVBox(&X11Ctx, VINF_SUCCESS); 3064 3066 RTTEST_CHECK_MSG(hTest, g_ownsSel, 3065 3067 (hTest, "VBox grabbed the clipboard with no data and we ignored it\n")); 3066 tstStringFromVBoxFailed(hTest, pCtx, "UTF8_STRING");3068 tstStringFromVBoxFailed(hTest, &X11Ctx, "UTF8_STRING"); 3067 3069 3068 3070 /*** An unknown VBox format ***/ 3069 3071 RTTestSub(hTest, "reading an unknown VBox format"); 3070 3072 tstClipSetSelectionValues("TEXT", XA_STRING, "", sizeof(""), 8); 3071 tstClipSetVBoxUtf16( pCtx, VINF_SUCCESS, "", 2);3072 ShClX11ReportFormatsToX11( pCtx, 0xa0000);3073 tstClipSetVBoxUtf16(&X11Ctx, VINF_SUCCESS, "", 2); 3074 ShClX11ReportFormatsToX11(&X11Ctx, 0xa0000); 3073 3075 RTTEST_CHECK_MSG(hTest, g_ownsSel, 3074 3076 (hTest, "VBox grabbed the clipboard with unknown data and we ignored it\n")); 3075 tstStringFromVBoxFailed(hTest, pCtx, "UTF8_STRING");3077 tstStringFromVBoxFailed(hTest, &X11Ctx, "UTF8_STRING"); 3076 3078 3077 3079 /*** VBox requests a bad format ***/ 3078 3080 RTTestSub(hTest, "recovery from a bad format request"); 3079 tstBadFormatRequestFromHost(hTest, pCtx);3080 3081 rc = ShClX11ThreadStop( pCtx);3081 tstBadFormatRequestFromHost(hTest, &X11Ctx); 3082 3083 rc = ShClX11ThreadStop(&X11Ctx); 3082 3084 AssertRCReturn(rc, 1); 3083 ShClX11Destroy( pCtx);3085 ShClX11Destroy(&X11Ctx); 3084 3086 3085 3087 /*** Headless clipboard tests ***/ 3086 3088 3087 pCtx = ShClX11Init(NULL, true); 3088 rc = ShClX11ThreadStart(pCtx, false /* fGrab */); 3089 rc = ShClX11Init(&X11Ctx, NULL, true); 3090 AssertRCReturn(rc, 1); 3091 3092 rc = ShClX11ThreadStart(&X11Ctx, false /* fGrab */); 3089 3093 AssertRCReturn(rc, 1); 3090 3094 … … 3092 3096 RTTestSub(hTest, "reading from X11, headless clipboard"); 3093 3097 /* Simple test */ 3094 tstClipSetVBoxUtf16( pCtx, VINF_SUCCESS, "",3098 tstClipSetVBoxUtf16(&X11Ctx, VINF_SUCCESS, "", 3095 3099 sizeof("") * 2); 3096 3100 tstClipSetSelectionValues("UTF8_STRING", XA_STRING, "hello world", 3097 3101 sizeof("hello world"), 8); 3098 tstNoX11( pCtx, "reading from X11, headless clipboard");3102 tstNoX11(&X11Ctx, "reading from X11, headless clipboard"); 3099 3103 3100 3104 /*** Read from VBox ***/ 3101 3105 RTTestSub(hTest, "reading from VBox, headless clipboard"); 3102 3106 /* Simple test */ 3103 tstClipEmptyVBox( pCtx, VERR_WRONG_ORDER);3107 tstClipEmptyVBox(&X11Ctx, VERR_WRONG_ORDER); 3104 3108 tstClipSetSelectionValues("TEXT", XA_STRING, "", sizeof(""), 8); 3105 tstClipSetVBoxUtf16( pCtx, VINF_SUCCESS, "hello world",3109 tstClipSetVBoxUtf16(&X11Ctx, VINF_SUCCESS, "hello world", 3106 3110 sizeof("hello world") * 2); 3107 tstNoSelectionOwnership( pCtx, "reading from VBox, headless clipboard");3108 3109 rc = ShClX11ThreadStop( pCtx);3111 tstNoSelectionOwnership(&X11Ctx, "reading from VBox, headless clipboard"); 3112 3113 rc = ShClX11ThreadStop(&X11Ctx); 3110 3114 AssertRCReturn(rc, 1); 3111 ShClX11Destroy(pCtx); 3115 3116 ShClX11Destroy(&X11Ctx); 3112 3117 3113 3118 return RTTestSummaryAndDestroy(hTest); … … 3165 3170 return RTTestSummaryAndDestroy(hTest); 3166 3171 } 3167 PSHCLX11CTX pCtx = ShClX11Init(NULL, false); 3168 AssertReturn(pCtx, 1); 3169 rc = ShClX11ThreadStart(pCtx, false /* fGrab */); 3172 SHCLX11CTX X11Ctx; 3173 rc = ShClX11Init(&X11Ctx, NULL, false); 3174 AssertRCReturn(rc, 1); 3175 rc = ShClX11ThreadStart(&X11Ctx, false /* fGrab */); 3170 3176 AssertRCReturn(rc, 1); 3171 3177 /* Give the clipboard time to synchronise. */ 3172 3178 RTThreadSleep(500); 3173 rc = ShClX11ThreadStop( pCtx);3179 rc = ShClX11ThreadStop(&X11Ctx); 3174 3180 AssertRCReturn(rc, 1); 3175 ShClX11Destroy( pCtx);3181 ShClX11Destroy(&X11Ctx); 3176 3182 return RTTestSummaryAndDestroy(hTest); 3177 3183 }
Note:
See TracChangeset
for help on using the changeset viewer.