a
    «ˆcŽ  ã                   @   s–   d dl mZ d dlmZ d dlZd dlZd dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d d	lmZ G d
d„ dejƒZedkr’e ¡  dS )é    )Úabspath)ÚBytesION)Údatasets)ÚEngine)Ú
NullEngine)ÚVTKDataSource)ÚOutline)Ú	GridPlanec                   @   s<   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )ÚTestGridPlanec           	      C   sÄ   t ƒ }| ¡  | ¡  || _t ¡ }t|d�}| |¡ tƒ }| 	|¡ t
ƒ }| 	|¡ t
ƒ }d|j_d|j_| 	|¡ t
ƒ }| 	|¡ d|j_d|j_|||fD ]}|jjjdd� q¢|j| _dS )	zlInitial setting up of test fixture, automatically called by TestCase before any other test method is invoked)ÚdataÚyé   Úzé   ç      ð?)ÚambientN)r   ÚstartZ	new_sceneÚer   ZgenerateStructuredGridr   Z
add_sourcer   Z
add_moduler	   Ú
grid_planeÚaxisÚpositionÚactorÚpropertyZ	trait_setÚcurrent_sceneÚscene)	Úselfr   ZsgridÚsrcÚoÚgp1Úgp2Úgp3Zgp© r!   ú_/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/mayavi/tests/test_grid_plane.pyÚsetUp   s.    





zTestGridPlane.setUpc                 C   s   | j  ¡  dS )zaFor necessary clean up, automatically called by TestCase after the test methods have been invokedN)r   Ústop©r   r!   r!   r"   ÚtearDown@   s    
zTestGridPlane.tearDownc                 C   sÄ   | j }|jd jd }|jdd… \}}}|  |jjd¡ |  |jjd¡ |  |jjjd¡ |  |jjd¡ |  |jjd¡ |  |jjjd¡ |  |jjd¡ |  |jjd	¡ |  |jjjd¡ dS )
zDo the actual testing.r   é   NÚxr   r   r   r   r   )	r   ÚchildrenÚassertEqualr   r   r   r   r   r   )r   ÚsÚmmr   r   r    r!   r!   r"   ÚcheckE   s    zTestGridPlane.checkc                 C   s   |   ¡  dS )zTest if the test fixture worksN)r-   r%   r!   r!   r"   Útest_grid_planeW   s    zTestGridPlane.test_grid_planec                 C   sX   | j }| j}tƒ }tdƒ|_| |¡ | d¡ | |¡ | |¡ |j	| _|  
¡  dS )z6Test if saving a visualization and restoring it works.ztest.mv2r   N)r   r   r   r   ÚnameZsave_visualizationÚseekZclose_sceneZload_visualizationr   r-   )r   Zenginer   Úfr!   r!   r"   Útest_save_and_restore_   s    




z#TestGridPlane.test_save_and_restorec                 C   sD   | j }|j ¡ }|j |¡ |  ¡  t |¡}||jd< |  ¡  dS )z5Test if the MayaVi2 visualization can be deep-copied.r   N)r   r)   ÚpopÚappendr-   ÚcopyÚdeepcopy)r   r+   ÚsourceZsource1r!   r!   r"   Útest_deepcopiedu   s    


zTestGridPlane.test_deepcopiedN)	Ú__name__Ú
__module__Ú__qualname__r#   r&   r-   r.   r2   r8   r!   r!   r!   r"   r
      s   'r
   Ú__main__)Úos.pathr   Úior   r5   ZunittestZmayavi.testsr   Zmayavi.core.enginer   Zmayavi.core.null_enginer   Zmayavi.sources.vtk_data_sourcer   Zmayavi.modules.outliner   Zmayavi.modules.grid_planer	   ZTestCaser
   r9   Úmainr!   r!   r!   r"   Ú<module>   s   w