SLACTools.py 6.14 KB
Newer Older
Kenneth Moreland's avatar
Kenneth Moreland committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#/usr/bin/env python

import QtTesting
import QtTestingImage


#############################################################################
# Load the SLACTools plugin.

object1 = 'pqClientMainWindow/menubar'
QtTesting.playCommand(object1, 'activate', 'menuTools')
object2 = 'pqClientMainWindow/menubar/menuTools'
QtTesting.playCommand(object2, 'activate', 'actionManage_Plugins')

object3 = 'pqClientMainWindow/PluginManagerDialog/localGroup/localPlugins'
QtTesting.playCommand(object3, 'setCurrent', 'SLACTools')
object4 = 'pqClientMainWindow/PluginManagerDialog/localGroup/loadSelected_Local'
QtTesting.playCommand(object4, 'activate', '')

object5 = 'pqClientMainWindow/PluginManagerDialog/buttonBox/1QPushButton0'
QtTesting.playCommand(object5, 'activate', '')


#############################################################################
# Load the pic-example SLAC files.

object6 = 'pqSLACActionHolder/actionDataLoadManager'
QtTesting.playCommand(object6, 'activate', '')

object7 = 'pqClientMainWindow/pqSLACDataLoadManager/meshFile/FileButton'
QtTesting.playCommand(object7, 'activate', '')
object8 = 'pqClientMainWindow/pqSLACDataLoadManager/meshFile/pqFileDialog'
QtTesting.playCommand(object8, 'filesSelected', '$PARAVIEW_DATA_ROOT/Data/SLAC/pic-example/mesh.ncdf')

object9 = 'pqClientMainWindow/pqSLACDataLoadManager/modeFile/FileButton'
QtTesting.playCommand(object9, 'activate', '')
object8 = 'pqClientMainWindow/pqSLACDataLoadManager/modeFile/pqFileDialog'
QtTesting.playCommand(object8, 'filesSelected', '$PARAVIEW_DATA_ROOT/Data/SLAC/pic-example/fields_..mod')

object10 = 'pqClientMainWindow/pqSLACDataLoadManager/particlesFile/FileButton'
QtTesting.playCommand(object10, 'activate', '')
object8 = 'pqClientMainWindow/pqSLACDataLoadManager/particlesFile/pqFileDialog'
QtTesting.playCommand(object8, 'filesSelected', '$PARAVIEW_DATA_ROOT/Data/SLAC/pic-example/particles_..ncdf')

object11 = 'pqClientMainWindow/pqSLACDataLoadManager/buttonBox/1QPushButton0'
QtTesting.playCommand(object11, 'activate', '')

#Image compare
snapshotWidget = 'pqClientMainWindow/centralwidget/MultiViewManager/SplitterFrame/MultiViewSplitter/0/Viewport'
50 51 52 53 54 55
# For some reason, the snapshot is being grabbed before the image is updated
# when the dialog closes.  To get around this issue, simulate a mouse click
# in the view.  I'm not really happy with this hack because it won't catch if
# accepting the dialog really doesn't render the final view.
QtTesting.playCommand(snapshotWidget, 'mousePress', '(0.5,0.5,1,1,0)')
QtTesting.playCommand(snapshotWidget, 'mouseRelease', '(0.5,0.5,1,0,0)')
Kenneth Moreland's avatar
Kenneth Moreland committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
QtTestingImage.compareImage(snapshotWidget, 'SLACToolsInitialLoad.png', 300, 300);


#############################################################################
# Show the magnetic (b) field and change the representation to solid+wireframe.

object1 = 'pqSLACActionHolder/actionShowBField'
QtTesting.playCommand(object1, 'activate', '')

object2 = 'pqSLACActionHolder/actionWireframeSolidMesh'
QtTesting.playCommand(object2, 'activate', '')

#Image compare
snapshotWidget = 'pqClientMainWindow/centralwidget/MultiViewManager/SplitterFrame/MultiViewSplitter/0/Viewport'
QtTestingImage.compareImage(snapshotWidget, 'SLACToolsBFieldWireSolid.png', 300, 300);

#############################################################################
# Rotate the camera, show front wireframe + solid back, show electric (e)
# field scaled to all time steps, turn off particles.

# Make window 300x300
object1 = 'pqClientMainWindow/menubar'
QtTesting.playCommand(object1, 'activate', 'menuTools')
object2 = 'pqClientMainWindow/menubar/menuTools'
QtTesting.playCommand(object2, 'activate', 'actionTesting_Window_Size')

object3 = 'pqClientMainWindow/centralwidget/MultiViewManager/SplitterFrame/MultiViewSplitter/0/Viewport'
QtTesting.playCommand(object3, 'mousePress', '(0.863333,0.543333,1,1,0)')
QtTesting.playCommand(object3, 'mouseMove', '(0.743333,0.633333,1,0,0)')
QtTesting.playCommand(object3, 'mouseRelease', '(0.743333,0.633333,1,0,0)')

# Restore window
QtTesting.playCommand(object1, 'activate', 'menuTools')
QtTesting.playCommand(object2, 'activate', 'actionTesting_Window_Size')

object4 = 'pqSLACActionHolder/actionWireframeAndBackMesh'
QtTesting.playCommand(object4, 'activate', '')

object5 = 'pqSLACActionHolder/actionShowEField'
QtTesting.playCommand(object5, 'activate', '')

object6 = 'pqSLACActionHolder/actionTemporalResetRange'
QtTesting.playCommand(object6, 'activate', '')

object7 = 'pqSLACActionHolder/actionShowParticles'
QtTesting.playCommand(object7, 'set_boolean', 'false')

#Image compare
snapshotWidget = 'pqClientMainWindow/centralwidget/MultiViewManager/SplitterFrame/MultiViewSplitter/0/Viewport'
QtTestingImage.compareImage(snapshotWidget, 'SLACToolsWireEFieldTempResetHideP.png', 300, 300);

#############################################################################
# Restore black background, restore solid, restore particles, restore camera

object1 = 'pqSLACActionHolder/actionToggleBackgroundBW'
QtTesting.playCommand(object1, 'activate', '')

object2 = 'pqSLACActionHolder/actionSolidMesh'
QtTesting.playCommand(object2, 'activate', '')

object3 = 'pqSLACActionHolder/actionShowParticles'
QtTesting.playCommand(object3, 'set_boolean', 'true')

object5 = 'pqSLACActionHolder/actionShowStandardViewpoint'
QtTesting.playCommand(object5, 'activate', '')

#Image compare
snapshotWidget = 'pqClientMainWindow/centralwidget/MultiViewManager/SplitterFrame/MultiViewSplitter/0/Viewport'
QtTestingImage.compareImage(snapshotWidget, 'SLACToolsBlackBackReset.png', 300, 300);

#############################################################################
# Plot over Z axis, change time.

object6 = 'pqSLACActionHolder/actionPlotOverZ'
QtTesting.playCommand(object6, 'activate', '')

object7 = 'pqClientMainWindow/VCRToolbar/actionVCRNextFrame'
QtTesting.playCommand(object7, 'activate', '')

135 136 137
object8 = 'pqClientMainWindow/centralwidget/MultiViewManager/SplitterFrame/MultiViewSplitter/0/MultiViewFrameMenu/CloseAction'
QtTesting.playCommand(object8, 'activate', '')

Kenneth Moreland's avatar
Kenneth Moreland committed
138
#Image compare
139
snapshotWidget = 'pqClientMainWindow/centralwidget/MultiViewManager/SplitterFrame/MultiViewSplitter/0/Viewport'
Kenneth Moreland's avatar
Kenneth Moreland committed
140
QtTestingImage.compareImage(snapshotWidget, 'SLACToolsPlotOverZ.png', 300, 300);