Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    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)
Ejemplo n.º 7
0
    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)
Ejemplo n.º 8
0
    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()
Ejemplo n.º 9
0
 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()
Ejemplo n.º 10
0
 def test_toString(self):
     layer = fractal.HistogramLayer()
     desc = str(layer)
     self.assertEqual("histogramLayer", desc)
Ejemplo n.º 11
0
    def test_is_visible(self):
        layer = fractal.HistogramLayer()

        self.assertEqual(True, layer.is_visible)
        layer.is_visible = False
        self.assertEqual(False, layer.is_visible)
Ejemplo n.º 12
0
    def test_name(self):
        layer = fractal.HistogramLayer()

        self.assertEqual("My Layer", layer.name)
        layer.name = "Layer 1"
        self.assertEqual("Layer 1", layer.name)
Ejemplo n.º 13
0
    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)
Ejemplo n.º 14
0
    def test_insert_layer(self):
        frac = fractal.Fractal()
        layer = fractal.HistogramLayer()
        frac.insert_layer(0, layer)

        self.assertEqual(1, frac.layer_count())
Ejemplo n.º 15
0
    def test_opacity(self):
        layer = fractal.HistogramLayer()

        self.assertEqual(1, layer.opacity)
        layer.opacity = 0.2
        self.assertEqual(0.2, round(layer.opacity, 5))