
    i#                     6   d dl Z d dlZe j                  j                  d      dk(  rdZd dlZd dlmZ d dlZd dlm	Z	  G d dej                        Z G d	 d
ej                        Z G d dej                        ZddZd Zedk(  r ej"                          yy)    NSDL_VIDEODRIVERdummy)ignoresubprocess_ignore)trunk_relative_path)scrapc                       e Zd Zed        Zed        Zd Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd Z ej"                  dej&                  vd      d        Zd Zy)ScrapModuleTestc                     t         j                  j                          t         j                  j                  d       t	        j                          y N)   r   pygamedisplayinitset_moder   clss    a/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/pygame/tests/scrap_test.py
setUpClasszScrapModuleTest.setUpClass   -    '

    c                 @    t         j                  j                          y N)r   r   quitr   s    r   tearDownClasszScrapModuleTest.tearDownClass   s     	r   c                     t        j                          t        j                          | j                  t        j                                y)zAEnsures scrap module still initialized after multiple init calls.N)r   r   
assertTrueget_initselfs    r   	test_initzScrapModuleTest.test_init   s'    



()r   c                     t         j                  }d}t        j                  ||       t        j                          | j                  t        j                  |      |       y)z?Ensures reinitializing the scrap module doesn't clear its data.s   test_init__reinitN)r   
SCRAP_TEXTr   putr   assertEqualget)r!   	data_typeexpected_datas      r   test_init__reinitz!ScrapModuleTest.test_init__reinit    sB    %%	,		)]+

9-}=r   c                 J    | j                  t        j                                y)z%Ensures get_init gets the init state.N)r   r   r   r    s    r   test_get_initzScrapModuleTest.test_get_init*   s    ()r   c                 $    | j                          y)z#Ensures contains works as expected.Nfailr    s    r   todo_test_containsz"ScrapModuleTest.todo_test_contains.       		r   c                 $    | j                          y)zEnsures get works as expected.Nr.   r    s    r   todo_test_getzScrapModuleTest.todo_test_get2   r1   r   c                    d}t        j                         rIt        j                  t        j                  d       t        j                         r| j                  d       t        j                  |      }| j                  |       y)zEnsures get works when there is no data of the requested type
        in the clipboard and the clipboard is owned by the pygame application.
        test_get__owned_empty_types   text to clipboardz4requires the pygame application to own the clipboardN)r   lostr%   r   r$   skipTestr'   assertIsNoner!   	DATA_TYPEdatas      r   r5   z*ScrapModuleTest.test_get__owned_empty_type6   sY     1	::<IIf'')=>zz|TUyy#$r   c                 $    | j                          y)z$Ensures get_types works as expected.Nr.   r    s    r   todo_test_get_typesz#ScrapModuleTest.todo_test_get_typesI   r1   r   c                 $    | j                          y)zEnsures lost works as expected.Nr.   r    s    r   todo_test_lostzScrapModuleTest.todo_test_lostM   r1   r   c                     t        j                  t        j                         t        j                  t        j                         | j                  t        t         j                  d       y)z#Ensures set_mode works as expected.iK  N)r   r   r   SCRAP_SELECTIONSCRAP_CLIPBOARDassertRaises
ValueErrorr    s    r   test_set_modezScrapModuleTest.test_set_modeQ   s<    v--.v--.*ennd;r   c                 `   t        j                  t        j                  d       | j	                  t        j
                  t        j                        d       t        j                  t        j                  d       | j	                  t        j
                  t        j                        d       y)z.Ensures put can place text into the clipboard.s   Hello worlds   Another StringN)r   r%   r   r$   r&   r'   r    s    r   test_put__textzScrapModuleTest.test_put__textX   sj    		&##^46#4#45~F		&##%676#4#457HIr   zpygame.imagezrequires pygame.image modulec                 B   t         j                  j                  t        d            }t         j                  j	                  |d      }t        j                  t         j                  |       | j                  t        j                  t         j                        |       y)z5Ensures put can place a BMP image into the clipboard.zexamples/data/asprite.bmpRGBAN)
r   imageloadr   tostringr   r%   	SCRAP_BMPr&   r'   )r!   sfexpected_strings      r   test_put__bmp_imagez#ScrapModuleTest.test_put__bmp_imageb   sh     \\23NOP ,,//F;		&""O46#3#34oFr   c                     d}t        j                  |d       t        j                  |      }| j                  |d       y)ziEnsures put can place data into the clipboard
        when using a user defined type identifier.
        zarbitrary buffers   bufN)r   r%   r'   r&   )r!   r:   rs      r   test_putzScrapModuleTest.test_putk   s5     '			)V$IIi F#r   N)__name__
__module____qualname__classmethodr   r   r"   r*   r,   r0   r3   r5   r=   r?   rE   rG   unittestskipIfsysmodulesrP   rS    r   r   r
   r
      s     
  *>* &<J X__^3;;68VWG XG	$r   r
   c                   N    e Zd ZdZed        Zed        Zd Zd Zd Z	d Z
d Zy	)
 ScrapModuleClipboardNotOwnedTestzTest the scrap module's functionality when the pygame application is
    not the current owner of the clipboard.

    A separate class is used to prevent tests that acquire the clipboard from
    interfering with these tests.
    c                     t         j                  j                          t         j                  j                  d       t	        j                          y r   r   r   s    r   r   z+ScrapModuleClipboardNotOwnedTest.setUpClass   r   r   c                 h    t        j                          t         j                  j                          y r   )r   r   r   r   s    r   r   z.ScrapModuleClipboardNotOwnedTest.tearDownClass   s     	r   c                 P    t        j                         s| j                  d       y y )Nz8requires the pygame application to not own the clipboard)r   r6   r7   r    s    r   _skip_if_clipboard_ownedz9ScrapModuleClipboardNotOwnedTest._skip_if_clipboard_owned   s     zz|MMTU r   c                 t    | j                          d}t        j                  |      }| j                  |       y)zEnsures get works when there is no data of the requested type
        in the clipboard and the clipboard is not owned by the pygame
        application.
        test_get__not_ownedN)rb   r   r'   r8   r9   s      r   rd   z4ScrapModuleClipboardNotOwnedTest.test_get__not_owned   s3    
 	%%' *	yy#$r   c                 x    | j                          t        j                         }| j                  |t               y)zcEnsures get_types works when the clipboard is not owned
        by the pygame application.
        N)rb   r   	get_typesassertIsInstancelist)r!   
data_typess     r   test_get_types__not_ownedz:ScrapModuleClipboardNotOwnedTest.test_get_types__not_owned   s,     	%%'__&
j$/r   c                 t    | j                          d}t        j                  |      }| j                  |       y)zbEnsures contains works when the clipboard is not owned
        by the pygame application.
        test_contains__not_ownedN)rb   r   containsassertFalse)r!   r:   rm   s      r   rl   z9ScrapModuleClipboardNotOwnedTest.test_contains__not_owned   s3     	%%' /	>>),"r   c                 n    | j                          t        j                         }| j                  |       y)z^Ensures lost works when the clipboard is not owned
        by the pygame application.
        N)rb   r   r6   r   )r!   r6   s     r   test_lost__not_ownedz5ScrapModuleClipboardNotOwnedTest.test_lost__not_owned   s'     	%%'zz|r   N)rT   rU   rV   __doc__rW   r   r   rb   rd   rj   rl   rp   r\   r   r   r^   r^   w   sI      
  
V 0#r   r^   c                       e Zd ZddgZ	 ej
                  j                          ej
                  j                         dk(  rdgZej
                  j                          d Z
y# e	$ r Y d Z
yw xY w)X11InteractiveTestr   r   x11interactivec                 .   ddl m}m}m} ddlm}m} ddlm}m}m	} d}	|j                          |j                  dd      }
|j                          |j                  d       |j                  d	      }|j                  t        j                  d
             d}dj!                  |      }t#        |||
d       |j%                          |j'                          t)        j                          t)        j                  |       t)        j*                  ||j-                  d             	 |j/                         }|j0                  |k(  rn |j0                  |k(  r|j2                  |k(  }	n@t         j                  j5                          | j7                  |	       y)zPATCH: pygame.scrap on X11, fix copying into PRIMARY selection

        Copying into theX11 PRIMARY selection (mouse copy/paste) would not
        work due to a confusion between content type and clipboard type.

        r   )r   eventfreetype)rA   r$   )KEYDOWNK_yQUITFN   zInteractive X11 Paste Test)iX     whitezScrap put() succeeded.zSome text has been placed into the X11 clipboard. Please click the center mouse button in an open text window to retrieve it.

Did you get "{}"? (y/n)   zUTF-8)r   r   rw   rx   pygame.localsrA   r$   ry   rz   r{   r   Fontset_captionr   fillColorformat	word_wrapflippumpr   r%   encodewaittypekeyr   r   )r!   r   rw   rx   rA   r$   ry   rz   r{   successfontscreentextmsges                  r   test_issue_208z!X11InteractiveTest.test_issue_208   s1    	43=44}}T2&89!!*-FLL)*'* &, 	 	&#tQ'



'		*dkk'23

Avv~vv %%3,  	 r   N)rT   rU   rV   __tags__r   r   r   
get_driverr   	Exceptionr   r\   r   r   rs   rs      sn    -.H >>$$&%/%H(!  (!s   A" "A-,A-rs   c                 z   d|_         | j                         \  }}|d|z  z
  }|d|z  z
  }t        d|j                         z        }	|||	z   }}
|j	                  d      }t        |      D ]  }|dk(  r|||	z   }}
|j	                  |      }|
|j                  z   |j                  z   |k\  r|||	z   }}
|
|j                  z   |j                  z   |k\  rt        d      ||j                  z   |j                  z
  |k\  rt        d      |j                  | |
|fd |       |
|j                  |j                  z   z  }
 |
|fS )NT   g      ? 
zword too wide for the surfaceztext to long for the surface)originget_sizeintget_sized_heightget_rectiwordswidthxrD   heighty	render_to)surfr   r   margincolor
surf_widthsurf_heightr   r   line_spacingr   r   spacewordboundss                  r   r   r      sK   DK"mmoJV#E1v:%Ftd33556L6L(qAMM#Et ,4<1|+qA]]4(F6<<&((*e3q</16<<&((*e3 !@AA6== 688+v5 !?@@NN4!Qu5++A, a4Kr   c              #     K   d}|}t        |       }||k  ri| |   dk(  r|dz  }|dz   }nO| |   dk(  r|dz  }d |dz   }n8||k(  r
| |d   |}n)| |   dk(  r
| ||  |}n| |   dk(  r
| ||  |}n|dz  }||k  rhy y w)Nr   r   r   r   )len)r   headtailends       r   r   r     s      DD
d)C
*:AID!8D$Z4AIDJ!8DS[tu+D$Z4tD/!D$Z3tD/!DAID% *s   A<B?B__main__)r   )r   r   r   )osrZ   environr'   r   rX   pygame.tests.test_utilsr   r   r   TestCaser
   r^   rs   r   r   rT   mainr\   r   r   <module>r      s    	 
::>>#$/.H  7  g$h'' g$TIx'8'8 IX3!** 3!l06 zHMMO r   