o
    tVÆgYµ  ã                   @   sô   d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ d dlmZ G dd„ de j	ƒZ
G dd„ de j	ƒZG dd	„ d	eƒZG d
d„ de j	ƒZG dd„ de j	ƒZe  ej d¡dkd¡G dd„ de j	ƒƒZG dd„ de j	ƒZedkrxe  ¡  dS dS )é    N©Úquestion)Údisplayc                   @   sB  e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Ze	 
ej d¡dkd¡dd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Ze	 
dd¡dd „ ƒZd!d"„ Zd#d$„ Ze	 
d%d&¡d'd(„ ƒZe	 
d%d&¡d)d*„ ƒZe	 
d%d&¡d+d,„ ƒZe	 
d%d&¡d-d.„ ƒZe	 
ej d¡d/v d0¡d1d2„ ƒZd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Z d;d<„ Z!d=d>„ Z"d?d@„ Z#dAdB„ Z$dCdD„ Z%e	 
ej d¡dkdE¡dFdG„ ƒZ&e	 
ej d¡dkdE¡dHdI„ ƒZ'e	 
e(e)j*dJƒ dK¡dLdM„ ƒZ+dNdO„ Z,dPdQ„ Z-dRdS„ Z.dTdU„ Z/dVdW„ Z0e	 
ddX¡dYdZ„ ƒZ1dd[gZ2e	 
ddX¡d\d]„ ƒZ3dd[gZ2e	 
ej d¡e2v d^¡d_d`„ ƒZ4daS )bÚDisplayModuleTestzpygame windowc                 C   ó   t  ¡  d S ©N)r   Úinit©Úself© r   úM/home/ubuntu/.local/lib/python3.10/site-packages/pygame/tests/display_test.pyÚsetUp   ó   zDisplayModuleTest.setUpc                 C   r   r   ©r   Úquitr	   r   r   r   ÚtearDown   r   zDisplayModuleTest.tearDownc                 C   s\   t j ¡ }|  |jd¡ |  |jd¡ t j d¡}t j ¡ }|  |jd¡ |  |jd¡ d S )Néÿÿÿÿ©é€   r   r   )Úpygamer   ÚInfoÚassertNotEqualÚ	current_hÚ	current_wÚset_modeÚassertEqual)r
   ÚinfÚscreenr   r   r   Ú	test_Info   s   

zDisplayModuleTest.test_Infoc                 C   s¸   t j d¡}|  t j ¡ ¡ t j |d¡ |  t j ¡ ¡ t j ¡  |  t j	¡ t j ¡  W d   ƒ n1 s8w   Y  ~|  t j	¡ t j ¡  W d   ƒ d S 1 sUw   Y  d S )N©éd   r    )éB   r!   é5   )
r   r   r   ÚassertIsNoneÚflipÚSurfaceÚfillr   ÚassertRaisesÚerror©r
   r   r   r   r   Ú	test_flip!   s   
ÿ"ÿzDisplayModuleTest.test_flipc                 C   sn   t j ¡  |  t j ¡ d¡ t j ¡  t j d¡ |  t j ¡ d¡ t j ¡  t j ¡  |  t j ¡ d¡ dS )zTest the get_active functionF©i€  ià  TN)r   r   r   r   Ú
get_activer   r   r	   r   r   r   Útest_get_active5   s   



z!DisplayModuleTest.test_get_activeÚSDL_VIDEODRIVERÚdummyz4requires the SDL_VIDEODRIVER to be a non dummy valuec                 C   sX   t j d¡ t j ¡  t j ¡  tdƒD ]}t d¡ t j 	¡  q|  
t j ¡ d¡ dS )z-Test the get_active function after an iconifyr+   r    ç{®Gáz„?FN)r   r   r   ÚeventÚclearÚiconifyÚrangeÚtimeÚsleepÚpumpr   r,   )r
   Ú_r   r   r   Útest_get_active_iconifyG   s   	


z)DisplayModuleTest.test_get_active_iconifyc                 C   s$   t  d¡}|  t  ¡ d | j¡ d S )Nr   r   )r   r   r   Úget_captionÚdefault_captionr)   r   r   r   Útest_get_caption[   s   
z"DisplayModuleTest.test_get_captionc                 C   sJ   d}t  d¡}|  t  |¡¡ |  t  ¡ d |¡ |  t  ¡ d |¡ d S )NÚtestr   r   é   ©r   r   r#   Úset_captionr   r:   ©r
   ÚTEST_CAPTIONr   r   r   r   Útest_set_caption`   s
   
z"DisplayModuleTest.test_set_captionc                 C   sL   d}t  d¡}|  t j|d¡ |  t  ¡ d |¡ |  t  ¡ d |¡ d S )Nr=   r   )Útitler   r>   r?   rA   r   r   r   Útest_set_caption_kwargsh   s
   
z)DisplayModuleTest.test_set_caption_kwargsc                 C   s&   d}t  |¡ |  t  ¡ d |¡ d S )Nu   å°r   )r   r@   r   r:   )r
   rB   r   r   r   Útest_caption_unicodep   s   
z&DisplayModuleTest.test_caption_unicodec                 C   s^   g d¢}t  ¡ }|  ||¡ t  ¡  |  tj¡ t  ¡ }W d   ƒ d S 1 s(w   Y  d S )N)ÚaalibÚandroidÚarmÚcocoaÚdgaÚdirectxÚdirectfbr/   Ú
emscriptenÚfbconÚggiÚhaikuÚkhronosÚkmsdrmÚnaclÚ	offscreenÚpandoraÚpspÚqnxÚ	raspberryÚsvgalibÚuikitÚvglÚvivanteÚwaylandÚwindowsÚwindibÚwinrtÚx11)r   Ú
get_driverÚassertInr   r'   r   r(   )r
   ÚdriversÚdriverr   r   r   Útest_get_driveru   s   
"ÿz!DisplayModuleTest.test_get_driverc                 C   s   |   t ¡ ¡ dS )z;Ensures the module's initialization state can be retrieved.N)Ú
assertTruer   Úget_initr	   r   r   r   Útest_get_initœ   s   zDisplayModuleTest.test_get_initTzSDL2 issuesc                    s|   d‰ ‡ fdd„ˆ D ƒD ]0}dD ]+}t  |d|¡}tj  ¡ }|  ||¡ |  |tj¡ |  | ¡ |¡ |  | ¡ |¡ qqdS )z5Ensures get_surface gets the current display surface.)r>   é   r    c                 3   s"    | ]}ˆ D ]}||fV  qqd S r   r   )Ú.0ÚwÚh©Úlengthsr   r   Ú	<genexpr>§   s   €  z5DisplayModuleTest.test_get_surface.<locals>.<genexpr>)é   é   é   é    r   N)	r   r   r   Úget_surfacer   ÚassertIsInstancer%   Úget_sizeÚget_bitsize)r
   Úexpected_sizeÚexpected_depthÚexpected_surfaceÚsurfacer   ro   r   Útest_get_surface¢   s   
øÿz"DisplayModuleTest.test_get_surfacec                 C   s   t j ¡ }|  |¡ dS )z;Ensures get_surface handles the display mode not being set.N)r   r   rv   r#   )r
   r}   r   r   r   Útest_get_surface__mode_not_set²   s   
z0DisplayModuleTest.test_get_surface__mode_not_setc                 C   s<   t  ¡ }|  |t¡ h d£}t| ¡ ƒ |¡}|  |¡ d S )N>   ÚdfbÚhdcÚdataÚhglrcÚwindowr   r}   ÚfswindowÚwmwindowÚ	hinstanceÚ	lock_funcÚ
connectionÚ
taskHandleÚcolorbufferÚframebufferÚunlock_funcÚwimpVersionÚshell_surfaceÚresolveFramebuffer)r   Úget_wm_inforw   ÚdictÚsetÚkeysÚ
differenceÚassertFalse)r
   Úwm_infoÚwm_info_potential_keysÚwm_info_remaining_keysr   r   r   Útest_get_wm_info¸   s
   z"DisplayModuleTest.test_get_wm_infozJskipping for all because some failures on rasppi and maybe other platformsú-OpenGL requires a non-"dummy" SDL_VIDEODRIVERc                 C   sP  t  dtj¡}g }| 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¡¡ | 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¡¡ | tj  tj¡¡ | tj  tj¡¡ | tj  tj¡¡ tj  tjd¡ tj  tjd¡ tj  tjd¡ tj  tj	d¡ tj  tj
d¡ tj  tjd¡ tj  tjd¡ tj  tjd¡ tj  tjd¡ tj  tjd¡ tj  tjd¡ tj  tjd¡ tj  tjd¡ tj  tjd¡ tj  tjd¡ tj  tjd¡ tj  tjd¡ g d¢}g }| 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¡¡ | 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¡¡ | tj  tj¡¡ | tj  tj¡¡ | tj  tj¡¡ tt|ƒƒD ]}|  || || kp|| || k¡ qñ|  t¡ tj  d¡ W d   ƒ d S 1 s!w   Y  d S )	N©r   r   rr   rt   rs   r>   r   ©rr   rt   rr   rs   rs   rs   rs   r>   r>   r   r   r>   r>   r   r   r   r>   r   ÚDUMMY©r   r   r   ÚOPENGLÚappendÚgl_get_attributeÚGL_ALPHA_SIZEÚGL_DEPTH_SIZEÚGL_STENCIL_SIZEÚGL_ACCUM_RED_SIZEÚGL_ACCUM_GREEN_SIZEÚGL_ACCUM_BLUE_SIZEÚGL_ACCUM_ALPHA_SIZEÚGL_MULTISAMPLEBUFFERSÚGL_MULTISAMPLESAMPLESÚ	GL_STEREOÚGL_ACCELERATED_VISUALÚGL_CONTEXT_MAJOR_VERSIONÚGL_CONTEXT_MINOR_VERSIONÚGL_CONTEXT_FLAGSÚGL_CONTEXT_PROFILE_MASKÚGL_SHARE_WITH_CURRENT_CONTEXTÚGL_FRAMEBUFFER_SRGB_CAPABLEÚgl_set_attributer4   Úlenrh   r'   Ú	TypeError©r
   r   Úoriginal_valuesÚ
set_valuesÚ
get_valuesÚir   r   r   Útest_gl_get_attributeÛ   sÂ   ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþ$ÿz'DisplayModuleTest.test_gl_get_attributec                 C   s¶  t  dtj¡}g }| tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtj	d¡ | tj jtj
d¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ tj jtjdd tj jtjdd tj jtjdd tj jtj	dd tj jtj
dd tj jtjdd tj jtjdd tj jtjdd tj jtjdd tj jtjdd tj jtjdd tj jtjdd tj jtjdd tj jtjdd tj jtjdd tj jtjdd tj jtjdd g d	¢}g }| tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtj	d¡ | tj jtj
d¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ tt|ƒƒD ]}|  || || kp8|| || k¡ q$|  t¡ tj  d
¡ W d   ƒ d S 1 sTw   Y  d S )Nrœ   ©Úflagrr   ©r¾   Úvaluert   rs   r>   r   r   rž   rŸ   r·   r   r   r   Útest_gl_get_attribute_kwargsW  sö   ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþ$ÿz.DisplayModuleTest.test_gl_get_attribute_kwargsc                 C   s  t  dtj¡}g d¢}tj  tj|d ¡ tj  tj|d ¡ tj  tj|d ¡ tj  tj|d ¡ tj  tj	|d ¡ tj  tj
|d ¡ tj  tj|d	 ¡ tj  tj|d
 ¡ tj  tj|d ¡ tj  tj|d ¡ g }| 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¡¡ | tj  tj¡¡ | tj  tj¡¡ | tj  tj¡¡ tt|ƒƒD ]}|  || || k¡ qÛ|  t¡ tj  d¡ W d   ƒ d S 1 sw   Y  d S )Nrœ   ©
rr   rt   rr   rs   rs   rs   rs   r>   r>   r   r   r>   é   é   é   rk   é   é   rr   é	   rž   ©r   r   r   r    r´   r£   r¤   r¥   r¦   r§   r¨   r©   rª   r«   r¬   r¡   r¢   r4   rµ   rh   r'   r¶   ©r
   r   r¹   rº   r»   r   r   r   Útest_gl_set_attributeí  s8   $ÿz'DisplayModuleTest.test_gl_set_attributec                 C   s8  t  dtj¡}g d¢}tj jtj|d d tj jtj|d d tj jtj|d d tj jtj|d d tj jtj	|d d tj jtj
|d	 d tj jtj|d
 d tj jtj|d d tj jtj|d d tj jtj|d d g }| tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtj	d¡ | tj jtj
d¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ | tj jtjd¡ tt|ƒƒD ]}|  || || k¡ qï|  t¡ tj  d¡ W d   ƒ d S 1 sw   Y  d S )Nrœ   rÂ   r   r¿   r>   rÃ   rÄ   rÅ   rk   rÆ   rÇ   rr   rÈ   r½   rž   rÉ   rÊ   r   r   r   Útest_gl_set_attribute_kwargs0  sl   
ÿ
ÿ
ÿ
ÿ
ÿ
ÿ
ÿÿÿÿÿÿÿ$ÿz.DisplayModuleTest.test_gl_set_attribute_kwargs)r/   rH   z9iconify is only supported on some video drivers/platformsc                 C   sÄ   t j d¡ |  t j ¡ d¡ t j ¡ }|r[d }}tdƒD ](}t d¡ t j	 
¡ D ]}|jt jkr=|js=|jt jkr=d}|jt jkrEd}q*q|  |¡ |  |¡ |  t j ¡ ¡ d S |  d¡ d S )Nr+   TFé2   r0   z3Iconify not supported on this platform, please skip)r   r   r   r   r,   r3   r4   r5   r6   r1   ÚgetÚtypeÚACTIVEEVENTÚgainÚstateÚ	APPACTIVEÚWINDOWMINIMIZEDrh   r–   Úfail)r
   ÚsuccessÚactive_eventÚwindow_minimized_eventr8   r1   r   r   r   Útest_iconify  s&   

€û

zDisplayModuleTest.test_iconifyc                 C   s"   t  ¡  t  ¡  |  t  ¡ ¡ dS )z4Ensures the module is initialized after init called.N)r   r   r   rh   ri   r	   r   r   r   Ú	test_init¬  s   zDisplayModuleTest.test_initc                 C   ó"   t  ¡  t  ¡  |  t  ¡ ¡ dS )z<Ensures the module is initialized after multiple init calls.N)r   r   rh   ri   r	   r   r   r   Útest_init__multiple´  ó   z%DisplayModuleTest.test_init__multiplec                 C   sì   t jjdt jdd}|dkr$|  t|d ƒd¡ |  t|d d ƒt¡ t j ¡ }|dkrO|  t|d ƒd¡ |  t|d d ƒt¡ |  t|ƒtt|ƒƒ¡ t jjdddd}|dkrt|  t|d ƒd¡ |  t|d d ƒt¡ d S d S )Nr   ©ÚdepthÚflagsr   r   rÃ   )	r   r   Ú
list_modesÚ
FULLSCREENr   rµ   rÏ   Úintr“   )r
   Úmodesr   r   r   Útest_list_modes»  s   
þz!DisplayModuleTest.test_list_modesc                 C   sb   t j d¡ t j ¡ }|dkr|d }|  t j |¡d¡ t j ddd¡ t jjddddd d S )Nr   r   r   ru   )rà   rß   r   )r   r   Úmode_okrá   r   ©r
   rä   Úsizer   r   r   Útest_mode_okÍ  s   
zDisplayModuleTest.test_mode_okc                 C   ó<   t j ¡ }|dkr|d }|  t jj|t jdd¡ d S d S ©Nr   r   ©rà   )r   r   rá   r   ræ   râ   rç   r   r   r   Útest_mode_ok_fullscreen×  s   
ÿþz)DisplayModuleTest.test_mode_ok_fullscreenc                 C   rê   rë   )r   r   rá   r   ræ   ÚSCALEDrç   r   r   r   Útest_mode_ok_scaledß  s
   
þz%DisplayModuleTest.test_mode_ok_scaledc                 C   s   |   tj ¡ d¡ d S )Nr   )ÚassertGreaterr   r   Úget_num_displaysr	   r   r   r   Útest_get_num_displayså  ó   z'DisplayModuleTest.test_get_num_displaysc                 C   s   t  ¡  |  t  ¡ ¡ dS )z8Ensures the module is not initialized after quit called.N©r   r   r–   ri   r	   r   r   r   Ú	test_quitè  s   zDisplayModuleTest.test_quitc                 C   rÛ   )z@Ensures the module is not initialized after multiple quit calls.Nrô   r	   r   r   r   Útest_quit__multipleî  rÝ   z%DisplayModuleTest.test_quit__multiplezNeeds a not dummy videodriverc              
   C   s    t j d¡ g d¢}|D ]A}| j|d1 |  t¡ |  t j |¡d¡ W d   ƒ n1 s/w   Y  |  t j |¡d¡ W d   ƒ n1 sHw   Y  qd S )N©r>   r>   )ç      Ð?ç      à?g)\Âõ(ì?ç      ð?)ÚgammaT)r   r   r   ÚsubTestÚassertWarnsÚDeprecationWarningr   Ú	set_gamma)r
   Úgammasrû   r   r   r   Útest_set_gammaõ  s   ÿý€ÿz DisplayModuleTest.test_set_gammac              	   C   sp   t j d¡ g d¢}|D ])\}}}| j|||d |  t j |||¡d¡ W d   ƒ n1 s0w   Y  qd S )Nr÷   ))rù   rù   rù   )rú   rú   rú   )rø   g…ëQ¸Õ?g)\Âõ(Ü?)ÚrÚgÚbT)r   r   r   rü   r   rÿ   )r
   r   r  r  r  r   r   r   Útest_set_gamma__tuple  s   ÿ€ÿz'DisplayModuleTest.test_set_gamma__tupleÚset_gamma_rampz0Not all systems and hardware support gamma rampsc                 C   s¦   t j d¡ ttdƒƒ}dd„ |D ƒ}dd„ |D ƒ}|  t¡ t j |||¡}W d   ƒ n1 s2w   Y  |rF|  t j |||¡¡ d S |  	t j |||¡¡ d S )N)rk   rk   é   c                 S   ó   g | ]}|d  ‘qS ©r  r   ©rl   Únumberr   r   r   Ú
<listcomp>   ó    z9DisplayModuleTest.test_set_gamma_ramp.<locals>.<listcomp>c                 S   r  r	  r   r
  r   r   r   r  !  r  )
r   r   r   Úlistr4   rý   rþ   r  rh   r–   )r
   r  r  r  ÚisSupportedr   r   r   Útest_set_gamma_ramp  s   ÿz%DisplayModuleTest.test_set_gamma_rampc                 C   s   t jjddddd d S )Nr÷   r   ©rè   rà   rß   r   )r   r   r   r	   r   r   r   Útest_set_mode_kwargs)  ó   z&DisplayModuleTest.test_set_mode_kwargsc                 C   sŒ   t jjdt jddd}t j ¡ }|  |d | ¡ d  dd¡ |  |d | ¡ d  dd¡ |  |d | ¡ d  |d | ¡ d  ¡ d S )Nr÷   r   r  z6window width should be a multiple of the surface widthr>   z8window height should be a multiple of the surface height)r   r   r   rî   Úget_window_sizer   rx   )r
   ÚsurfÚwinsizer   r   r   Útest_set_mode_scaled,  s"   
ÿ
ýý$ÿz&DisplayModuleTest.test_set_mode_scaledc                 C   s   t j t  dd¡¡ d S )Nr>   )r   r   r   ÚVector2r	   r   r   r   Útest_set_mode_vector2?  r  z'DisplayModuleTest.test_set_mode_vector2c                 C   s@   t j dt j¡}|  | ¡ d¡ t j d¡}|  | ¡ d¡ dS )z8Ensures a window created with SCALED can become smaller.)é,  r  )éÈ   r  N)r   r   r   rî   r   rx   r)   r   r   r   Útest_set_mode_unscaledB  s   z(DisplayModuleTest.test_set_mode_unscaledc                 C   sV   t j d¡ |  t j ¡ ¡ t j d¡ |  t j ¡ ¡ t j ¡  |  t j ¡ ¡ d S )NTF)r   r   Úset_allow_screensaverrh   Úget_allow_screensaverr–   r	   r   r   r   Útest_screensaver_supportL  s   
z*DisplayModuleTest.test_screensaver_supportz#set_palette() not supported in SDL2c                 C   sü  |   tj¡ g d¢}tj |¡ W d   ƒ n1 sw   Y  tj ddd¡ g }|  tj |¡¡ |   t¡ d}tj |¡ W d   ƒ n1 sKw   Y  |   t¡ ddgddgg}tj |¡ W d   ƒ n1 snw   Y  |   t¡ g d¢gd	d
„ t	ddƒD ƒ }tj |¡ W d   ƒ n1 s˜w   Y  |   t¡ d}tj |¡ W d   ƒ n1 sµw   Y  |   t¡ g d¢d g}tj |¡ W d   ƒ n1 s×w   Y  |   t¡ g d¢}tj |¡ W d   ƒ d S 1 s÷w   Y  d S )N©r>   rÃ   rÄ   ©i   i   r   rr   é   r>   rÃ   ©r   r   r   r   r   c                 S   ó   g | ]	}|||||g‘qS r   r   ©rl   Úxr   r   r   r  e  ó    z6DisplayModuleTest.test_set_palette.<locals>.<listcomp>éÿ   Úqwerty©é{   r+  r+  é'  ©
r'   r   r(   r   Úset_paletter   r#   Ú
ValueErrorr¶   r4   ©r
   Úpaletter   r   r   Útest_set_paletteU  s>   þþþþþþ"þz"DisplayModuleTest.test_set_paletterH   c                 C   s  |   tj¡ g d¢}tjj|d W d   ƒ n1 sw   Y  tj ddd¡ g }|  tjj|d¡ |   t¡ d}tjj|d W d   ƒ n1 sNw   Y  |   t¡ ddgddgg}tjj|d W d   ƒ n1 srw   Y  |   t¡ g d	¢gd
d„ t	ddƒD ƒ }tjj|d W d   ƒ n1 sw   Y  |   t¡ d}tjj|d W d   ƒ n1 s»w   Y  |   t¡ g d¢d g}tjj|d W d   ƒ n1 sÞw   Y  |   t¡ g d¢}tjj|d W d   ƒ d S 1 sÿw   Y  d S )Nr   )r1  r!  r   rr   r"  r>   rÃ   r#  c                 S   r$  r   r   r%  r   r   r   r  ƒ  r'  z=DisplayModuleTest.test_set_palette_kwargs.<locals>.<listcomp>r(  r)  r*  r,  r-  r0  r   r   r   Útest_set_palette_kwargss  s>   þþþþþþ"þz)DisplayModuleTest.test_set_palette_kwargsz,requires the SDL_VIDEODRIVER to be non dummyc                 C   sæ   t j ¡  |  t j¡ t j ¡  W d  ƒ n1 sw   Y  t j ¡  d}t j |¡}zt j ¡  W n t jyC   |  ¡  Y dS w t j ¡ dkre| 	¡ | 
¡ ft jjdt jddv }|  |d¡ dS |  | 	¡ | 
¡ f|¡ dS )zTest for toggle fullscreenNr+   r>   r   rÞ   T)r   r   r   r'   r(   Útoggle_fullscreenr   r   rÕ   Ú	get_widthÚ
get_heightrá   râ   r   )r
   Úwidth_heightÚ	test_surfÚbooleanr   r   r   Útest_toggle_fullscreen‘  s0   
	ÿ
ÿþÿýÿz(DisplayModuleTest.test_toggle_fullscreenN)5Ú__name__Ú
__module__Ú__qualname__r;   r   r   r   r*   r-   ÚunittestÚskipIfÚosÚenvironrÎ   r9   r<   rC   rE   rF   rg   rj   r~   r   rš   r¼   rÁ   rË   rÌ   rÙ   rÚ   rÜ   rå   ré   rí   rï   rò   rõ   rö   r  r  Úhasattrr   r   r  r  r  r  r  r  r2  Ú	skip_listr3  r:  r   r   r   r   r      s¬    þ
'

#û
uû
 û
<û
Vþ

ÿ

ÿ
þ


	


þr   c                   @   sd   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S )ÚDisplayUpdateTestc                 C   s   dS )z)this is used in the interactive subclass.Nr   ©r
   Úqstrr   r   r   r   ¾  s    zDisplayUpdateTest.questionc                 C   s:   t  ¡  tj  d¡| _| j d¡ tj  ¡  tj ¡  d S )N)éô  rG  Úblack)	r   r   r   r   r   r&   r$   r1   r7   r	   r   r   r   r   Á  s
   
zDisplayUpdateTest.setUpc                 C   r   r   r   r	   r   r   r   r   È  r   zDisplayUpdateTest.tearDownc                 C   sn   | j  d¡ t dddd¡}tj |¡ t dddd¡}tj |¡ t dddd¡}tj |¡ |  d¡ dS )z!takes rects with negative values.Úgreenr   r    iöÿÿÿiœÿÿÿz(Is the screen green in (0, 0, 100, 100)?N)r   r&   r   ÚRectr   Úupdater   )r
   Úr1Úr2Úr3r   r   r   Útest_update_negativeË  s   z&DisplayUpdateTest.test_update_negativec              	   C   st   | j  d¡ t dddd¡t dddd¡t dddd¡t dddd¡g}tj |¡ tj ¡  |  d|› d¡ dS )	z8only updates the part of the display given by the rects.rI  r   r    r  r  úIs the screen green in ú?N©	r   r&   r   rJ  r   rK  r1   r7   r   ©r
   Úrectsr   r   r   Útest_update_sequenceÚ  s   ü
z&DisplayUpdateTest.test_update_sequencec              
   C   sj   | j  d¡ dt dddd¡dt dddd¡t dddd¡f}tj |¡ tj ¡  |  d|› d¡ dS )	z!None is skipped inside sequences.rI  Nr    r   r  r  rP  rQ  rR  rS  r   r   r   Útest_update_none_skippedè  s   û
z*DisplayUpdateTest.test_update_none_skippedc                 C   s0   | j  d¡ tj d¡ tj ¡  |  d¡ dS )údoes NOT update the display.rI  Nz"Is the screen black and NOT green?©r   r&   r   r   rK  r1   r7   r   r	   r   r   r   Útest_update_none÷  s   
z"DisplayUpdateTest.test_update_nonec                 C   s.   | j  d¡ tj ¡  tj ¡  |  d¡ dS )rW  rI  zIs the WHOLE screen green?NrX  r	   r   r   r   Útest_update_no_argsþ  s   

z%DisplayUpdateTest.test_update_no_argsc                 C   s6   | j  d¡ tj dddd¡ tj ¡  |  d¡ dS )z-updates the display using the args as a rect.rI  r    z,Is the screen green in (100, 100, 100, 100)?NrX  r	   r   r   r   Útest_update_args  s   
z"DisplayUpdateTest.test_update_argsc                 C   s|   |   t¡ tj dddd¡ W d  ƒ n1 sw   Y  |   t¡ tj g d¢¡ W d  ƒ dS 1 s7w   Y  dS )z*raises a ValueError when inputs are wrong.r    ÚasdfN)r    r\  r    r    )r'   r/  r   r   rK  r	   r   r   r   Útest_update_incorrect_args  s   ÿ"ÿz,DisplayUpdateTest.test_update_incorrect_argsc                 C   sF   t j ¡  |  t j¡ t j ¡  W d  ƒ dS 1 sw   Y  dS )zraises a pygame.error.N)r   r   r   r'   r(   rK  r	   r   r   r   Útest_update_no_init  s   
"ÿz%DisplayUpdateTest.test_update_no_initN)r;  r<  r=  r   r   r   rO  rU  rV  rY  rZ  r[  r]  r^  r   r   r   r   rD  ½  s    	rD  c                   @   s   e Zd ZdZdgZdd„ ZdS )ÚDisplayUpdateInteractiveTestzFBecause we want these tests to run as interactive and not interactive.Úinteractivec                 C   s   t |ƒ dS )z9since this is the interactive subclass we ask a question.Nr   rE  r   r   r   r   "  s   z%DisplayUpdateInteractiveTest.questionN)r;  r<  r=  Ú__doc__Ú__tags__r   r   r   r   r   r_    s    r_  c                   @   s"   e Zd ZdgZdd„ Zdd„ ZdS )ÚDisplayInteractiveTestr`  c                 C   sv   dt jd< tj ¡  tj ¡  t d¡}| d¡ tj |¡ tj 	d¡}tj 
d¡ tdƒ}|  |¡ tj ¡  d S )Nú100,250ÚSDL_VIDEO_WINDOW_POS)ru   ru   )r(  r   r   ©i  r    z Is the window icon a red square?zIs the display icon red square?)r@  rA  r   r   r   r   r%   r&   Úset_iconr   r@   r   rh   )r
   Ú	test_iconr   Úresponser   r   r   Útest_set_icon_interactive*  s   





z0DisplayInteractiveTest.test_set_icon_interactivec                 C   sº   dt jd< tj ¡  tj ¡  tj d¡}| d¡ dd„ tddƒD ƒ}d	|d
< dd„ tddƒD ƒ}d}tj 	|||¡rCtj 
¡  d}|rVtdƒ}|  |¡ tj 	|||¡ tj ¡  d S )Nrd  re  rf  )r    r    r    c                 S   ó   g | ]}|d  ‘qS r	  r   r%  r   r   r   r  C  r  z>DisplayInteractiveTest.test_set_gamma_ramp.<locals>.<listcomp>r   r  i –  r    c                 S   rk  r	  r   r%  r   r   r   r  E  r  FTz%Is the window background tinted blue?)r@  rA  r   r   r   r   r   r&   r4   r  rK  r   rh   )r
   r   Ú	blue_rampÚnormal_rampÚgamma_successri  r   r   r   r  ;  s"   





z*DisplayInteractiveTest.test_set_gamma_rampN)r;  r<  r=  rb  rj  r  r   r   r   r   rc  '  s    rc  c                   @   sP   e Zd ZdgZdZdZdZdZdZdd„ Z	dd	„ Z
dd
d„Zdd„ Zdd„ ZdS )ÚFullscreenToggleTestsr`  NFi   iX  c                 C   s|   t  ¡  tjdkrt jj| j| jft jd| _	nt j | j| jf¡| _	t j 
d¡ | j	 d¡ t j ¡  t j d d¡| _d S )NÚwin32rì   zFullscreen Tests)r(  r(  r(  ru   )r   r   ÚsysÚplatformr   r   ÚWIDTHÚHEIGHTrî   r   r@   r&   r$   ÚfontÚFontr	   r   r   r   r   _  s   

ÿ
zFullscreenToggleTests.setUpc                 C   s   | j rtj ¡  t ¡  d S r   )Úisfullscreenr   r   r4  r   r	   r   r   r   r   n  s   
zFullscreenToggleTests.tearDownc                 C   sì   d}|r| j stj ¡  d| _ d}n| j rtj ¡  d| _ d}| j |dd¡}| j || jd | j 	|¡d d  d	f¡ tj 
¡  	 tj ¡ D ],}|jtjkrk|jtjkrY dS |jtjkrb dS |jtjkrk dS |jtjkrt dS qHqC)
NÚ TzIs this in fullscreen? [y/n]FzIs this not in fullscreen [y/n])r   r   r   rÃ   r   r    )rw  r   r   r4  ru  Úrenderr   Úblitrs  rè   r$   r1   rÎ   rÏ   ÚKEYDOWNÚkeyÚK_ESCAPEÚK_yÚK_nÚQUIT)r
   Ú
fullscreenÚtextÚsr1   r   r   r   Úvisual_tests  s4   

,
ÿ÷z!FullscreenToggleTests.visual_testc                 C   ó   |   | jdd¡ d S )NT©r  ©rh   r„  r	   r   r   r   Útest_fullscreen_true  ró   z*FullscreenToggleTests.test_fullscreen_truec                 C   r…  )NFr†  r‡  r	   r   r   r   Útest_fullscreen_false’  ró   z+FullscreenToggleTests.test_fullscreen_false)F)r;  r<  r=  rb  r   ru  rw  rs  rt  r   r   r„  rˆ  r‰  r   r   r   r   ro  U  s    
ro  r.   r/   r›   c                   @   ó   e Zd Zdd„ ZdS )ÚDisplayOpenGLTestc                 C   s.   t j ¡  t j dt j¡}|  d| ¡ ¡ dS )z[returns a surface with the same size requested.
        |tags:display,slow,opengl|
        r+   N)r   r   r   r   r    r   rx   r)   r   r   r   Útest_screen_size_opengl›  s   
z)DisplayOpenGLTest.test_screen_size_openglN)r;  r<  r=  rŒ  r   r   r   r   r‹  –  s    r‹  c                   @   rŠ  )ÚX11CrashTestc                 C   s6   t j ¡  t j ¡  t j dd¡}|  d| ¡ ¡ d S )Nr+   r   )r   r   r   r   r   r   rx   r)   r   r   r   Útest_x11_set_mode_crash_gh1654¥  s   

z+X11CrashTest.test_x11_set_mode_crash_gh1654N)r;  r<  r=  rŽ  r   r   r   r   r  ¤  s    r  Ú__main__)r>  r@  rq  r5   r   Úpygame.transformÚpygame.tests.test_utilsr   r   ÚTestCaser   rD  r_  rc  ro  r?  rA  rÎ   r‹  r  r;  Úmainr   r   r   r   Ú<module>   s8           7`
.Aþ

ÿ