o
    ¢ÄiYµ  ã                   @   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   úS/home/kim/smarthome/.venv/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   ZInfoÚassertNotEqualZ	current_hZ	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   r7   ©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<   r>   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   r7   )r
   r?   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)ZaalibÚandroidÚarmZcocoaZdgaZdirectxZdirectfbr,   Z
emscriptenZfbconZggiZhaikuZkhronosZkmsdrmZnaclZ	offscreenZpandoraZpspZqnxZ	raspberryZsvgalibZuikitÚvglZvivanteZwaylandÚwindowsZwindibZwinrtZx11)r   Z
get_driverZassertInr   r$   r   r%   )r
   ZdriversZ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_sizeZget_bitsize)r
   Zexpected_sizeZexpected_depthZexpected_surfaceÚsurfacer   rP   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   rW   r    )r
   rZ   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>   Z
taskHandleZframebufferZhdcZ	hinstanceÚdataZ	lock_funcZresolveFramebufferZwmwindowZcolorbufferÚ
connectionZhglrcrZ   r   ZwindowZunlock_funcZfswindowZshell_surfaceZwimpVersionZdfb)r   Zget_wm_inforX   ÚdictÚsetÚkeysÚ
differenceÚassertFalse)r
   Zwm_infoZwm_info_potential_keysZ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   rS   rU   rT   r;   r   ©rS   rU   rS   rT   rT   rT   rT   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_STEREOZGL_ACCELERATED_VISUALZGL_CONTEXT_MAJOR_VERSIONZGL_CONTEXT_MINOR_VERSIONZGL_CONTEXT_FLAGSZGL_CONTEXT_PROFILE_MASKZGL_SHARE_WITH_CURRENT_CONTEXTZGL_FRAMEBUFFER_SRGB_CAPABLEÚgl_set_attributer1   ÚlenrI   r$   Ú	TypeError©r
   r   Z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 )Nrf   ©ÚflagrS   ©r€   ÚvaluerU   rT   r;   r   rg   rh   ri   rz   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 )Nrf   ©
rS   rU   rS   rT   rT   rT   rT   r;   r;   r   r   r;   é   é   é   rL   é   é   rS   é	   rh   ©r   r   r   rj   rw   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rk   rl   r1   rx   rI   r$   ry   ©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 )Nrf   r„   r   r   r;   r…   r†   r‡   rL   rˆ   r‰   rS   rŠ   r   rh   r‹   rŒ   r   r   r   Útest_gl_set_attribute_kwargs0  sl   
ÿ
ÿ
ÿ
ÿ
ÿ
ÿ
ÿÿÿÿÿÿÿ$ÿz.DisplayModuleTest.test_gl_set_attribute_kwargs)r,   rD   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   r-   z3Iconify not supported on this platform, please skip)r   r   r   r   r)   r0   r1   r2   r3   r.   ÚgetÚtypeZACTIVEEVENTZgainÚstateZ	APPACTIVEZWINDOWMINIMIZEDrI   rc   Úfail)r
   ÚsuccessZactive_eventZwindow_minimized_eventr5   r.   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   rI   rJ   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   rI   rJ   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   rx   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   rV   )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   )ZassertGreaterr   r   Z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   rc   rJ   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)rL   rL   é   c                 S   ó   g | ]}|d  ‘qS ©rÁ   r   ©rM   Ú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   Úlistr1   r·   r¸   rÀ   rI   rc   )r
   r¼   r½   r¾   Z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ª   Zget_window_sizer   rY   )r
   ZsurfZ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   Z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   rY   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   Zset_allow_screensaverrI   Zget_allow_screensaverrc   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   rS   é   r;   r…   ©r   r   r   r   r   c                 S   ó   g | ]	}|||||g‘qS r   r   ©rM   Úxr   r   r   rÆ   e  ó    z6DisplayModuleTest.test_set_palette.<locals>.<listcomp>éÿ   Úqwerty©é{   rÞ   rÞ   é'  ©
r$   r   r%   r   Zset_paletter   r    Ú
ValueErrorry   r1   ©r
   Úpaletter   r   r   Útest_set_paletteU  s>   þþþþþþ"þz"DisplayModuleTest.test_set_paletterD   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Ó   )rã   rÔ   r   rS   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à   râ   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“   Z	get_widthZ
get_heightr   rž   r   )r
   Zwidth_heightZ	test_surfÚbooleanr   r   r   Útest_toggle_fullscreen‘  s0   
	ÿ
ÿþÿýÿz(DisplayModuleTest.test_toggle_fullscreenN)5Ú__name__Ú
__module__Ú__qualname__r8   r   r   r   r'   r*   ÚunittestÚskipIfÚosÚenvironr   r6   r9   r@   rB   rC   rH   rK   r[   r\   rd   r~   rƒ   r   rŽ   r•   r–   r˜   r¡   r¥   r©   r«   r¬   r¯   r°   r»   r¿   Úhasattrr   r   rÉ   rË   rÍ   rÎ   rÑ   rÒ   rä   Z	skip_listrå   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
   Zqstrr   r   r   r   ¾  s    zDisplayUpdateTest.questionc                 C   s:   t  ¡  tj  d¡| _| j d¡ tj  ¡  tj ¡  d S )N)éô  ró   Úblack)	r   r   r   r   r   r#   r!   r.   r4   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Úr2Z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.rõ   r   r   rÐ   rÏ   úIs the screen green in ú?N©	r   r#   r   rö   r   r÷   r.   r4   r   ©r
   Z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.rõ   Nr   r   rÐ   rÏ   rû   rü   rý   rþ   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.rõ   Nz"Is the screen black and NOT green?©r   r#   r   r   r÷   r.   r4   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 )r  rõ   zIs the WHOLE screen green?Nr  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.rõ   r   z,Is the screen green in (100, 100, 100, 100)?Nr  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   r÷   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%   r÷   r	   r   r   r   Útest_update_no_init  s   
"ÿz%DisplayUpdateTest.test_update_no_initN)ré   rê   rë   r   r   r   rú   rÿ   r   r  r  r  r  r  r   r   r   r   rñ   ½  s    	rñ   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   rò   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)rV   rV   )rÛ   r   r   ©i  r   z Is the window icon a red square?zIs the display icon red square?)rî   rï   r   r   r   r   r"   r#   Zset_iconr   r=   r   rI   )r
   Z	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 )Nr  r  r  )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   r  rÃ   r   rØ   r   r   r   rÆ   E  rÇ   FTz%Is the window background tinted blue?)rî   rï   r   r   r   r   r   r#   r1   rÀ   r÷   r   rI   )r
   r   Z	blue_rampZnormal_rampZgamma_successr  r   r   r   rÉ   ;  s"   





z*DisplayInteractiveTest.test_set_gamma_rampN)ré   rê   rë   r  r  rÉ   r   r   r   r   r  '  s    r  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Û   rV   )r   r   ÚsysÚplatformr   r   ÚWIDTHÚHEIGHTrª   r   r=   r#   r!   ÚfontZFontr	   r   r   r   r   _  s   

ÿ
zFullscreenToggleTests.setUpc                 C   s   | j rtj ¡  t ¡  d S r   )Úisfullscreenr   r   ræ   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   )r  r   r   ræ   r  Úrenderr   Zblitr  r¤   r!   r.   r   r‘   ZKEYDOWNÚkeyZK_ESCAPEZK_yZK_nZQUIT)r
   Ú
fullscreenÚtextÚsr.   r   r   r   Úvisual_tests  s4   

,
ÿ÷z!FullscreenToggleTests.visual_testc                 C   ó   |   | jdd¡ d S )NT©r  ©rI   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ë   r  r   r  r  r  r  r   r   r"  r&  r'  r   r   r   r   r  U  s    
r  r+   r,   re   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   rj   r   rY   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   rY   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î   r  r2   r   Zpygame.transformZpygame.tests.test_utilsr   r   ZTestCaser   rñ   r	  r  r  rí   rï   r   r)  r+  ré   Úmainr   r   r   r   Ú<module>   s8           7`
.Aþ

ÿ