a
    §ˆcÃ  ã                   @   sT   d dl mZ d dlmZ d dlmZmZ d dlmZ d dl	m
Z
 G dd„ deƒZdS )	é    )Úpatch)ÚUnittestTools)ÚActionÚMenuManager)ÚGUI©ÚWindowc                   @   s`   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
dd„ Zdd„ Zdd„ ZdS )ÚWidgetMixinz8 Mixin which provides standard methods for all widgets. c                 C   sT   t ƒ | _|  ¡ | _| j ¡  |  | j¡ | j ¡  |  ¡ | _	| j 
¡  | j ¡  d S ©N)r   ÚguiÚ_create_parentÚparentÚ_createÚ
addCleanupÚ_destroy_parentÚprocess_eventsÚ_create_widgetÚwidgetÚopen©Úself© r   ú^/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/testing/widget_mixin.pyÚsetUp   s    




zWidgetMixin.setUpc                 C   s   t ƒ S r
   r   r   r   r   r   r   $   s    zWidgetMixin._create_parentc                 C   s
   t ƒ ‚d S r
   )ÚNotImplementedErrorr   r   r   r   r   '   s    zWidgetMixin._create_widgetc                 C   s0   | j  ¡  |  | j¡ | j  d¡ | j ¡  d S )NT)r   r   r   Ú_destroy_widgetÚshowr   r   r   r   r   r   Ú_create_widget_control*   s    
z"WidgetMixin._create_widget_controlc                 C   s   | j  ¡  | j ¡  d | _ d S r
   )r   Údestroyr   r   r   r   r   r   r   0   s    

zWidgetMixin._destroy_parentc                 C   s   | j  ¡  | j ¡  d | _ d S r
   )r   r   r   r   r   r   r   r   r   5   s    

zWidgetMixin._destroy_widgetc                 C   s0   |   ¡  d| j_| j ¡  |  | j ¡ d¡ d S )NúNew tooltip.)r   r   Útooltipr   r   ÚassertEqualZ_get_control_tooltipr   r   r   r   Útest_widget_tooltip:   s    
zWidgetMixin.test_widget_tooltipc              	   C   s–   |   ¡ }tj|dd d��f}| ¡  z*| d¡ | j ¡  W | ¡  | j ¡  n| ¡  | j ¡  0 d|_| 	¡  W d   ƒ n1 s„0    Y  d }d S )NZ_tooltip_updated©Zreturn_valueTr   )
r   r   Úobjectr   r   r   r   r   r    Úassert_not_called©r   r   Úupdatedr   r   r   Útest_widget_tooltip_cleanupA   s    
ÿ&z'WidgetMixin.test_widget_tooltip_cleanupc                 C   s,   |   ¡  ttdd�dd�| j_| j ¡  d S )NÚTest©Úname)r   r   r   r   Úcontext_menur   r   r   r   r   r   Útest_widget_menuR   s    zWidgetMixin.test_widget_menuc              	   C   s¤   |   ¡ }tj|dd d��t}| ¡  z*| d¡ | j ¡  W | ¡  | j ¡  n| ¡  | j ¡  0 tt	dd�dd�|_
| ¡  W d   ƒ n1 s’0    Y  d }d S )NZ_context_menu_updatedr#   Tr)   r*   )r   r   r$   r   r   r   r   r   r   r   r,   r%   r&   r   r   r   Ú test_widget_context_menu_cleanupX   s    
ÿ&z,WidgetMixin.test_widget_context_menu_cleanupN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r"   r(   r-   r.   r   r   r   r   r	      s   r	   N)Zunittest.mockr   Ztraits.testing.apir   Zpyface.action.apir   r   Z
pyface.guir   Zpyface.windowr   r	   r   r   r   r   Ú<module>   s
   