@@ -3265,6 +3265,11 @@ describe('Remote Frame Buffer protocol client', function () {
32653265 expect ( spy ) . to . have . been . calledOnce ;
32663266 expect ( spy . args [ 0 ] [ 0 ] . detail . name ) . to . equal ( 'som€ nam€' ) ;
32673267 } ) ;
3268+
3269+ it ( 'should handle the extendedMouseButtons pseudo-encoding' , function ( ) {
3270+ sendFbuMsg ( [ { x : 0 , y : 0 , width : 0 , height : 0 , encoding : - 316 } ] , [ [ ] ] , client ) ;
3271+ expect ( client . _extendedPointerEventSupported ) . to . equals ( true ) ;
3272+ } ) ;
32683273 } ) ;
32693274
32703275 describe ( 'Caps Lock and Num Lock remote fixup' , function ( ) {
@@ -3757,6 +3762,7 @@ describe('Remote Frame Buffer protocol client', function () {
37573762 describe ( 'Asynchronous events' , function ( ) {
37583763 let client ;
37593764 let pointerEvent ;
3765+ let extendedPointerEvent ;
37603766 let keyEvent ;
37613767 let qemuKeyEvent ;
37623768
@@ -3770,12 +3776,14 @@ describe('Remote Frame Buffer protocol client', function () {
37703776 client . focusOnClick = false ;
37713777
37723778 pointerEvent = sinon . spy ( RFB . messages , 'pointerEvent' ) ;
3779+ extendedPointerEvent = sinon . spy ( RFB . messages , 'extendedPointerEvent' ) ;
37733780 keyEvent = sinon . spy ( RFB . messages , 'keyEvent' ) ;
37743781 qemuKeyEvent = sinon . spy ( RFB . messages , 'QEMUExtendedKeyEvent' ) ;
37753782 } ) ;
37763783
37773784 afterEach ( function ( ) {
37783785 pointerEvent . restore ( ) ;
3786+ extendedPointerEvent . restore ( ) ;
37793787 keyEvent . restore ( ) ;
37803788 qemuKeyEvent . restore ( ) ;
37813789 } ) ;
@@ -3884,6 +3892,32 @@ describe('Remote Frame Buffer protocol client', function () {
38843892 50 , 70 , 0x0 ) ;
38853893 } ) ;
38863894
3895+ it ( 'should send extended pointer event when supports extended pointer events' , function ( ) {
3896+ client . _extendedPointerEventSupported = true ;
3897+ sendMouseButtonEvent ( 50 , 70 , true , 0x10 , client ) ;
3898+
3899+ expect ( extendedPointerEvent ) . to . have . been . calledOnceWith ( client . _sock ,
3900+ 50 , 70 , 0x100 ) ;
3901+ } ) ;
3902+
3903+ it ( 'should send normal pointer event when supports does not extended pointer events' , function ( ) {
3904+ client . _extendedPointerEventSupported = false ;
3905+ sendMouseButtonEvent ( 50 , 70 , true , 0x10 , client ) ;
3906+
3907+ expect ( pointerEvent ) . to . have . been . calledOnceWith ( client . _sock ,
3908+ 50 , 70 , 0x100 ) ;
3909+ } ) ;
3910+
3911+ it ( 'should not send pointer event with illegal mask' , function ( ) {
3912+ // FIXME: Should we mock convertButtonmask to return 0x7f80 instead of
3913+ // calling sendmouse?
3914+ expect ( ( ) => client . _sendmouse ( 50 , 70 , 0x7f80 ) ) . to . throw ( Error ) ;
3915+ } ) ;
3916+
3917+ it ( 'should not send extended pointer event with illegal mask' , function ( ) {
3918+ expect ( ( ) => RFB . messages . extendedPointerevent ( client . _sock , 50 , 70 , 0xfe00 ) ) . to . throw ( Error ) ;
3919+ } ) ;
3920+
38873921 describe ( 'Event aggregation' , function ( ) {
38883922 it ( 'should send a single pointer event on mouse movement' , function ( ) {
38893923 sendMouseMoveEvent ( 50 , 70 , 0x0 , client ) ;
@@ -5135,11 +5169,29 @@ describe('RFB messages', function () {
51355169 } ) ;
51365170
51375171 it ( 'should send correct data for pointer events' , function ( ) {
5172+ RFB . messages . pointerEvent ( sock , 12345 , 54321 , 0x2b ) ;
5173+ let expected =
5174+ [ 5 , 0x2b , 0x30 , 0x39 , 0xd4 , 0x31 ] ;
5175+ expect ( sock ) . to . have . sent ( new Uint8Array ( expected ) ) ;
5176+ } ) ;
5177+
5178+ it ( 'should send correct data for pointer events with marker bit set' , function ( ) {
51385179 RFB . messages . pointerEvent ( sock , 12345 , 54321 , 0xab ) ;
51395180 let expected =
5140- [ 5 , 0xab , 0x30 , 0x39 , 0xd4 , 0x31 ] ;
5181+ [ 5 , 0x2b , 0x30 , 0x39 , 0xd4 , 0x31 ] ;
51415182 expect ( sock ) . to . have . sent ( new Uint8Array ( expected ) ) ;
51425183 } ) ;
5184+
5185+ it ( 'should send correct data for extended pointer events' , function ( ) {
5186+ RFB . messages . extendedPointerEvent ( sock , 12345 , 54321 , 0xab ) ;
5187+ let expected =
5188+ [ 5 , 0xab , 0x30 , 0x39 , 0xd4 , 0x31 , 0x1 ] ;
5189+ expect ( sock ) . to . have . sent ( new Uint8Array ( expected ) ) ;
5190+ } ) ;
5191+
5192+ it ( 'should not send invalid data for extended pointer events' , function ( ) {
5193+ expect ( ( ) => RFB . messages . extendedPointerEvent ( sock , 12345 , 54321 , 0x3ab ) ) . to . throw ( Error ) ;
5194+ } ) ;
51435195 } ) ;
51445196
51455197 describe ( 'Clipboard events' , function ( ) {
0 commit comments