o
    OZŽhÇ  ã                   @   s`   d dl Z d dlZd dlT d dlmZ G dd„ de jƒZG dd„ de jƒZedkr.e  ¡  dS dS )	é    N)Ú*)Útimec                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚBlitTestc                 C   sÄ   t  dtd¡}| d¡ t  dtd¡}| d¡ | |d¡ |  | d¡| d¡¡ t  dtd¡}| d¡ t  dtd¡}| d¡ t  dtd¡}| d¡ | |d¡ |  | d¡| d¡¡ dS )	zSRCALPHA tests.©é   r   é    ©éÿ   r	   r	   r   ©r   r   r	   r	   ©r   r   )é{   r   r   r	   )é
   r   r   r   N)ÚpygameÚSurfaceÚSRCALPHAÚfillÚblitÚassertEqualÚget_at)ÚselfÚsÚdÚs1© r   úE/var/www/auris/lib/python3.10/site-packages/pygame/tests/blit_test.pyÚtest_SRCALPHA
   s   




zBlitTest.test_SRCALPHAc                 C   s  t  dtd¡}| d¡ t  dtd¡}| d¡ | |ddt¡ | |ddt¡ |  | d¡d d¡ | d	¡ | d
¡ | |ddt¡ |  | d¡d d¡ | d	¡ | d
¡ | |ddt	¡ |  | d¡d d¡ | d	¡ | d¡ | |ddt	¡ |  | d¡d d¡ dS )zBLEND_ tests.r   r   r   r
   r   Né   r	   )é   r	   r	   r   )r   r   r	   r	   é   r   r   )é   r   r	   r	   )
r   r   r   r   r   Z	BLEND_ADDZBLEND_RGBA_ADDr   r   Z	BLEND_SUB)r   r   r   r   r   r   Ú
test_BLEND%   s&   







zBlitTest.test_BLENDN)Ú__name__Ú
__module__Ú__qualname__r   r    r   r   r   r   r   	   s    r   c                   @   sh   e Zd 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 )Ú	BlitsTestzTests for pygame.Surface.blitsc                 C   sD   d| _ d| _t | j d dftd¡| _| j d¡ |  | j ¡| _d S )Nr	   r   r   r   )éæ   r%   r%   )	Ú	NUM_SURFSÚPRINT_TIMINGr   r   r   Údstr   Úmake_blit_listÚ	blit_list)r   r   r   r   ÚsetUpP   s
   zBlitsTest.setUpc                 C   s^   g }t |ƒD ]&}|d df}t dtd¡}|d |d |d f}| |¡ | ||f¡ q|S )zUGenerate a list of tuples representing surfaces and destinations
        for blittingr   r   ©r   r   r   r   )Úranger   r   r   r   Úappend)r   Z	num_surfsr*   ÚiÚdestÚsurfÚcolorr   r   r   r)   W   s   
zBlitsTest.make_blit_listc                 C   s    |D ]\}}| j  ||¡ qdS )zrCustom blits method that manually iterates over the blit_list and blits
        each surface onto the destination.N)r(   r   )r   r*   Zsurfacer0   r   r   r   Úcustom_blitsd   s   ÿzBlitsTest.custom_blitsc                 C   s8   t ƒ }|  | j¡}t ƒ }| jrtd|| › ƒ dS dS )z2Checks time performance of the custom blits methodzpython blits: N)r   r3   r*   r'   Úprint©r   Út0ÚresultsÚt1r   r   r   Útest_custom_blits_performancek   s   ÿz'BlitsTest.test_custom_blits_performancec                 C   s¬   t ƒ }| j | j¡}t ƒ }| jrtd|| › ƒ t ƒ }| jj| jdd}t ƒ }| jr4td|| › ƒ t ƒ }| j dd„ | jD ƒ¡}t ƒ }| jrTtd|| › ƒ dS dS )	z Checks time performance of blitszSurface.blits: r   ©ZdoreturnzSurface.blits doreturn=0: c                 s   s    | ]	\}}||fV  qd S )Nr   )Ú.0r1   r0   r   r   r   Ú	<genexpr>†   s   € z3BlitsTest.test_blits_performance.<locals>.<genexpr>zSurface.blits generator: N)r   r(   Úblitsr*   r'   r4   r5   r   r   r   Útest_blits_performancet   s    ÿz BlitsTest.test_blits_performancec                 C   s†   | j  | j¡}t| jƒD ]+}|d |d |d f}|  | j  |d df¡|¡ |  | j  |d d df¡|¡ q|  t|ƒ| j¡ dS )z¬Checks the correctness of the colors on the destination
        after blitting and tests that the length of the results list
        matches the number of surfaces blitted.r   r   r   é   N)r(   r=   r*   r-   r&   r   r   Úlen)r   r7   r/   r2   r   r   r   Útest_blits_correctness‹   s   "z BlitsTest.test_blits_correctnessc                 C   s"   | j j| jdd}|  |d¡ dS )z+Tests that when doreturn=0, it returns Noner   r:   N)r(   r=   r*   r   )r   r7   r   r   r   Útest_blits_doreturn˜   s   zBlitsTest.test_blits_doreturnc                 C   sH   t  dtd¡}|  t¡ | d¡ W d  ƒ dS 1 sw   Y  dS )z`Tests that calling blits with an invalid non-sequence None argument
        raises a ValueError.©éd   r   r   N©r   r   r   ÚassertRaisesÚ
ValueErrorr=   ©r   r(   r   r   r   Útest_blits_not_sequencež   s   "ÿz!BlitsTest.test_blits_not_sequencec                 C   sT   t  dtd¡}|  t¡ | t  dtd¡g¡ W d  ƒ dS 1 s#w   Y  dS )z‚Tests that calling blits with an invalid sequence containing a single surface
        (without a destination) raises a ValueError.rC   r   r,   NrE   rH   r   r   r   Útest_blits_wrong_length¦   s   "ÿz!BlitsTest.test_blits_wrong_lengthc                 C   sJ   t  dtd¡}|  t¡ | dg¡ W d  ƒ dS 1 sw   Y  dS )zrTests that calling blits with a sequence containing an invalid tuple of
        None arguments raises a TypeError.rC   r   )NNN©r   r   r   rF   Ú	TypeErrorr=   rH   r   r   r   Útest_blits_bad_surf_args®   s   "ÿz"BlitsTest.test_blits_bad_surf_argsc                 C   sX   t  dtd¡}|  t¡ | t  dtd¡dfg¡ W d  ƒ dS 1 s%w   Y  dS )z{Tests that calling blits with a sequence containing an invalid tuple with a
        destination of None raises a TypeError.rC   r   r,   NrK   rH   r   r   r   Útest_blits_bad_dest¶   s   "ÿzBlitsTest.test_blits_bad_destN)r!   r"   r#   Ú__doc__r+   r)   r3   r9   r>   rA   rB   rI   rJ   rM   rN   r   r   r   r   r$   M   s    	r$   Ú__main__)	Zunittestr   Zpygame.localsr   ZTestCaser   r$   r!   Úmainr   r   r   r   Ú<module>   s    Drÿ