tests update
This commit is contained in:
parent
e6ebde12d9
commit
e43911e4ea
1 changed files with 37 additions and 12 deletions
|
@ -21,20 +21,24 @@ def get_color_lightness(c):
|
|||
return 0
|
||||
return (2*c[0]+c[2]+3*c[1])/6
|
||||
|
||||
def renderable(a):
|
||||
return any([any([y in ["width", "fill-color", "fill-image", "icon-image", "text", "extrude", "background-color", "pattern-image", "shield-text"] for y in x]) for x in a])
|
||||
|
||||
def compare_order(a, function, b):
|
||||
"a is over b on all zooms"
|
||||
global TOTAL_TESTS, FAILED_TESTS
|
||||
for zoom in range(minzoom, maxzoom+1):
|
||||
for typ1 in ['line', 'node', 'area']:
|
||||
for typ2 in ['line', 'node', 'area']:
|
||||
sa = [x.get('z-index', 0.) for x in style.get_style(typ1, a, zoom)]
|
||||
sb = [x.get('z-index', 0.) for x in style.get_style(typ2, b, zoom)]
|
||||
sa = [x.get('z-index', 0.) for x in style.get_style(typ1, a, zoom) if renderable([x])]
|
||||
sb = [x.get('z-index', 0.) for x in style.get_style(typ2, b, zoom) if renderable([x])]
|
||||
if sa and sb:
|
||||
mia = min(sa)
|
||||
mab = max(sb)
|
||||
TOTAL_TESTS += 1
|
||||
if (function == "over") and (mia <= mab):
|
||||
print "ORDER: z%s\t[%s %s %s %s %s]\t[%s, %s], " % (zoom, typ1, mia, function, typ2, mab, repr(a), repr(b))
|
||||
print style.get_style(typ1, a, zoom)
|
||||
FAILED_TESTS += 1
|
||||
|
||||
def compare_line_lightness(a, function, b):
|
||||
|
@ -43,8 +47,8 @@ def compare_line_lightness(a, function, b):
|
|||
for zoom in range(minzoom, maxzoom+1):
|
||||
for typ1 in ['line', 'node', 'area']:
|
||||
for typ2 in ['line', 'node', 'area']:
|
||||
sa = [get_color_lightness(x.get('color', 0.)) for x in style.get_style(typ1, a, zoom)]
|
||||
sb = [get_color_lightness(x.get('color', 0.)) for x in style.get_style(typ2, b, zoom)]
|
||||
sa = [get_color_lightness(x.get('color', 0.)) for x in style.get_style(typ1, a, zoom) if x.get("width",0) > 0]
|
||||
sb = [get_color_lightness(x.get('color', 0.)) for x in style.get_style(typ2, b, zoom) if x.get("width",0) > 0]
|
||||
if sa and sb:
|
||||
mia = min(sa)
|
||||
mab = max(sb)
|
||||
|
@ -58,14 +62,31 @@ def compare_visibility(a, function, b):
|
|||
global TOTAL_TESTS, FAILED_TESTS
|
||||
for zoom in range(minzoom, maxzoom+1):
|
||||
for typ in ['line', 'node', 'area']:
|
||||
sa = [x.get('z-index', 0.) for x in style.get_style(typ, a, zoom)]
|
||||
sb = [x.get('z-index', 0.) for x in style.get_style(typ, b, zoom)]
|
||||
sa = [x.get('z-index', 0.) for x in style.get_style(typ, a, zoom) if x]
|
||||
sb = [x.get('z-index', 0.) for x in style.get_style(typ, b, zoom) if x]
|
||||
if sa or sb:
|
||||
TOTAL_TESTS += 1
|
||||
if (function == "both") and not ((sa) and (sb)):
|
||||
print "VISIBILITY: z%s\t[%s %s %s %s %s]\t[%s, %s], " % (zoom, typ, bool(sa), function, typ, bool(sb), repr(a), repr(b))
|
||||
FAILED_TESTS += 1
|
||||
|
||||
def has_stable_labels(a):
|
||||
"a is visible with b on all zooms"
|
||||
global TOTAL_TESTS, FAILED_TESTS
|
||||
prev = {"line":False, "node": False, "area":False}
|
||||
for zoom in range(minzoom, maxzoom+1):
|
||||
for typ in ['line', 'node', 'area']:
|
||||
sa = any(["text" in x for x in style.get_style(typ, a, zoom)])
|
||||
sb = prev[typ]
|
||||
if sa or sb:
|
||||
TOTAL_TESTS += 1
|
||||
if sb and not sa:
|
||||
print "LABELS: %s|z%s\t[%s]" % (typ, zoom, repr(a))
|
||||
FAILED_TESTS += 1
|
||||
else:
|
||||
prev[typ] = sa
|
||||
|
||||
|
||||
|
||||
compare_order( {'area:highway': 'primary'}, "over", {'highway': 'primary'})
|
||||
|
||||
|
@ -97,10 +118,7 @@ compare_order( {'highway': 'unclassified'}, "over", {'highway':
|
|||
compare_order( {'highway': 'residential'}, "over", {'highway': "path", "bicycle": "yes"})
|
||||
compare_order( {'highway': 'track'}, "over", {'highway': "path"})
|
||||
compare_order( {"highway": "steps"}, "over", {'highway': "pedestrian"})
|
||||
compare_order( {"highway": "steps"}, "over", {'highway': "footway"})
|
||||
compare_order( {"highway": "steps"}, "over", {'highway': "footway", "tunnel": "yes"})
|
||||
compare_order( {"highway": "steps"}, "over", {'highway': "cycleway"})
|
||||
compare_order( {"highway": "cycleway"}, "over", {'highway': "footway"})
|
||||
|
||||
compare_order( {"highway": "service"}, "over", {'building': "yes"})
|
||||
|
||||
|
@ -118,16 +136,23 @@ compare_order( {"place": "suburb"}, "over", {'leisure':
|
|||
|
||||
compare_order( {"highway": "path"}, "over", {'man_made': "cut_line"})
|
||||
compare_order( {"highway": "footway"}, "over", {'man_made': "cut_line"})
|
||||
#compare_order( {"highway": "bus_stop"}, "over", {'highway': "trunk"})
|
||||
|
||||
#compare_visibility( {"highway": "motorway"}, "both", {'highway': 'motorway_link'})
|
||||
#compare_visibility( {"highway": "trunk"}, "both", {'highway': 'trunk_link'})
|
||||
compare_visibility( {"highway": "primary"}, "both", {'highway': 'primary_link'})
|
||||
compare_visibility( {"highway": "primary"}, "both", {'highway': 'trunk_link'})
|
||||
compare_visibility( {"highway": "secondary"}, "both", {'highway': 'secondary_link'})
|
||||
compare_visibility( {"highway": "secondary"}, "both", {'highway': 'primary_link'})
|
||||
compare_visibility( {"highway": "tertiary"}, "both", {'highway': 'tertiary_link'})
|
||||
|
||||
has_stable_labels( {"highway": "trunk", "name": "name", "int_name": "int_name"} )
|
||||
has_stable_labels( {"highway": "motorway", "name": "name", "int_name": "int_name"} )
|
||||
has_stable_labels( {"highway": "primary", "name": "name", "int_name": "int_name"} )
|
||||
has_stable_labels( {"highway": "secondary", "name": "name", "int_name": "int_name"} )
|
||||
has_stable_labels( {"highway": "tertiary", "name": "name", "int_name": "int_name"} )
|
||||
has_stable_labels( {"highway": "residential", "name": "name", "int_name": "int_name"} )
|
||||
has_stable_labels( {"highway": "unclassified", "name": "name", "int_name": "int_name"} )
|
||||
|
||||
|
||||
|
||||
print "Failed tests: %s (%s%%)" % (FAILED_TESTS, 100*FAILED_TESTS/TOTAL_TESTS)
|
||||
print "Passed tests:", TOTAL_TESTS - FAILED_TESTS
|
||||
print "Total tests:", TOTAL_TESTS
|
Loading…
Add table
Reference in a new issue