o
    Òó·iu  ã                   @  s¤   d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	m
Z
mZmZ ddlmZ G dd„ deƒZG d	d
„ d
eƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZdS )zJ
Tests for the insults windowing module, L{twisted.conch.insults.window}.
é    )Úannotations)ÚCallable)ÚServerProtocol)ÚScrolledAreaÚ	SelectionÚ
TextOutputÚ	TopWindowÚWidget)ÚTestCasec                   @  ó   e Zd ZdZddd„ZdS )ÚTopWindowTestszB
    Tests for L{TopWindow}, the root window container class.
    ÚreturnÚNonec                   sÎ   g ‰ g }t ‡ fdd„|jƒ}|  ˆ g ¡ |  |g ¡ | ¡  |  ˆ g ¡ |  t|ƒd¡ | ¡  |  ˆ g ¡ |  t|ƒd¡ | ¡ ƒ  |  tˆ ƒd¡ |  |g ¡ | ¡  |  tˆ ƒd¡ |  t|ƒd¡ dS )z”
        Verify that L{TopWindow.repaint} schedules an actual paint to occur
        using the scheduling object passed to its initializer.
        c                     s
   ˆ   d ¡S ©N)Úappend© ©Zpaintsr   údC:\Users\psant\Downloads\PAF backend\school\venv\Lib\site-packages\twisted/conch/test/test_window.pyÚ<lambda>   s   
 z5TopWindowTests.test_paintScheduling.<locals>.<lambda>é   N)r   r   ÚassertEqualZrepaintÚlenÚpop)ÚselfZ	scheduledÚrootr   r   r   Útest_paintScheduling   s"   
z#TopWindowTests.test_paintSchedulingN©r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r      ó    r   c                   @  r   )ÚScrolledAreaTestsz—
    Tests for L{ScrolledArea}, a widget which creates a viewport containing
    another widget and can reposition that viewport using scrollbars.
    r   r   c                 C  s2   t ƒ }t|ƒ}|  |j|j¡ |  |jj|¡ dS )zÌ
        The parent of the widget passed to L{ScrolledArea} is set to a new
        L{Viewport} created by the L{ScrolledArea} which itself has the
        L{ScrolledArea} instance as its parent.
        N)r   r   ÚassertIsÚparentZ	_viewport)r   ÚwidgetZscrolledr   r   r   Útest_parentB   s   zScrolledAreaTests.test_parentNr   )r   r   r   r    r&   r   r   r   r   r"   <   s    r"   c                   @  sB   e Zd ZdZddd„Zddd„Zddd	„Zdd
d„Zddd„ZdS )ÚSelectionTestszC
    Change focused entry in L{Selection} using function keys.
    r   r   c                 C  s2   dd„ t dƒD ƒ}t|dƒ| _d| j_d| j_dS )zg
        Create L{ScrolledArea} widget with 10 elements and position selection to 5th element.
        c                 S  s   g | ]}|›   d ¡‘qS )Úascii)Úencode)Ú.0Z_numr   r   r   Ú
<listcomp>W   s    z(SelectionTests.setUp.<locals>.<listcomp>é
   Né   )Úranger   r%   ÚheightÚfocusedIndex)r   Úseqr   r   r   ÚsetUpS   s   zSelectionTests.setUpc                 C  ó$   | j  tjd¡ |  | j jd¡ dS )zO
        Send DOWN_ARROW to select element just below the current one.
        Né   )r%   ÚkeystrokeReceivedr   Ú
DOWN_ARROWr#   r0   ©r   r   r   r   Útest_selectionDownArrow\   ó   z&SelectionTests.test_selectionDownArrowc                 C  r3   )zM
        Send UP_ARROW to select element just above the current one.
        Né   )r%   r5   r   ÚUP_ARROWr#   r0   r7   r   r   r   Útest_selectionUpArrowc   r9   z$SelectionTests.test_selectionUpArrowc                 C  r3   )zQ
        Send PGDN to select element one page down (here: last element).
        Né	   )r%   r5   r   ÚPGDNr#   r0   r7   r   r   r   Útest_selectionPGDNj   r9   z!SelectionTests.test_selectionPGDNc                 C  r3   )zP
        Send PGUP to select element one page up (here: first element).
        Nr   )r%   r5   r   ÚPGUPr#   r0   r7   r   r   r   Útest_selectionPGUPq   r9   z!SelectionTests.test_selectionPGUPNr   )	r   r   r   r    r2   r8   r<   r?   rA   r   r   r   r   r'   N   s    

	

r'   c                   @  sV   e Zd ZdZddd„Zddd	„Zdd
d„Zddd„Zddd„Zddd„Z	ddd„Z
dS )ÚRecordingWidgetzn
    A dummy Widget implementation to test handling of function keys by
    recording keyReceived events.
    r   r   c                 C  s   t  | ¡ g | _d S r   )r	   Ú__init__Ú	triggeredr7   r   r   r   rC      s   

zRecordingWidget.__init__ÚmodifierÚstrc                 C  ó   | j  d¡ d S )NÚF1©rD   r   ©r   rE   r   r   r   Úfunc_F1ƒ   ó   zRecordingWidget.func_F1c                 C  rG   )NÚHOMErI   rJ   r   r   r   Ú	func_HOME†   rL   zRecordingWidget.func_HOMEc                 C  rG   )Nr6   rI   rJ   r   r   r   Úfunc_DOWN_ARROW‰   rL   zRecordingWidget.func_DOWN_ARROWc                 C  rG   )Nr;   rI   rJ   r   r   r   Úfunc_UP_ARROWŒ   rL   zRecordingWidget.func_UP_ARROWc                 C  rG   )Nr>   rI   rJ   r   r   r   Ú	func_PGDN�   rL   zRecordingWidget.func_PGDNc                 C  rG   )Nr@   rI   rJ   r   r   r   Ú	func_PGUP’   rL   zRecordingWidget.func_PGUPNr   )rE   rF   r   r   )r   r   r   r    rC   rK   rN   rO   rP   rQ   rR   r   r   r   r   rB   y   s    





rB   c                   @  r   )ÚWidgetFunctionKeyTestszN
    Call functionKeyReceived with key values from insults.ServerProtocol
    r   r   c                   sJ   t ƒ ‰d‡ ‡fdd„}|dƒ |dƒ |d	ƒ |d
ƒ |dƒ |dƒ dS )zŒ
        L{Widget.functionKeyReceived} dispatches its input, a constant on
        ServerProtocol, to a matched C{func_KEY} method.
        ÚkeyrF   r   r   c                   s0   ˆ  tt| ƒd ¡ ˆ  | gˆj¡ ˆj ¡  d S r   )ZfunctionKeyReceivedÚgetattrr   r   rD   Úclear)rT   ©r   r%   r   r   ÚcheckOneKey¢   s   zLWidgetFunctionKeyTests.test_functionKeyReceivedDispatch.<locals>.checkOneKeyrH   rM   r6   r;   r>   r@   N)rT   rF   r   r   )rB   )r   rX   r   rW   r   Ú test_functionKeyReceivedDispatch›   s   z7WidgetFunctionKeyTests.test_functionKeyReceivedDispatchNr   )r   r   r   r    rY   r   r   r   r   rS   –   r!   rS   N)r    Ú
__future__r   Útypingr   Ztwisted.conch.insults.insultsr   Ztwisted.conch.insults.windowr   r   r   r   r	   Ztwisted.trial.unittestr
   r   r"   r'   rB   rS   r   r   r   r   Ú<module>   s    )+