3
ÐÆ‘[Ž  ã               @   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jƒ  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 ƒ }|jƒ  |jƒ  || _tjƒ }t|d�}|j|ƒ tƒ }|j	|ƒ t
ƒ }|j	|ƒ t
ƒ }d|j_d|j_|j	|ƒ t
ƒ }|j	|ƒ d|j_d|j_x"|||fD ]}|jjjdd� q¤W |j| _dS )	zlInitial setting up of test fixture, automatically called by TestCase before any other test method is invoked)ÚdataÚyé   Úzé   g      ð?)ÚambientN)r   ÚstartZ	new_sceneÚer   ZgenerateStructuredGridr   Z
add_sourcer   Z
add_moduler	   Ú
grid_planeÚaxisÚpositionÚactorÚpropertyÚ	trait_setÚcurrent_sceneÚscene)	Úselfr   ZsgridÚsrcÚoÚgp1Úgp2Úgp3Zgp© r!   ú_/home/yuhw/wc/wire-cell-python/venv/lib/python3.6/site-packages/mayavi/tests/test_grid_plane.pyÚsetUp   s.    





zTestGridPlane.setUpc             C   s   | j 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jdƒ | j|jjdƒ | j|jjjdƒ | j|jjdƒ | j|jjdƒ | j|jjjdƒ | j|jjdƒ | j|jjd	ƒ | j|jjjdƒ dS )
zDo the actual testing.r   é   NÚxg      ð?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   | j ƒ  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ƒ|_|j|ƒ |jdƒ |j|ƒ |j|ƒ |j	| _| 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   Úenginer   Úfr!   r!   r"   Útest_save_and_restore_   s    




z#TestGridPlane.test_save_and_restorec             C   sD   | j }|jjƒ }|jj|ƒ | jƒ  tj|ƒ}||jd< | jƒ  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   ÚunittestZmayavi.testsr   Úmayavi.core.enginer   Úmayavi.core.null_enginer   Zmayavi.sources.vtk_data_sourcer   Zmayavi.modules.outliner   Zmayavi.modules.grid_planer	   ÚTestCaser
   r9   Úmainr!   r!   r!   r"   Ú<module>   s   w