B � f �@s�dZddlmZmZddlmZed�ddlmZddlZddl m Z m Z m Z ddl Z dd �Zd d �Zd d �Zdd�ZGdd�de j�ZGdd�de j�Zedkr�e jdd�dS)z�Test tooltip, coverage 100%. Coverage is 100% after excluding 6 lines with "# pragma: no cover". They involve TclErrors that either should or should not happen in a particular situation, and which are 'pass'ed if they do. �)� TooltipBase�Hovertip)�requiresZgui)�wrapsN)�Button�Tk�ToplevelcCs t�adS)N)r�root�r r �C/opt/alt/python37/lib64/python3.7/idlelib/idle_test/test_tooltip.py� setUpModulesr cCst��t��bdS)N)r Zupdate_idletasks�destroyr r r r �tearDownModulesrcs t����fdd���g�_�S)Ncs�j�||f��||�S)N)�call_args_list�append)�args�kwargs)�func� wrapped_funcr r rsz'add_call_counting..wrapped_func)rr)rr )rrr �add_call_countingsrcCsNtt�}|�|j�|�d�t|dd�}|��|�|j�|��||fS)Nz Test tooltipzToolTip test button)�text)rr � addCleanupr �titler�packZlift)Ztestobj�top�buttonr r r �_make_top_and_button&s    rc@seZdZdd�Zdd�ZdS)�ToolTipBaseTestcCst|�\|_|_dS)N)rrr)�selfr r r �setUp3szToolTipBaseTest.setUpc Cs^tt�}|�|j�t|dd�}|��|�|j�|�t��t|�}|� �WdQRXdS)NzToolTip test button)r) rr rr rrZ assertRaises�NotImplementedErrorr�showtip)rrr�tooltipr r r �test_base_class_is_unusable6s    z+ToolTipBaseTest.test_base_class_is_unusableN)�__name__� __module__� __qualname__rr#r r r r r2src@sLeZdZdd�Zdd�Zdd�Zdd�Zd d �Zd d �Zd d�Z dd�Z dS)� HovertipTestcCst|�\|_|_dS)N)rrr)rr r r rEszHovertipTest.setUpcCs|jo|j��S)N)� tipwindowZwinfo_viewable)rr"r r r �is_tipwindow_shownHszHovertipTest.is_tipwindow_showncCsDt|jd�}|�|j�|�|�|��|��|�|�|��dS)Nz ToolTip text)rrr�hidetip� assertFalser)r!� assertTrue)rr"r r r � test_showtipKs   zHovertipTest.test_showtipcCspt|jd�}|�|j�|�|�|��|��|�|�|��|j}|��|�|�|��|� |j|�dS)Nz ToolTip text) rrrr*r+r)r!r,r(ZassertIs)rr"Zorig_tipwindowr r r �test_showtip_twiceRs  zHovertipTest.test_showtip_twicecCs<t|jd�}|�|j�|��|��|�|�|��dS)Nz ToolTip text)rrrr*r!r+r))rr"r r r � test_hidetip]s   zHovertipTest.test_hidetipcCs�t|jddd�}|�|j�t|j�|_t��|�|� |��|jj dddd�t��|� |� |��|� t |jj�d�dS)Nz ToolTip text)� hover_delayzr)�x�y)rrrr*rr!r �updater+r)�event_generater,� assertGreater�lenr)rr"r r r �$test_showtip_on_mouse_enter_no_delayds  z1HovertipTest.test_showtip_on_mouse_enter_no_delaycCs(t|jddd�}|�|j�t|j�|_t��|�|� |��|jj dddd�t��|�|� |��t|jddd�}|�|j�t|j�|_t��|jj dddd�t��|jj dddd�t��t � d�t��|� |� |��|�t|jj�d�|�|� |��|�|jjg�dS) Nz ToolTip text�d)r0zr)r1r2zg333333�?)rrrr*rr!r r3r+r)r4�timeZsleepr,r5r6rZ assertEqual)rZtooltip1Ztooltip2r r r �test_hover_with_delayos,     z"HovertipTest.test_hover_with_delaycCs�t|jddd�}|�|j�t|j�|_t��|jjdddd�t��|jjdddd�t��|� |� |��|� t |jj �d�dS)Nz ToolTip text)r0zr)r1r2z)rrrr*rr!r r3r4r+r)r5r6r)rr"r r r �test_hidetip_on_mouse_leave�s  z(HovertipTest.test_hidetip_on_mouse_leaveN) r$r%r&rr)r-r.r/r7r:r;r r r r r'Ds  $r'�__main__�)� verbosity)�__doc__Zidlelib.tooltiprrZ test.supportr� functoolsrr9ZtkinterrrrZunittestr rrrZTestCaserr'r$�mainr r r r �s    \