Skip to content

Commit 1395462

Browse files
committed
added tests
1 parent 46bd5c6 commit 1395462

9 files changed

Lines changed: 226 additions & 6 deletions

Packages/vcsaddons/Lib/Multi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,10 @@ def get(self,column=None,row=None,legend=None,font=True,fontlimit=0.8):
337337
dx=self.legend.stretch
338338
dy=self.legend.thickness
339339
## print x1,x2,y1,y2,dx,dy
340-
t.legend.x1=x1+(x2-x1)*(1.-dx)/2.
341-
t.legend.x2=x2-(x2-x1)*(1.-dx)/2.
342-
t.legend.y1=y1+(y2-y1)*(1.-dy)/2.
343-
t.legend.y2=y2-(y2-y1)*(1.-dy)/2.
340+
t.legend.x1=min(1,max(0,x1+(x2-x1)*(1.-dx)/2.))
341+
t.legend.x2=min(1,max(0,x2-(x2-x1)*(1.-dx)/2.))
342+
t.legend.y1=min(1,max(0,y1+(y2-y1)*(1.-dy)/2.))
343+
t.legend.y2=min(1,max(0,y2-(y2-y1)*(1.-dy)/2.))
344344
return t
345345

346346
def preview(self,out='EZTemplate_Multi',bg=1):

testing/vcsaddons/CMakeLists.txt

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,43 @@ set(BASELINE_DIR "${UVCDAT_GIT_TESTDATA_DIR}/baselines/vcsaddons")
33
add_test(vcs_addons_preview_2x2
44
${CMAKE_INSTALL_PREFIX}/bin/python
55
${cdat_SOURCE_DIR}/testing/vcsaddons/test_vcsaddons_preview_2x2.py
6-
"${BASELINE_DIR}/test_vcsaddons_preview_2x2.png"
6+
${BASELINE_DIR}/test_vcsaddons_preview_2x2.png
7+
)
8+
add_test(vcs_addons_test_12_plot_one_leg_per_row
9+
${CMAKE_INSTALL_PREFIX}/bin/python
10+
${cdat_SOURCE_DIR}/testing/vcsaddons/test_12_plot_one_leg_per_row.py
11+
${BASELINE_DIR}/test_12_plot_one_leg_per_row.png
12+
)
13+
add_test(vcs_addons_test_12_plot_one_leg_per_row_right
14+
${CMAKE_INSTALL_PREFIX}/bin/python
15+
${cdat_SOURCE_DIR}/testing/vcsaddons/test_12_plot_one_leg_per_row_right.py
16+
${BASELINE_DIR}/test_12_plot_one_leg_per_row_right.png
17+
)
18+
add_test(vcs_addons_test_EzTemplate_12_plots_margins_thickness
19+
${CMAKE_INSTALL_PREFIX}/bin/python
20+
${cdat_SOURCE_DIR}/testing/vcsaddons/test_EzTemplate_12_plots_margins_thickness.py
21+
${BASELINE_DIR}/test_EzTemplate_12_plots_margins_thickness.png
22+
)
23+
add_test(vcs_addons_test_EzTemplate_12_plots_legd_direction
24+
${CMAKE_INSTALL_PREFIX}/bin/python
25+
${cdat_SOURCE_DIR}/testing/vcsaddons/test_EzTemplate_12_plots_legd_direction.py
26+
${BASELINE_DIR}/test_EzTemplate_12_plots_legd_direction.png
27+
)
28+
add_test(vcs_addons_test_EzTemplate_12_plots_mix_glb_local
29+
${CMAKE_INSTALL_PREFIX}/bin/python
30+
${cdat_SOURCE_DIR}/testing/vcsaddons/test_EzTemplate_12_plots_mix_glb_local.py
31+
${BASELINE_DIR}/test_EzTemplate_12_plots_mix_glb_local.png
32+
)
33+
add_test(vcs_addons_test_EzTemplate_12_plots_spacing
34+
${CMAKE_INSTALL_PREFIX}/bin/python
35+
${cdat_SOURCE_DIR}/testing/vcsaddons/test_EzTemplate_12_plots_spacing.py
36+
${BASELINE_DIR}/test_EzTemplate_12_plots_spacing.png
737
)
838

939
if (CDAT_DOWNLOAD_SAMPLE_DATA)
1040
add_test(vcs_addons_EzTemplate_2x2
1141
${CMAKE_INSTALL_PREFIX}/bin/python
1242
${cdat_SOURCE_DIR}/testing/vcsaddons/test_vcs_addons_EzTemplate_2x2.py
13-
"${BASELINE_DIR}/test_vcs_addons_EzTemplate_2x2.png"
43+
${BASELINE_DIR}/test_vcs_addons_EzTemplate_2x2.png
1444
)
1545
endif()
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import sys,os
2+
src = sys.argv[1]
3+
pth = os.path.join(os.path.dirname(__file__),"..")
4+
sys.path.append(pth)
5+
import checkimage
6+
import EzTemplate,vcs
7+
## 12 plot one legend per row
8+
9+
## Initialize VCS
10+
x=vcs.init()
11+
12+
bg = True
13+
M=EzTemplate.Multi(rows=4,columns=3)
14+
M.legend.stretch=2.5 # 250% of width (for middle one)
15+
for i in range(12):
16+
t=M.get(legend='local')
17+
if i%3 !=1:
18+
t.legend.priority=0 # Turn off legend
19+
fnm = "test_12_plot_one_leg_per_row.png"
20+
M.preview(fnm,bg=bg)
21+
print "fnm:",fnm
22+
print "src:",src
23+
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
24+
if not bg:
25+
raw_input("Press Enter")
26+
sys.exit(ret)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import sys,os
2+
src = sys.argv[1]
3+
pth = os.path.join(os.path.dirname(__file__),"..")
4+
sys.path.append(pth)
5+
import checkimage
6+
import EzTemplate,vcs
7+
import cdms,EzTemplate,vcs,sys
8+
## 12 plots 1 legend per row on the right
9+
## Initialize VCS
10+
x=vcs.init()
11+
bg=True
12+
M=EzTemplate.Multi(rows=4,columns=3)
13+
M.legend.direction='vertical'
14+
for i in range(12):
15+
t=M.get(legend='local')
16+
if i%3 !=2:
17+
t.legend.priority=0 # Turn off legend
18+
fnm = "test_12_plot_one_leg_per_row_right.png"
19+
M.preview(fnm,bg=bg)
20+
print "fnm:",fnm
21+
print "src:",src
22+
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
23+
if not bg:
24+
raw_input("Press Enter")
25+
sys.exit(ret)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import sys,os
2+
src = sys.argv[1]
3+
pth = os.path.join(os.path.dirname(__file__),"..")
4+
sys.path.append(pth)
5+
import checkimage
6+
import EzTemplate,vcs
7+
## 12 plot one legend per row
8+
9+
## Initialize VCS
10+
x=vcs.init()
11+
12+
bg = True
13+
M=EzTemplate.Multi(rows=4,columns=3)
14+
M.margins.top=.25
15+
M.margins.bottom=.25
16+
M.margins.left=.25
17+
M.margins.right=.25
18+
19+
M.legend.direction='vertical'
20+
## The legend uses the right margin for display are
21+
## We need to "shrink it"
22+
M.legend.thickness=.05
23+
for i in range(12):
24+
t=M.get()
25+
26+
fnm = "test_EzTemplate_12_plots_legd_direction.png"
27+
M.preview(fnm,bg=bg)
28+
print "fnm:",fnm
29+
print "src:",src
30+
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
31+
if not bg:
32+
raw_input("Press Enter")
33+
sys.exit(ret)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import sys,os
2+
src = sys.argv[1]
3+
pth = os.path.join(os.path.dirname(__file__),"..")
4+
sys.path.append(pth)
5+
import checkimage
6+
import EzTemplate,vcs
7+
## 12 plot one legend per row
8+
9+
## Initialize VCS
10+
x=vcs.init()
11+
12+
bg = True
13+
M=EzTemplate.Multi(rows=4,columns=3)
14+
M.margins.top=.25
15+
M.margins.bottom=.25
16+
M.margins.left=.25
17+
M.margins.right=.25
18+
19+
## The legend uses the bottom margin for display are
20+
## We need to "shrink it"
21+
M.legend.thickness=.1
22+
for i in range(12):
23+
t=M.get()
24+
fnm = "test_EzTemplate_12_plots_margins_thickness.png"
25+
M.preview(fnm,bg=bg)
26+
print "fnm:",fnm
27+
print "src:",src
28+
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
29+
if not bg:
30+
raw_input("Press Enter")
31+
sys.exit(ret)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import sys,os
2+
src = sys.argv[1]
3+
pth = os.path.join(os.path.dirname(__file__),"..")
4+
sys.path.append(pth)
5+
import checkimage
6+
import EzTemplate,vcs
7+
## 12 plot one legend per row
8+
9+
## Initialize VCS
10+
x=vcs.init()
11+
12+
bg = True
13+
M=EzTemplate.Multi(rows=4,columns=3)
14+
for i in range(12):
15+
if i%2==1:
16+
if i%4 == 3:
17+
M.legend.direction='vertical'
18+
t=M.get(legend='local')
19+
M.legend.direction='horizontal'
20+
else:
21+
t=M.get()
22+
23+
fnm = "test_EzTemplate_12_plots_mix_glb_local.png"
24+
M.preview(fnm,bg=bg)
25+
print "fnm:",fnm
26+
print "src:",src
27+
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
28+
if not bg:
29+
raw_input("Press Enter")
30+
sys.exit(ret)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import sys,os
2+
src = sys.argv[1]
3+
pth = os.path.join(os.path.dirname(__file__),"..")
4+
sys.path.append(pth)
5+
import checkimage
6+
import EzTemplate,vcs
7+
## 12 plot one legend per row
8+
9+
## Initialize VCS
10+
x=vcs.init()
11+
12+
bg = True
13+
M=EzTemplate.Multi(rows=4,columns=3)
14+
M.spacing.horizontal=.25
15+
M.spacing.vertical=.1
16+
17+
fnm = "test_EzTemplate_12_plots_spacing.png"
18+
M.preview(fnm,bg=bg)
19+
print "fnm:",fnm
20+
print "src:",src
21+
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
22+
if not bg:
23+
raw_input("Press Enter")
24+
sys.exit(ret)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import sys,os
2+
src = sys.argv[1]
3+
pth = os.path.join(os.path.dirname(__file__),"..")
4+
sys.path.append(pth)
5+
import checkimage
6+
7+
import vcsaddons
8+
9+
bg = True
10+
11+
M=vcsaddons.EzTemplate.Multi(rows=2,columns=2)
12+
if bg:
13+
M.x.setbgoutputdimensions(1200,1091,units="pixels")
14+
fnm = "test_vcsaddons_preview_2x2.png"
15+
M.preview(out=fnm,bg=bg)
16+
print "fnm:",fnm
17+
print "src:",src
18+
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
19+
if not bg:
20+
raw_input("Press Enter")
21+
sys.exit(ret)

0 commit comments

Comments
 (0)