def test_toString(self): frac = fractal.Fractal() layer = fractal.HistogramLayer() frac.insert_layer(0, layer) desc = str(frac) self.assertEqual("fractal: \n\thistogramLayer\n", desc)
def test_get_layer_memory_leak(self): frac = fractal.Fractal() layer = fractal.HistogramLayer() frac.insert_layer(0, layer) retrieved_layer = frac.get_layer(0) self.assertEqual(retrieved_layer, layer)
def test_palette_memory_leak(self): layer = fractal.HistogramLayer() new_palette = fractal.Palette() layer.palette = new_palette layer_palette = layer.palette self.assertEqual(new_palette, layer_palette)
def test_remove_layer_memory_leak(self): frac = fractal.Fractal() layer = fractal.HistogramLayer() # Insert then delete layer frac.insert_layer(0, layer) deleted_layer = frac.remove_layer(0) self.assertEqual(deleted_layer, layer)
def test_get_layer_functionality(self): frac = fractal.Fractal() layer = fractal.HistogramLayer() frac.insert_layer(0, layer) retrieved_layer = frac.get_layer(0) retrieved_layer.opacity = 0.2 self.assertEqual(retrieved_layer.opacity, layer.opacity)
def test_remove_layer_functionality(self): frac = fractal.Fractal() layer = fractal.HistogramLayer() # Insert then delete layer frac.insert_layer(0, layer) deleted_layer = frac.remove_layer(0) # Assert list length and equality of deleted layer self.assertEqual(0, frac.layer_count()) deleted_layer.opacity = 0.2 self.assertEqual(deleted_layer.opacity, layer.opacity)
def test_palette(self): layer = fractal.HistogramLayer() # Ensure that the getter points to the real one pal = layer.palette pal.add_color((1, 1, 1), 0.5) self.assertEqual(len(layer.palette.get_colors()), 3) # Ensure the setter works newPal = fractal.Palette() newPal.remove_color(0) layer.palette = newPal self.assertEqual(len(layer.palette.get_colors()), 1)
def layer_type_changed_callback(self, event): index = event["index"] palette = self.fract.get_layer(index).palette new_layer = None if self.fract.remove_layer(index): if event["value"] == "Histogram": new_layer = fractal.HistogramLayer() elif event["value"] == "SmoothBands": new_layer = fractal.SmoothBandsLayer() elif event["value"] == "SimpleBands": new_layer = fractal.SimpleBandsLayer() new_layer.palette = palette if self.fract.insert_layer(index, new_layer): self.fractRenderer.update()
def layer_added_callback(self, event): self.current_layer = fractal.HistogramLayer() self.current_layer_index = event["index"] self.fract.insert_layer(event["index"], self.current_layer) self.update_palette() self.fractRenderer.update()
def test_toString(self): layer = fractal.HistogramLayer() desc = str(layer) self.assertEqual("histogramLayer", desc)
def test_is_visible(self): layer = fractal.HistogramLayer() self.assertEqual(True, layer.is_visible) layer.is_visible = False self.assertEqual(False, layer.is_visible)
def test_name(self): layer = fractal.HistogramLayer() self.assertEqual("My Layer", layer.name) layer.name = "Layer 1" self.assertEqual("Layer 1", layer.name)
def test_insert_layer_invalid(self): frac = fractal.Fractal() layer = fractal.HistogramLayer() self.assertRaises(IndexError, frac.insert_layer, 1, layer) self.assertRaises(IndexError, frac.insert_layer, -1, layer)
def test_insert_layer(self): frac = fractal.Fractal() layer = fractal.HistogramLayer() frac.insert_layer(0, layer) self.assertEqual(1, frac.layer_count())
def test_opacity(self): layer = fractal.HistogramLayer() self.assertEqual(1, layer.opacity) layer.opacity = 0.2 self.assertEqual(0.2, round(layer.opacity, 5))