o
    >hu                     @  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 paintsr   ~/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/twisted/conch/test/test_window.py<lambda>   s   
 z5TopWindowTests.test_paintScheduling.<locals>.<lambda>   N)r   r   assertEqualrepaintlenpop)self	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parent	_viewport)r   widget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).0_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&   r6   r   r   r   r   test_selectionDownArrow\      z&SelectionTests.test_selectionDownArrowc                 C  r9   )zM
        Send UP_ARROW to select element just above the current one.
        N   )r)   r;   r   UP_ARROWr&   r6   r=   r   r   r   test_selectionUpArrowc   r?   z$SelectionTests.test_selectionUpArrowc                 C  r9   )zQ
        Send PGDN to select element one page down (here: last element).
        N	   )r)   r;   r   PGDNr&   r6   r=   r   r   r   test_selectionPGDNj   r?   z!SelectionTests.test_selectionPGDNc                 C  r9   )zP
        Send PGUP to select element one page up (here: first element).
        Nr   )r)   r;   r   PGUPr&   r6   r=   r   r   r   test_selectionPGUPq   r?   z!SelectionTests.test_selectionPGUPNr   )	r    r!   r"   r#   r8   r>   rB   rE   rG   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__	triggeredr=   r   r   r   rI      s   

zRecordingWidget.__init__modifierstrc                 C     | j d d S )NF1rJ   r   r   rK   r   r   r   func_F1      zRecordingWidget.func_F1c                 C  rM   )NHOMErO   rP   r   r   r   	func_HOME   rR   zRecordingWidget.func_HOMEc                 C  rM   )Nr<   rO   rP   r   r   r   func_DOWN_ARROW   rR   zRecordingWidget.func_DOWN_ARROWc                 C  rM   )NrA   rO   rP   r   r   r   func_UP_ARROW   rR   zRecordingWidget.func_UP_ARROWc                 C  rM   )NrD   rO   rP   r   r   r   	func_PGDN   rR   zRecordingWidget.func_PGDNc                 C  rM   )NrF   rO   rP   r   r   r   	func_PGUP   rR   zRecordingWidget.func_PGUPNr   )rK   rL   r   r   )r    r!   r"   r#   rI   rQ   rT   rU   rV   rW   rX   r   r   r   r   rH   y   s    





rH   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.
        keyrL   r   r   c                   s0    tt| d   | gj j  d S r   )functionKeyReceivedgetattrr   r   rJ   clear)rZ   r   r)   r   r   checkOneKey   s   zLWidgetFunctionKeyTests.test_functionKeyReceivedDispatch.<locals>.checkOneKeyrN   rS   r<   rA   rD   rF   N)rZ   rL   r   r   )rH   )r   r_   r   r^   r    test_functionKeyReceivedDispatch   s   z7WidgetFunctionKeyTests.test_functionKeyReceivedDispatchNr   )r    r!   r"   r#   r`   r   r   r   r   rY      r$   rY   N)r#   
__future__r   typingr   twisted.conch.insults.insultsr   twisted.conch.insults.windowr   r   r   r   r	   twisted.trial.unittestr
   r   r%   r,   rH   rY   r   r   r   r   <module>   s    )+