o
    tVÆg9ƒ  ã                   @   s¬  d dl Z d dlZd dlZd dlZd dlZejejejejej	ej
ejejejejejejejejejfZe  e¡Ze ejdejiejdejieji ejddiej	ddii¡ g dejf‘dejf‘dejf‘dejf‘d	ejf‘d
ejf‘dej	f‘dej
f‘dejf‘dejf‘dejf‘dejf‘dejf‘dejf‘dejf‘dejf‘dejf‘dejf‘dejf‘d‘dejf‘dejf‘dej f‘dej!f‘dej"f‘dej#f‘dej$f‘d ej%f‘d!ej&f‘d"ej'f‘d#ej(f‘d$ej)f‘d%ej*f‘d&ej+f‘d'ej,f‘d(ej-f‘d)ej.f‘d*ej/f‘d+ej0f‘R Z1G d,d-„ d-ej2ƒZ3d.Z4G d/d0„ d0ej2ƒZ5G d1d2„ d2ej2ƒZ6G d3d4„ d4ej2ƒZ7G d5d6„ d6ej2ƒZ8e9d7krTe :¡  dS dS )8é    NÚkeyÚbuttoné   ÚNoEventÚActiveEventÚKeyDownÚKeyUpÚMouseMotionÚMouseButtonDownÚMouseButtonUpÚJoyAxisMotionÚJoyBallMotionÚJoyHatMotionÚJoyButtonDownÚJoyButtonUpÚVideoResizeÚVideoExposeÚQuitÚ
SysWMEventÚMidiInÚMidiOutÚ	UserEvent)ÚUnknownéÿÿ  ÚFingerMotionÚ
FingerDownÚFingerUpÚMultiGestureÚ
MouseWheelÚ	TextInputÚTextEditingÚControllerAxisMotionÚControllerButtonDownÚControllerButtonUpÚControllerDeviceAddedÚControllerDeviceRemovedÚControllerDeviceMappedÚDropFileÚAudioDeviceAddedÚAudioDeviceRemovedÚDropTextÚ	DropBeginÚDropCompletec                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚEventTypeTestc                 C   sØ   t jjt jddd}|  |jd¡ |  |jd¡ |  |jt j¡ |  |j	|j
¡ d|_|  |jd¡ d|_|  |jd¡ |  tt|dd¡ |  tt|dd	¡ t|ƒ}d
}|D ]}|  ||¡ qV| jtt jjddd d	S )z&Ensure an Event object can be created.r   Ú1)Ú	some_attrÚ
other_attré   é   Útyper   ÚdictN)r3   r4   Ú__dict__r/   r0   Únew_attré
   éd   ©r3   )ÚpygameÚeventÚEventÚ	USEREVENTÚassertEqualr/   r0   r3   ÚassertIsr4   r5   r6   ÚassertRaisesÚAttributeErrorÚsetattrÚdirÚassertInÚ
ValueError)ÚselfÚeÚdÚattrsÚattr© rK   úK/home/ubuntu/.local/lib/python3.10/site-packages/pygame/tests/event_test.pyÚ
test_EventU   s    zEventTypeTest.test_Eventc                 C   s>   zt tjjtd ddƒ W d S  ty   |  d¡ Y d S w )Nr   õ   Ã­©Úaz5Event object raised exception for non-ascii character)Ústrr:   r;   r<   ÚEVENT_TYPESÚUnicodeEncodeErrorÚfail©rF   rK   rK   rL   Útest_as_strw   s
   ÿzEventTypeTest.test_as_strc                 C   sD   |   tj tj¡¡ tjtjtjtjfD ]}|  	tj |¡¡ qd S ©N)
ÚassertFalser:   r;   r<   ÚNOEVENTÚMOUSEBUTTONDOWNÚACTIVEEVENTÚWINDOWLEAVEÚUSEREVENT_DROPFILEÚ
assertTrue)rF   Ú
event_typerK   rK   rL   Útest_event_bool   s   üúzEventTypeTest.test_event_boolc                 C   sð   t jjtd dd}t jjtd dd}t jjtd dd}t jjtd dd}|  ||¡ |  ||¡ |  ||¡ |  ||¡ |  ||¡ |  ||¡ |  ||¡ |  ||¡ |  ||¡ |  ||¡ |  ||¡ |  ||¡ |  ||¡ dS )z-Ensure that events can be compared correctly.r   r   rO   é   N)r:   r;   r<   rR   r>   ÚassertNotEqual)rF   rP   ÚbÚcrH   rK   rK   rL   Útest_event_equality‹   s"   z!EventTypeTest.test_event_equalityN)Ú__name__Ú
__module__Ú__qualname__rM   rV   r`   re   rK   rK   rK   rL   r-   T   s
    "

r-   zÈ
This test is dependent on timing. The event queue is cleared in preparation for
tests. There is a small window where outside events from the OS may have effected
results. Try running the test again.
c                   @   s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )ÚEventModuleArgsTestc                 C   ó   t j ¡  t j ¡  d S rW   ©r:   ÚdisplayÚinitr;   ÚclearrU   rK   rK   rL   ÚsetUp°   ó   
zEventModuleArgsTest.setUpc                 C   s   t j ¡  d S rW   )r:   rl   ÚquitrU   rK   rK   rL   ÚtearDown´   s   zEventModuleArgsTest.tearDownc                 C   s°   t j ¡  t j d ¡ t j d d¡ t jjdd t jjdd t jjd d t jjt jt jgd t jjt jdd |  tt jjd¡ |  tt jjd¡ |  tt jjd¡ d S )	NTF©Úpump©Ú	eventtype©rv   rt   i   y      ð?       @Úfoo)	r:   r;   ÚgetÚKEYUPÚKEYDOWNr=   r@   rE   Ú	TypeErrorrU   rK   rK   rL   Útest_get·   s   
zEventModuleArgsTest.test_getc                 C   s¢   t j ¡  t j d ¡ t j d d¡ t jjdd t jjdd t jjd d t jjt jt jgd t jjt jdd |  tt jjd¡ |  tt jj	g d¢¡ d S )NTFrs   ru   rw   iÿÿ)rP   rc   rd   )
r:   r;   rn   rz   r{   r=   r@   rE   r|   ry   rU   rK   rK   rL   Ú
test_clearÇ   s   
zEventModuleArgsTest.test_clearc                 C   sÂ   t j ¡  t j d ¡ t j d d¡ t jjdd t jjdd t jjd d t jjt jt jgd t jjt jdd G dd„ dƒ}|  tt jjd¡ |  tt jjd	g¡ |  tt jj|ƒ ¡ d S )
NTFrs   ru   rw   c                   @   s   e Zd ZdS )z*EventModuleArgsTest.test_peek.<locals>.FooN)rf   rg   rh   rK   rK   rK   rL   ÚFooá   s    r   éÿÿÿÿiöÿÿÿ)	r:   r;   Úpeekrz   r{   r=   r@   rE   r|   )rF   r   rK   rK   rL   Ú	test_peekÖ   s   
zEventModuleArgsTest.test_peekN)rf   rg   rh   ro   rr   r}   r~   r‚   rK   rK   rK   rL   ri   ¯   s    ri   c                   @   s8   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚEventCustomTypeTestzrThose tests are special in that they need the _custom_event counter to
    be reset before and/or after being run.c                 C   s   t  ¡  t  ¡  t j ¡  d S rW   )r:   rq   rm   rl   rU   rK   rK   rL   ro   î   s   zEventCustomTypeTest.setUpc                 C   s   t  ¡  d S rW   )r:   rq   rU   rK   rK   rL   rr   ó   s   zEventCustomTypeTest.tearDownc                 C   s†   |   tj ¡ tjd ¡ tj ¡ }tj ¡ }|   ||d ¡ tj |¡}tj |¡ tj |¡}|   t|ƒd¡ |   |d j	|¡ d S )Nr   r   )
r>   r:   r;   Úcustom_typer=   r<   Úpostry   Úlenr3   )rF   ÚatypeÚatype2ÚevÚqueuerK   rK   rL   Útest_custom_typeö   s   

z$EventCustomTypeTest.test_custom_typec                 C   s|   d}t j ¡ d }t|t jƒD ]}t j ¡ }q|  |t jd ¡ |  t j¡ t j ¡  W d  ƒ dS 1 s7w   Y  dS )z”Ensure custom_type() raises error when no more custom types.

        The last allowed custom type number should be (pygame.NUMEVENTS - 1).
        r€   r   N)r:   r;   r„   ÚrangeÚ	NUMEVENTSr>   r@   Úerror)rF   ÚlastÚstartÚ_rK   rK   rL   Útest_custom_type__end_boundary  s   "ÿz2EventCustomTypeTest.test_custom_type__end_boundaryc                 C   sP   t j ¡ }|  |t j ¡ d ¡ t  ¡  t  ¡  t j ¡  |  |t j ¡ ¡ dS )z2Ensure custom events get 'deregistered' by quit().r   N)r:   r;   r„   r>   rq   rm   rl   )rF   ÚbeforerK   rK   rL   Útest_custom_type__reset  s   

z+EventCustomTypeTest.test_custom_type__resetN)	rf   rg   rh   Ú__doc__ro   rr   r‹   r’   r”   rK   rK   rK   rL   rƒ   ê   s    rƒ   c                   @   sŒ  e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Zd;d<„ Z d=d>„ Z!d?d@„ Z"dAdB„ Z#dCdD„ Z$e% &dE¡dFdG„ ƒZ'dHdI„ Z(dJdK„ Z)e% &dE¡dLdM„ ƒZ*e% +e,j- .dN¡dOkdP¡e% +e/ 0¡ dQk dR¡dSdT„ ƒƒZ1dUdV„ Z2dWS )XÚEventModuleTestc                 O   s   | j |i |¤Ž d S rW   )ÚassertCountEqual)rF   ÚargsÚkwargsrK   rK   rL   Ú_assertCountEqual  s   z!EventModuleTest._assertCountEqualc                 C   sš   |dd… }|D ]4}|D ]}|j D ]}|j | |j | kr nq| |¡  nqtdt|ƒ d t|ƒ d t|ƒ ƒ‚qt|ƒdkrKtdt|ƒ ƒ‚dS )zFind events like expected events, raise on unexpected or missing,
        ignore additional event properties if expected properties are present.Nz	Expected z among remaining events z out of r   zUnexpected Events: )r5   ÚremoveÚAssertionErrorrQ   r†   )rF   ÚexpectedÚgotÚ
items_leftÚexpected_elementÚitemr   rK   rK   rL   Ú_assertExpectedEvents!  s6   
ÿ
üÿþýüûÿþ
ÿz%EventModuleTest._assertExpectedEventsc                 C   rj   rW   rk   rU   rK   rK   rL   ro   =  rp   zEventModuleTest.setUpc                 C   rj   rW   ©r:   r;   rn   rl   rq   rU   rK   rK   rL   rr   A  rp   zEventModuleTest.tearDownc                 C   s   d}|   tj|¡ dS )zCEnsures NUMEVENTS does not exceed the maximum SDL number of events.r   N)ÚassertLessEqualr:   r   )rF   ÚMAX_SDL_EVENTSrK   rK   rL   Útest_event_numeventsE  s   z$EventModuleTest.test_event_numeventsc                 C   s$   t jjt jdd}|  |jd¡ d S )NÚattr1©r§   )r:   r;   r<   r=   r>   r§   )rF   Úe1rK   rK   rL   Útest_event_attributeL  s   z$EventModuleTest.test_event_attributec                    sà   t d ‰ t d }tj ˆ ¡ |  tj ˆ ¡¡ |  tj |¡¡ tj tjjˆ fi t	ˆ  ¤Ž¡}|  |¡ tj tjj|fi t	| ¤Ž¡}|  |¡ tj 
¡ }‡ fdd„|D ƒ}‡ fdd„|D ƒ}|  |g ¡ |  ||v ¡ dS )z,Ensure events can be blocked from the queue.r   r   c                    s   g | ]	}|j ˆ kr|‘qS rK   r9   ©Ú.0rG   ©r;   rK   rL   Ú
<listcomp>e  s    z4EventModuleTest.test_set_blocked.<locals>.<listcomp>c                    s   g | ]
}|j ˆ kr|j ‘qS rK   r9   r«   r­   rK   rL   r®   f  s    N)rR   r:   r;   Úset_blockedr^   Úget_blockedrX   r…   r<   ÚEVENT_TEST_PARAMSry   r>   )rF   Úunblocked_eventÚpostedÚretÚshould_be_blockedÚshould_be_allowed_typesrK   r­   rL   Útest_set_blockedP  s$   ÿ
ÿ

z EventModuleTest.test_set_blockedc                 C   sL   t jt jt jt jt jt jt jg}t j 	|¡ |D ]}|  
t j |¡¡ qdS )z0Ensure a sequence of event types can be blocked.N)r:   r{   rz   ÚMOUSEMOTIONrZ   ÚMOUSEBUTTONUPÚWINDOWFOCUSLOSTr=   r;   r¯   r^   r°   ©rF   Úevent_typesÚetyperK   rK   rL   Ú test_set_blocked__event_sequencek  s   ù
ÿz0EventModuleTest.test_set_blocked__event_sequencec                 C   s,   t j d¡ tD ]}|  t j |¡¡ qdS )z+Ensure all events can be unblocked at once.N)r:   r;   r¯   rR   r^   r°   ©rF   rG   rK   rK   rL   Útest_set_blocked_all|  s   ÿz$EventModuleTest.test_set_blocked_allc              	   C   s   t jjt jdd}t j |¡ t j ¡ }|  |j|jt¡ t	ddƒD ]#}t j t jjt
| fi tt
|  ¤Ž¡ |  t j ¡ jt
| t¡ q"dS )z)Ensure events can be posted to the queue.r§   r¨   r   é   N)r:   r;   r<   r=   r…   Úpollr>   r§   Úrace_condition_notificationrŒ   rR   r±   r3   )rF   r©   Úposted_eventÚirK   rK   rL   Útest_post__and_pollƒ  s   
ÿÿûz#EventModuleTest.test_post__and_pollc                 C   sº   t j ¡ }t jjt jt jdt jjt jt j|dt jjt jt jddt jjt jt j	ddt jjt jt j
dddt jjt jt j|ddg}|D ]}t j |¡ t j ¡ }|  ||t¡ qFdS )	z1Ensure keydown events can be posted to the queue.©r   )r   ÚmodÚg)r   ÚunicodeN)r   rÈ   ÚwindowrG   )r   rÈ   rÊ   )r:   r   Úget_modsr;   r<   r{   ÚK_pÚK_yÚK_gÚK_aÚK_mÚK_er…   rÂ   r>   rÃ   )rF   ÚactivemodkeysÚeventsrG   rÄ   rK   rK   rL   Útest_post_and_get_keydown•  s   
ÿú
ýz)EventModuleTest.test_post_and_get_keydownc                 C   sj   t j t jjt jddittdƒƒd¡ t j ¡ }|  |j	t j¡ |  |j
d¡ |  |jttdƒƒ¡ d S )NrP   Á   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar8   )Útest)r:   r;   r…   r<   r=   ÚlistrŒ   rÂ   r>   r3   rP   r×   r¿   rK   rK   rL   Útest_post_large_user_event©  s   ÿÿ
z*EventModuleTest.test_post_large_user_eventc                 C   s„   t j t j¡ |  t j t j t j¡¡¡ |  t j ¡ ¡ t j t j¡ |  	t j t j t j¡¡¡ |  
t j ¡ t j t j¡¡ dS )zr
        Test blocked events are not posted. Also test whether post()
        returns a boolean correctly
        N)r:   r;   r¯   r=   rX   r…   r<   rÂ   Úset_allowedr^   r>   rU   rK   rK   rL   Útest_post_blockedµ  s    z!EventModuleTest.test_post_blockedc                 C   s^   d}t |ƒD ]}tj tj tj¡¡ qtj ¡ }|  t|ƒ|¡ |  	t
dd„ |D ƒƒ¡ dS )z3Ensure get() retrieves all the events on the queue.r7   c                 s   s    | ]	}|j tjkV  qd S rW   )r3   r:   r=   r«   rK   rK   rL   Ú	<genexpr>Ê  s   € z+EventModuleTest.test_get.<locals>.<genexpr>N)rŒ   r:   r;   r…   r<   r=   ry   r>   r†   r^   Úall)rF   Ú	event_cntr‘   rŠ   rK   rK   rL   r}   Á  s   
zEventModuleTest.test_getc                 C   s¤   t j t j¡}t j |¡ t j t j¡}|  t|ƒd¡ |  |d jt j¡ d}t	|ƒD ]}t j |¡ q,t j t jg¡}|  t|ƒ|¡ |D ]}|  ||¡ qGd S )Nr   r   r7   )
r:   r;   r<   r=   r…   ry   r>   r†   r3   rŒ   )rF   r‰   rŠ   Ú
TESTEVENTSr‘   Úqr;   rK   rK   rL   Útest_get_typeÌ  s   ÿzEventModuleTest.test_get_typec                 C   s    |   tjtjjtjdtj¡ d S )NF)r@   r:   rŽ   r;   ry   r{   rz   rU   rK   rK   rL   Útest_get_exclude_throwÛ  s   ÿz&EventModuleTest.test_get_exclude_throwc                 C   sä   t j t j t j¡¡ t j t j t j¡¡ t jjt jd}|  t|ƒd¡ |  |d j	t j¡ t j t j t j
¡¡ t j t j t j¡¡ t jjt jt j
fd}|  t|ƒd¡ |  |d j	t j¡ t j ¡ }|  t|ƒd¡ d S )N)Úexcluder   r   ra   )r:   r;   r…   r<   r=   r{   ry   r>   r†   r3   rz   )rF   rŠ   rK   rK   rL   Útest_get_excludeà  s   
z EventModuleTest.test_get_excludec                 C   sb   g }t j ¡  t j ¡ }|  ||¡ tD ]}t j |¡}|  ||¡ qt j t¡}|  ||¡ dS )z/Ensure get() works correctly on an empty queue.N)r:   r;   rn   ry   ÚassertListEqualrR   )rF   Úexpected_eventsÚretrieved_eventsr_   rK   rK   rL   Útest_get__empty_queueñ  s   

z%EventModuleTest.test_get__empty_queuec                 C   s@  t jt jt jg}t j}g }t j ¡  t j |¡}| j||d g }t j ¡  t j 	t jj
|fi t| ¤Ž¡ t j |¡}| j||d t jj
|d fi t|d  ¤Žg}t j ¡  t j 	|d ¡ t j |¡}| j||d t j ¡  g }|D ]}| t jj
|fi t| ¤Ž¡ t j 	|d ¡ qwt j |¡}| j||d dS )z2Ensure get() can handle a sequence of event types.)r   rž   r   r€   N)r:   r{   rz   r¸   r¹   r;   rn   ry   r¢   r…   r<   r±   Úappend)rF   r¼   Úother_event_typeræ   rç   r½   rK   rK   rL   Útest_get__event_sequence  s8   

ÿÿ

ÿz(EventModuleTest.test_get__event_sequencec                 C   s    t j ¡  |  t j ¡ g ¡ dS )z0Ensure get() clears the event queue after a callN)r:   r;   ry   r>   rU   rK   rK   rL   Útest_get_clears_queue9  s   
z%EventModuleTest.test_get_clears_queuec                 C   sn   t D ]}tj tjj|fi t| ¤Ž¡ qtj ¡ }|  |jtj	¡ tj 
¡  tj ¡ }|  |jtj	t¡ dS )z3Ensure clear() removes all the events on the queue.N)rR   r:   r;   r…   r<   r±   rÂ   rb   r3   rY   rn   r>   rÃ   )rF   rG   Ú
poll_eventrK   rK   rL   r~   >  s   "


zEventModuleTest.test_clearc                 C   s2   g }t j ¡  t j ¡  t j ¡ }|  ||¡ dS )z1Ensure clear() works correctly on an empty queue.N)r:   r;   rn   ry   rå   )rF   ræ   rç   rK   rK   rL   Útest_clear__empty_queueK  s
   


z'EventModuleTest.test_clear__empty_queuec                 C   s¤   t dd… }t dd… }g }|D ]}tj tjj|fi t| ¤Ž¡ q|D ]}| tjj|fi t| ¤Ž¡ tj |d ¡ q%tj |¡ tj ¡ }|  	||¡ dS )z?Ensure a sequence of event types can be cleared from the queue.Né   r7   r€   )
rR   r:   r;   r…   r<   r±   ré   rn   ry   rš   )rF   Úcleared_event_typesÚexpected_event_typesræ   r½   Úremaining_eventsrK   rK   rL   Útest_clear__event_sequenceW  s   "ÿ
z*EventModuleTest.test_clear__event_sequencec                 C   s0   t D ]\}}|  tj |¡|d|d›¡ qdS )z3Ensure event_name() returns the correct event name.Ú0xÚXN©ÚNAMES_AND_EVENTSr>   r:   r;   Ú
event_name©rF   Úexpected_namer;   rK   rK   rL   Útest_event_nameo  s
   ÿÿzEventModuleTest.test_event_namec                 C   s:   d}t tjtjƒD ]}|  tj |¡|d|d›¡ q	dS )zuEnsures event_name() returns the correct name for user events.

        Tests the full range of user events.
        r   rô   rõ   N)rŒ   r:   r=   r   r>   r;   rø   rù   rK   rK   rL   Ú test_event_name__userevent_rangev  s   ÿÿz0EventModuleTest.test_event_name__userevent_rangec                 C   s<   d}t jd t jfD ]}|  t j |¡|d|d›¡ q
dS )zoEnsures event_name() does not return 'UserEvent' for events
        just outside the user event range.
        r   r   rô   rõ   N)r:   r=   r   rb   r;   rø   )rF   Úunexpected_namer;   rK   rK   rL   Ú#test_event_name__userevent_boundary‚  s   ÿÿz3EventModuleTest.test_event_name__userevent_boundaryc                 C   s2   t D ]\}}|  tjj|d|d|d›¡ qdS )zDEnsure event_name() returns the correct event name when kwargs used.r9   rô   rõ   Nrö   rù   rK   rK   rL   Útest_event_name__kwargs  s
   ÿÿz'EventModuleTest.test_event_name__kwargsc                 C   sl   t jt jt jg}|D ]}t j t jj|fi t| ¤Ž¡ q
|D ]}|  t j 	|¡¡ q|  t j 	|¡¡ dS )z&Ensure queued events can be peeked at.N)
r:   r{   rz   r¸   r;   r…   r<   r±   r^   r   )rF   r¼   r_   rK   rK   rL   r‚   ”  s   ÿzEventModuleTest.test_peekc                 C   s  t jt jt jg}t j}t j ¡  t j |¡}|  |¡ t j ¡  t j 	t jj
|fi t| ¤Ž¡ t j |¡}|  |¡ t j ¡  t j 	t jj
|d fi t|d  ¤Ž¡ t j |¡}|  |¡ t j ¡  |D ]}t j 	t jj
|fi t| ¤Ž¡ qft j |¡}|  |¡ dS )z3Ensure peek() can handle a sequence of event types.r   N)r:   r{   rz   r¸   r¹   r;   rn   r   rX   r…   r<   r±   r^   )rF   r¼   rê   Úpeekedr½   rK   rK   rL   Útest_peek__event_sequence¤  s,   


ÿ

ÿ

"z)EventModuleTest.test_peek__event_sequencec                 C   sX   t j ¡  t j ¡ }|  |¡ tD ]}t j |¡}|  |¡ qt j t¡}|  |¡ dS )z0Ensure peek() works correctly on an empty queue.N)r:   r;   rn   r   rX   rR   )rF   r   r_   rK   rK   rL   Útest_peek__empty_queueÌ  s   


z&EventModuleTest.test_peek__empty_queuec                 C   sH   t d }tj |¡ |  tj |¡¡ tj |¡ |  tj |¡¡ dS )z5Ensure a blocked event type can be unblocked/allowed.r   N)rR   r:   r;   r¯   r^   r°   rÚ   rX   )rF   r;   rK   rK   rL   Útest_set_allowedß  s
   z EventModuleTest.test_set_allowedc                 C   sP   t jt jt jt jt jg}t j |¡ t j |¡ |D ]}|  	t j 
|¡¡ qdS )zBEnsure a sequence of blocked event types can be unblocked/allowed.N)r:   r{   rz   r¸   rZ   r¹   r;   r¯   rÚ   rX   r°   r»   rK   rK   rL   Ú test_set_allowed__event_sequenceê  s   ûÿz0EventModuleTest.test_set_allowed__event_sequencec                 C   sT   t j d¡ tD ]}|  t j |¡¡ qt j d¡ tD ]}|  t j |¡¡ qdS )z3Ensure all events can be unblocked/allowed at once.N)r:   r;   r¯   rR   r^   r°   rÚ   rX   r¿   rK   rK   rL   Útest_set_allowed_allú  s   ÿz$EventModuleTest.test_set_allowed_allc                 C   s   t j ¡  dS )z!Ensure pump() functions properly.N)r:   r;   rt   rU   rK   rK   rL   Ú	test_pump  s   zEventModuleTest.test_pumpz(flaky test, and broken on 2.0.18 windowsc                 C   óH   t j d¡}t j d¡ |  t j ¡ ¡ t j d¡ |  t j ¡ ¡ dS )z¦Ensure event grabbing can be enabled and disabled.

        WARNING: Moving the mouse off the display during this test can cause it
                 to fail.
        ©r7   r7   TFN)r:   rl   Úset_moder;   Úset_grabr^   Úget_grabrX   ©rF   ÚsurfrK   rK   rL   Ú test_set_grab__and_get_symmetric  s
   z0EventModuleTest.test_set_grab__and_get_symmetricc                 C   s\   t j d¡ tD ]}t j |¡}|  |¡ qt j d¡ tD ]}t j |¡}|  |¡ qdS )z1Ensure an event's blocked state can be retrieved.N)r:   r;   rÚ   rR   r°   rX   r¯   r^   )rF   r½   ÚblockedrK   rK   rL   Útest_get_blocked  s   ýz EventModuleTest.test_get_blockedc                 C   s‚   t jt jt jt jt jt jt jg}t j 	|¡}|  
|¡ t j |d ¡ t j 	|¡}|  |¡ t j |¡ t j 	|¡}|  |¡ dS )z:Ensure get_blocked() can handle a sequence of event types.ra   N)r:   r{   rz   r¸   rZ   r¹   ÚWINDOWMINIMIZEDr=   r;   r°   rX   r¯   r^   )rF   r¼   r  rK   rK   rL   Ú test_get_blocked__event_sequence1  s    ù

z0EventModuleTest.test_get_blocked__event_sequencec                 C   sD   t j d¡}tdƒD ]}t j |d ¡ |  t j ¡ |d ¡ q
dS )z#Ensure get_grab() works as expectedr  rï   ra   N)r:   rl   r	  rŒ   r;   r
  r>   r  )rF   r  rÅ   rK   rK   rL   Útest_get_grabU  s
   þzEventModuleTest.test_get_grabÚSDL_VIDEODRIVERÚdummyz4requires the SDL_VIDEODRIVER to be a non dummy value)ra   r   é   zNeeds at least SDL 2.0.16c                 C   r  )zCEnsure set_keyboard_grab() and get_keyboard_grab() work as expectedr  TFN)r:   rl   r	  r;   Úset_keyboard_grabr^   Úget_keyboard_grabrX   r  rK   rK   rL   Ú,test_set_keyboard_grab_and_get_keyboard_grab^  s
   z<EventModuleTest.test_set_keyboard_grab_and_get_keyboard_grabc                 C   sÚ   t j ¡  t j ¡ }|  |jt j¡ t j t j¡}t jjt j	t j
d}t jjt jt j
d}t j |¡ t j |¡ t j |¡ |  t j ¡ j|j¡ |  t j ¡ j|j¡ |  t j ¡ j|j¡ |  t j ¡ jt j¡ dS )zEnsure poll() works as expectedrÇ   N)r:   r;   rn   rÂ   r>   r3   rY   r<   r=   r{   rÐ   rz   r…   )rF   r‰   r©   Úe2Úe3rK   rK   rL   Ú	test_polln  s   

zEventModuleTest.test_pollN)3rf   rg   rh   rš   r¢   ro   rr   r¦   rª   r·   r¾   rÀ   rÆ   rÕ   rÙ   rÛ   r}   rá   râ   rä   rè   rë   rì   r~   rî   ró   rû   rü   rþ   rÿ   r‚   r  r  r  r  r  r  ÚunittestÚskipr  r  r  r  ÚskipIfÚosÚenvironry   r:   Úget_sdl_versionr  r  rK   rK   rK   rL   r–     s`    3(	
$
þr–   c                   @   s*   e Zd ZdgZdd„ Zdd„ Zdd„ ZdS )	ÚEventModuleTestsWithTimingÚtimingc                 C   rj   rW   rk   rU   rK   rK   rL   ro   †  rp   z EventModuleTestsWithTiming.setUpc                 C   rj   rW   r£   rU   rK   rK   rL   rr   Š  rp   z#EventModuleTestsWithTiming.tearDownc                 C   s®  t jjtd fi ttd  ¤Ž}t j |¡ t j ¡ }|  |j|j¡ t j d¡}|  |jt j	¡ t jjtd fi ttd  ¤Ž}t j |¡ t j d¡}|  |j|j¡ t j
 t jdd¡ dt jdfdt jdfdt j	dfdt jd	fd
t j	d
ffD ]"\}}}t
 ¡ }|  t j |¡j|¡ | jt
 ¡ | |d dd qyt j
 t jdd¡ t
 ¡ }|  t j ¡ jt j¡ | jt
 ¡ | ddd t j
 t jdd¡ |  t j d¡jt j	¡ dS )z.Ensure wait() waits for an event on the queue.r   r8   é2   é   é<   éA   é   é-   é   éF   iè  g{®Gáz„?)Údeltar   gš™™™™™¹?é(   N)r:   r;   r<   rR   r±   r…   Úwaitr>   r3   rY   ÚtimeÚ	set_timerr=   Úperf_counterÚassertAlmostEqual)rF   r;   Ú
wait_eventÚ	wait_timeÚexpected_typeÚexpected_timeÚ
start_timerK   rK   rL   Útest_event_waitŽ  s8    
 




ûÿz*EventModuleTestsWithTiming.test_event_waitN)rf   rg   rh   Ú__tags__ro   rr   r9  rK   rK   rK   rL   r#  ƒ  s
    r#  Ú__main__);Úcollectionsr0  r  r   r:   r{   rz   r¸   rZ   r¹   ÚJOYAXISMOTIONÚJOYBALLMOTIONÚJOYHATMOTIONÚJOYBUTTONDOWNÚJOYBUTTONUPÚVIDEORESIZEÚVIDEOEXPOSEÚQUITÚ
SYSWMEVENTr=   rR   Údefaultdictr4   r±   ÚupdateÚK_SPACErY   r[   ÚMIDIINÚMIDIOUTÚFINGERMOTIONÚ
FINGERDOWNÚFINGERUPÚMULTIGESTUREÚ
MOUSEWHEELÚ	TEXTINPUTÚTEXTEDITINGÚCONTROLLERAXISMOTIONÚCONTROLLERBUTTONDOWNÚCONTROLLERBUTTONUPÚCONTROLLERDEVICEADDEDÚCONTROLLERDEVICEREMOVEDÚCONTROLLERDEVICEREMAPPEDÚDROPFILEÚAUDIODEVICEADDEDÚAUDIODEVICEREMOVEDÚDROPTEXTÚ	DROPBEGINÚDROPCOMPLETEr÷   ÚTestCaser-   rÃ   ri   rƒ   r–   r#  rf   ÚmainrK   rK   rK   rL   Ú<module>   sô    ï


ûÿÿþýüûúùø	÷
öõôóòñðïîíìëêéèçæåäãâá à!ß"Þ#Ý$Ü%Û&Ú'Ù+T;1    l
=ÿ