'Test legend behaviour.'

def test_legend(self):

    self.widget.cb_show_legend.setChecked(True)
    self.send_signal('Tree', self.titanic)
    self.assertIsInstance(self.widget.legend, OWDiscreteLegend)
    self.assertTrue(self.widget.legend.isVisible())
    self.send_signal('Tree', self.housing)
    self.assertIsInstance(self.widget.legend, OWContinuousLegend)
    self.assertFalse(self.widget.legend.isVisible())
    index = 2
    simulate.combobox_activate_index(self.widget.target_class_combo, index)
    self.assertIsInstance(self.widget.legend, OWContinuousLegend)
    self.assertTrue(self.widget.legend.isVisible())
    self.send_signal('Tree', self.titanic)
    self.assertIsInstance(self.widget.legend, OWDiscreteLegend)
    self.assertTrue(self.widget.legend.isVisible())
