--- trunk/thuban/test/test_classgen.py 2003/07/08 13:23:20 1379 +++ trunk/thuban/test/test_classgen.py 2003/07/30 15:43:41 1528 @@ -21,7 +21,7 @@ generate_uniform_distribution, \ generate_quantiles, \ calculate_quantiles, \ - GreyRamp, CustomRamp + grey_ramp, CustomRamp, FixedRamp from Thuban.Model.range import Range from Thuban.Model.color import Color @@ -47,12 +47,12 @@ self.doBoundsTest(clazz) - def doBoundsTest(self, clazz, ramp = GreyRamp): + def doBoundsTest(self, clazz, ramp = grey_ramp): # # check that the properties are right (i.e. the first group # is all white, the last is all black). This assumes that - # the GreyRamp, unless another is provided. + # the grey_ramp, unless another is provided. # if clazz.GetNumGroups() >= 1: groupF = clazz.GetGroup(0) @@ -69,7 +69,7 @@ eq = self.assertEquals gs = generate_singletons - ramp = GreyRamp + ramp = grey_ramp _list = [1, 2, 3, 4] cl = gs(_list, ramp) @@ -101,7 +101,7 @@ eq = self.assertEquals gud = generate_uniform_distribution - ramp = GreyRamp + ramp = grey_ramp cl = gud(0, 99, 10, ramp, True) self.doClassRangeTest(cl, ("[0;10[", "[10;20[", "[20;30[", "[30;40[", @@ -132,7 +132,7 @@ gq = generate_quantiles - ramp = GreyRamp + ramp = grey_ramp adj, cl = gq([1, 2, 3, 4], [.25, .5, .75, 1.0], ramp, Range("[1;4]")) self.failIf(adj) @@ -318,6 +318,34 @@ self.assertEquals(half.GetLineColor(), Color(0, 0.5, 0)) +class TestFixedRamp(unittest.TestCase): + + def test(self): + """Test FixedRamp""" + eq = self.assertEquals + + for lineColor, lineWidth, fillColor in \ + [(None, None, None), (Color(1, 1, 1), None, None), + (None, 4, None), (None, None, Color(0, 1, 0)), + (Color(1, 1, 1), 4, None), (Color(1, 1, 1), None, Color(0, 1, 0)), + (None, 4, Color(0, 1, 0)), (Color(1, 1, 1), 4, Color(0, 1, 0))]: + + framp = FixedRamp(grey_ramp, (lineColor, lineWidth, fillColor)) + + for i in [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]: + props = framp.GetProperties(i) + grey = Color(1 - i, 1 - i, 1 - i) + if lineColor is not None: + eq(props.GetLineColor(), lineColor) + else: + eq(props.GetLineColor(), grey) + if lineWidth is not None: + eq(props.GetLineWidth(), lineWidth) + if fillColor is not None: + eq(props.GetFill(), fillColor) + else: + eq(props.GetFill(), grey) + if __name__ == "__main__": unittest.main()