import { ModifierKeys } from '@angular/cdk/testing' ; docs-private export function createMouseEvent ( type , clientX = 0 , clientY = 0 , button = 0 , modifiers = { } , relatedTarget ? ) { const event = document . createEvent ( 'MouseEvent' ) ; const originalPreventDefault = event . preventDefault . bind ( event ) ; const screenX = clientX ; const screenY = clientY ; event . initMouseEvent ( type , true , true , window , 0 , screenX , screenY , clientX , clientY , ! ! modifiers . control , ! ! modifiers . alt , ! ! modifiers . shift , ! ! modifiers . meta , button , relatedTarget ) ; defineReadonlyEventProperty ( event , 'buttons' , 1 ) ; event . preventDefault = function ( ) { defineReadonlyEventProperty ( event , 'defaultPrevented' , true ) ; return originalPreventDefault ( ) ; } ; return event ; } docs-private export function createPointerEvent ( type , clientX = 0 , clientY = 0 , options = { isPrimary : true } ) { return new PointerEvent ( type , { bubbles : true , cancelable : true , view : window , clientX , clientY , ... options } ) ; } docs-private export function createTouchEvent ( type , pageX = 0 , pageY = 0 ) { const event = document . createEvent ( 'UIEvent' ) ; const touchDetails = { pageX , pageY } ; ( event as any ) . initUIEvent ( type , true , true , window , 0 ) ; defineReadonlyEventProperty ( event , 'touches' , [ touchDetails ] ) ; defineReadonlyEventProperty ( event , 'targetTouches' , [ touchDetails ] ) ; defineReadonlyEventProperty ( event , 'changedTouches' , [ touchDetails ] ) ; return event ; } docs-private export function createKeyboardEvent ( type , keyCode = 0 , key = '' , modifiers = { } ) { const event = document . createEvent ( 'KeyboardEvent' ) ; const originalPreventDefault = event . preventDefault . bind ( event ) ; if ( ( event as any ) . initKeyEvent !== undefined ) { ( event as any ) . initKeyEvent ( type , true , true , window , modifiers . control , modifiers . alt , modifiers . shift , modifiers . meta , keyCode ) ; } else { let modifiersList = '' ; if ( modifiers . control ) { modifiersList += 'Control ' ; } if ( modifiers . alt ) { modifiersList += 'Alt ' ; } if ( modifiers . shift ) { modifiersList += 'Shift ' ; } if ( modifiers . meta ) { modifiersList += 'Meta ' ; } ( event as any ) . initKeyboardEvent ( type , true , true , window , 0 , key , 0 , modifiersList . trim ( ) , false ) ; } defineReadonlyEventProperty ( event , 'keyCode' , keyCode ) ; defineReadonlyEventProperty ( event , 'key' , key ) ; defineReadonlyEventProperty ( event , 'ctrlKey' , ! ! modifiers . control ) ; defineReadonlyEventProperty ( event , 'altKey' , ! ! modifiers . alt ) ; defineReadonlyEventProperty ( event , 'shiftKey' , ! ! modifiers . shift ) ; defineReadonlyEventProperty ( event , 'metaKey' , ! ! modifiers . meta ) ; event . preventDefault = function ( ) { defineReadonlyEventProperty ( event , 'defaultPrevented' , true ) ; return originalPreventDefault ( ) ; } ; return event ; } docs-private export function createFakeEvent ( type , canBubble = false , cancelable = true ) { const event = document . createEvent ( 'Event' ) ; event . initEvent ( type , canBubble , cancelable ) ; return event ; } export function createDragEvent ( type , dataTransfer = null , canBubble = false , cancelable = true ) { const event = document . createEvent ( 'DragEvent' ) ; event . initEvent ( type , canBubble , cancelable ) ; defineReadonlyEventProperty ( event , 'dataTransfer' , dataTransfer ) ; return event ; } /**
 * Defines a readonly property on the given event object. Readonly properties on an event object
 * are always set as configurable as that matches default readonly properties for DOM event objects.
 */ function defineReadonlyEventProperty ( event , propertyName , value ) { Object . defineProperty ( event , propertyName , { get : ( ) => value , configurable : true } ) ; }