license import { ModifierKeys } from '@angular/cdk/testing' ; /** Used to generate unique IDs for events. */ let uniqueIds = 0 ; docs-private export function createMouseEvent ( type , clientX = 0 , clientY = 0 , button = 0 , modifiers = { } ) { const screenX = clientX ; const screenY = clientY ; const event = new MouseEvent ( type , { bubbles : true , cancelable : true , composed : true , view : window , detail : 0 , relatedTarget : null , screenX , screenY , clientX , clientY , ctrlKey : modifiers . control , altKey : modifiers . alt , shiftKey : modifiers . shift , metaKey : modifiers . meta , button : button , buttons : 1 , } ) ; defineReadonlyEventProperty ( event , 'offsetX' , 1 ) ; defineReadonlyEventProperty ( event , 'offsetY' , 1 ) ; return event ; } docs-private export function createPointerEvent ( type , clientX = 0 , clientY = 0 , options = { isPrimary : true } ) { return new PointerEvent ( type , { bubbles : true , cancelable : true , composed : true , view : window , clientX , clientY , ... options , } ) ; } docs-private export function createTouchEvent ( type , pageX = 0 , pageY = 0 , clientX = 0 , clientY = 0 ) { const event = document . createEvent ( 'UIEvent' ) ; const touchDetails = { pageX , pageY , clientX , clientY , identifier : uniqueIds ++ } ; ( 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 = { } ) { return new KeyboardEvent ( type , { bubbles : true , cancelable : true , composed : true , view : window , keyCode : keyCode , key : key , shiftKey : modifiers . shift , metaKey : modifiers . meta , altKey : modifiers . alt , ctrlKey : modifiers . control , } ) ; } docs-private export function createFakeEvent ( type , bubbles = false , cancelable = true , composed = true ) { return new Event ( type , { bubbles , cancelable , composed } ) ; } /**
 * 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 } ) ; }