
    i                         d dl Z d dlZd dl d dlmZ  G d de j                        Z G d de j                        Zedk(  r e j                          yy)	    N)*)timec                       e Zd Zd Zd Zy)BlitTestc                    t        j                  dt        d      }|j                  d       t        j                  dt        d      }|j                  d       |j	                  |d       | j                  |j                  d      |j                  d             t        j                  dt        d      }|j                  d       t        j                  dt        d      }|j                  d       t        j                  dt        d      }|j                  d       |j	                  |d       | j                  |j                  d      |j                  d             y)	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s1s       `/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/pygame/tests/blit_test.pytest_SRCALPHAzBlitTest.test_SRCALPHA
   s     NN68R0	!"NN68R0	 	q&&)188F+;< NN68R0	 ^^FHb1
 !NN68R0	}	q&&)299V+<=    c                    t        j                  dt        d      }|j                  d       t        j                  dt        d      }|j                  d       |j	                  |ddt
               |j	                  |ddt               | j                  |j                  d      d   d       |j                  d	       |j                  d
       |j	                  |ddt
               | j                  |j                  d      d   d       |j                  d	       |j                  d
       |j	                  |ddt               | j                  |j                  d      d   d       |j                  d	       |j                  d       |j	                  |ddt               | j                  |j                  d      d   d       y)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   	BLEND_ADDBLEND_RGBA_ADDr   r   	BLEND_SUB)r   r   r   s      r   
test_BLENDzBlitTest.test_BLEND%   sj    NN68R0	!"NN68R0	 	q&$	* 	
q&$/&)!,c2 	
 !	 !	q&$	*&)!,c2 	
 !	 !	q&$	*&)!,b1 	
 !	 !	q&$	*&)!,a0r   N)__name__
__module____qualname__r   r'    r   r   r   r   	   s    >6%1r   r   c                   R    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zy)	BlitsTestzTests for pygame.Surface.blitsc                     d| _         d| _        t        j                  | j                   dz  dft        d      | _        | j
                  j                  d       | j                  | j                         | _        y )Nr   r   r   r
   )   r/   r/   )		NUM_SURFSPRINT_TIMINGr   r   r   dstr   make_blit_list	blit_list)r   s    r   setUpzBlitsTest.setUpP   sY    >>4>>B#6";XrJo&,,T^^<r   c                     g }t        |      D ]V  }|dz  df}t        j                  dt        d      }|dz  |dz  |dz  f}|j	                  |       |j                  ||f       X |S )zUGenerate a list of tuples representing surfaces and destinations
        for blittingr   r   r   r   r
   r	   )ranger   r   r   r   append)r   	num_surfsr4   idestsurfcolors          r   r3   zBlitsTest.make_blit_listW   sz     	y! 	+AFA;D>>(Hb9DUAE1q5)EIIedD\*	+ r   c                 P    |D ]!  \  }}| j                   j                  ||       # y)zrCustom blits method that manually iterates over the blit_list and blits
        each surface onto the destination.N)r2   r   )r   r4   surfacer<   s       r   custom_blitszBlitsTest.custom_blitsd   s)     ' 	)MGTHHMM'4(	)r   c                     t               }| j                  | j                        }t               }| j                  rt	        d||z
          yy)z2Checks time performance of the custom blits methodzpython blits: N)r   rA   r4   r1   printr   t0resultst1s       r   test_custom_blits_performancez'BlitsTest.test_custom_blits_performancek   sG     V##DNN3VN27),- r   c                    t               }| j                  j                  | j                        }t               }| j                  rt        d||z
          t               }| j                  j                  | j                  d      }t               }| j                  rt        d||z
          t               }| j                  j                  d | j                  D              }t               }| j                  rt        d||z
          yy)z Checks time performance of blitszSurface.blits: r   doreturnzSurface.blits doreturn=0: c              3   *   K   | ]  \  }}||f  y w)Nr+   ).0r=   r<   s      r   	<genexpr>z3BlitsTest.test_blits_performance.<locals>.<genexpr>   s     !P:44,!Ps   zSurface.blits generator: N)r   r2   blitsr4   r1   rC   rD   s       r   test_blits_performancez BlitsTest.test_blits_performancet   s     V((..0VOBG9-. V((..!.<V.rBwi89 V((..!P!PQV-b2gY78 r   c                    | j                   j                  | j                        }t        | j                        D ]s  }|dz  |dz  |dz  f}| j                  | j                   j                  |dz  df      |       | j                  | j                   j                  |dz  dz   df      |       u | j                  t        |      | j                         y)zChecks 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)r2   rO   r4   r8   r0   r   r   len)r   rF   r;   r>   s       r   test_blits_correctnessz BlitsTest.test_blits_correctness   s    
 ((..0t~~& 	HAUAE1q5)ETXX__a"fa[95ATXX__q2vlA->?G	H
 	Wt~~6r   c                 v    | j                   j                  | j                  d      }| j                  |d       y)z+Tests that when doreturn=0, it returns Noner   rJ   N)r2   rO   r4   r   )r   rF   s     r   test_blits_doreturnzBlitsTest.test_blits_doreturn   s.     ((..!.<$'r   c                     t        j                  dt        d      }| j                  t              5  |j                  d       ddd       y# 1 sw Y   yxY w)z`Tests that calling blits with an invalid non-sequence None argument
        raises a ValueError.d   r   r
   Nr   r   r   assertRaises
ValueErrorrO   r   r2   s     r   test_blits_not_sequencez!BlitsTest.test_blits_not_sequence   sD     nnY"5z* 	IIdO	 	 	s   AAc                     t        j                  dt        d      }| j                  t              5  |j                  t        j                  dt        d      g       ddd       y# 1 sw Y   yxY w)zTests that calling blits with an invalid sequence containing a single surface
        (without a destination) raises a ValueError.rX   r
   r7   NrZ   r]   s     r   test_blits_wrong_lengthz!BlitsTest.test_blits_wrong_length   sY     nnY"5z* 	@IIv~~h"=>?	@ 	@ 	@s   ,A&&A/c                     t        j                  dt        d      }| j                  t              5  |j                  dg       ddd       y# 1 sw Y   yxY w)zrTests that calling blits with a sequence containing an invalid tuple of
        None arguments raises a TypeError.rX   r
   )NNNr   r   r   r[   	TypeErrorrO   r]   s     r   test_blits_bad_surf_argsz"BlitsTest.test_blits_bad_surf_args   sG     nnY"5y) 	&II|n%	& 	& 	&s   AAc                     t        j                  dt        d      }| j                  t              5  |j                  t        j                  dt        d      dfg       ddd       y# 1 sw Y   yxY w)z{Tests that calling blits with a sequence containing an invalid tuple with a
        destination of None raises a TypeError.rX   r
   r7   Nrb   r]   s     r   test_blits_bad_destzBlitsTest.test_blits_bad_dest   s^     nnY"5y) 	HIIx2>EFG	H 	H 	Hs   .A((A1N)r(   r)   r*   __doc__r5   r3   rA   rH   rP   rT   rV   r^   r`   rd   rf   r+   r   r   r-   r-   M   s>    (=).9.7(@&Hr   r-   __main__)	unittestr   pygame.localsr   TestCaser   r-   r(   mainr+   r   r   <module>rm      sW       A1x   A1HoH!! oHd zHMMO r   