
    Vhu                        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e      Z G d	 d
e      Z G d de      Z G d de      Z G d de      Zy)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Zy)TopWindowTestszB
    Tests for L{TopWindow}, the root window container class.
    c                   g g }t        fd|j                        }| j                  g        | j                  |g        |j                          | j                  g        | j                  t	        |      d       |j                          | j                  g        | j                  t	        |      d        |j                                 | j                  t	              d       | j                  |g        |j                          | j                  t	              d       | j                  t	        |      d       y)z
        Verify that L{TopWindow.repaint} schedules an actual paint to occur
        using the scheduling object passed to its initializer.
        c                 &     j                  d       S N)append)paintss   N/home/dcms/DCMS/lib/python3.12/site-packages/twisted/conch/test/test_window.py<lambda>z5TopWindowTests.test_paintScheduling.<locals>.<lambda>   s    t!4        N)r	   r   assertEqualrepaintlenpop)self	scheduledrootr   s      @r   test_paintSchedulingz#TopWindowTests.test_paintScheduling   s	   
  02	4i6F6FG 	$B' 	$Y+ 	$Y+ 		Va(B' 	Va(Y+r   NreturnNone)__name__
__module____qualname____doc__r    r   r   r   r      s    !,r   r   c                      e Zd ZdZddZy)ScrolledAreaTestsz
    Tests for L{ScrolledArea}, a widget which creates a viewport containing
    another widget and can reposition that viewport using scrollbars.
    c                    t               }t        |      }| j                  |j                  |j                         | j                  |j                  j                  |       y)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parent	_viewport)r   widgetscrolleds      r   test_parentzScrolledAreaTests.test_parentB   sG     'fmmX%7%78h((//:r   Nr   )r"   r#   r$   r%   r/   r&   r   r   r(   r(   <   s    
	;r   r(   c                  8    e Zd ZdZddZddZddZddZddZy)	SelectionTestszC
    Change focused entry in L{Selection} using function keys.
    c                    t        d      D cg c]  }| j                  d       }}t        |d      | _        d| j                  _        d| j                  _        yc c}w )zg
        Create L{ScrolledArea} widget with 10 elements and position selection to 5th element.
        
   asciiN   )rangeencoder   r-   heightfocusedIndex)r   _numseqs      r   setUpzSelectionTests.setUpS   sV     CH)L$tf,,W5LLT*#$  Ms   Ac                    | j                   j                  t        j                  d       | j	                  | j                   j
                  d       y)zO
        Send DOWN_ARROW to select element just below the current one.
        N   )r-   keystrokeReceivedr   
DOWN_ARROWr*   r9   r   s    r   test_selectionDownArrowz&SelectionTests.test_selectionDownArrow\   s6     	%%n&?&?Fdkk..2r   c                    | j                   j                  t        j                  d       | j	                  | j                   j
                  d       y)zM
        Send UP_ARROW to select element just above the current one.
        N   )r-   r?   r   UP_ARROWr*   r9   rA   s    r   test_selectionUpArrowz$SelectionTests.test_selectionUpArrowc   s6     	%%n&=&=tDdkk..2r   c                    | j                   j                  t        j                  d       | j	                  | j                   j
                  d       y)zQ
        Send PGDN to select element one page down (here: last element).
        N	   )r-   r?   r   PGDNr*   r9   rA   s    r   test_selectionPGDNz!SelectionTests.test_selectionPGDNj   6     	%%n&9&94@dkk..2r   c                    | j                   j                  t        j                  d       | j	                  | j                   j
                  d       y)zP
        Send PGUP to select element one page up (here: first element).
        Nr   )r-   r?   r   PGUPr*   r9   rA   s    r   test_selectionPGUPz!SelectionTests.test_selectionPGUPq   rK   r   Nr   )	r"   r#   r$   r%   r<   rB   rF   rJ   rN   r&   r   r   r1   r1   N   s     %3333r   r1   c                  H    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
y	)RecordingWidgetzn
    A dummy Widget implementation to test handling of function keys by
    recording keyReceived events.
    c                <    t        j                  |        g | _        y r   )r
   __init__	triggeredrA   s    r   rR   zRecordingWidget.__init__   s    $&r   c                :    | j                   j                  d       y )NF1rS   r   r   modifiers     r   func_F1zRecordingWidget.func_F1   s    d#r   c                :    | j                   j                  d       y )NHOMErV   rW   s     r   	func_HOMEzRecordingWidget.func_HOME       f%r   c                :    | j                   j                  d       y )Nr@   rV   rW   s     r   func_DOWN_ARROWzRecordingWidget.func_DOWN_ARROW   s    l+r   c                :    | j                   j                  d       y )NrE   rV   rW   s     r   func_UP_ARROWzRecordingWidget.func_UP_ARROW   s    j)r   c                :    | j                   j                  d       y )NrI   rV   rW   s     r   	func_PGDNzRecordingWidget.func_PGDN   r]   r   c                :    | j                   j                  d       y )NrM   rV   rW   s     r   	func_PGUPzRecordingWidget.func_PGUP   r]   r   Nr   )rX   strr    r!   )r"   r#   r$   r%   rR   rY   r\   r_   ra   rc   re   r&   r   r   rP   rP   y   s*    
'$&,*&&r   rP   c                      e Zd ZdZddZy)WidgetFunctionKeyTestszN
    Call functionKeyReceived with key values from insults.ServerProtocol
    c                     t               d	 fd} |d        |d        |d        |d        |d        |d       y)
z
        L{Widget.functionKeyReceived} dispatches its input, a constant on
        ServerProtocol, to a matched C{func_KEY} method.
        c                    j                  t        t        |       d        j                  | gj                         j                  j                          y r   )functionKeyReceivedgetattrr   r   rS   clear)keyr   r-   s    r   checkOneKeyzLWidgetFunctionKeyTests.test_functionKeyReceivedDispatch.<locals>.checkOneKey   sD    &&w~s'CTJcUF$4$45""$r   rU   r[   r@   rE   rI   rM   N)rn   rf   r    r!   )rP   )r   ro   r-   s   ` @r    test_functionKeyReceivedDispatchz7WidgetFunctionKeyTests.test_functionKeyReceivedDispatch   sD    
 !"	%
 	DFL!JFFr   Nr   )r"   r#   r$   r%   rp   r&   r   r   rh   rh      s    r   rh   N)r%   
__future__r   typingr   twisted.conch.insults.insultsr   twisted.conch.insults.windowr   r   r   r	   r
   twisted.trial.unittestr   r   r(   r1   rP   rh   r&   r   r   <module>rv      sb    #  8  ,&,X &,R; ;$(3X (3V&f &:X r   