Changeset 11111:8b86d1ff9919 in orange


Ignore:
Timestamp:
10/11/12 20:11:24 (19 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Fixed scheme's annotation signal signatures and added tests.

Location:
Orange/OrangeCanvas/scheme
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/scheme/annotations.py

    r11101 r11111  
    6262        return self.__rect 
    6363 
    64     rect = Property(tuple, fget=rect) 
     64    rect = Property(tuple, fget=rect, fset=set_rect) 
    6565 
    6666    def set_text(self, text): 
  • Orange/OrangeCanvas/scheme/scheme.py

    r11101 r11111  
    4747    channel_state_changed = Signal() 
    4848 
    49     annotation_added = Signal() 
    50     annotation_removed = Signal() 
     49    annotation_added = Signal(BaseSchemeAnnotation) 
     50    annotation_removed = Signal(BaseSchemeAnnotation) 
    5151 
    5252    node_property_changed = Signal(SchemeNode, str, object) 
  • Orange/OrangeCanvas/scheme/tests/test_scheme.py

    r11101 r11111  
    1111 
    1212 
    13 class TestScheme(test.QAppTestCase): 
     13class TestScheme(test.QCoreAppTestCase): 
    1414    def test_scheme(self): 
    1515        import Orange 
     
    2828        nodes_added = [] 
    2929        links_added = [] 
     30        annotations_added = [] 
    3031 
    3132        scheme.node_added.connect(nodes_added.append) 
     33        scheme.node_removed.connect(nodes_added.remove) 
     34 
    3235        scheme.link_added.connect(links_added.append) 
    3336        scheme.link_removed.connect(links_added.remove) 
     37 
     38        scheme.annotation_added.connect(annotations_added.append) 
     39        scheme.annotation_removed.connect(annotations_added.remove) 
    3440 
    3541        w1 = scheme.new_node(file_desc) 
     
    8187        self.assertRaises(ValueError, scheme.new_link, 
    8288                          w2, "Data", w1, "Data") 
     89 
     90        text_annot = SchemeTextAnnotation((0, 0, 100, 20), "Text") 
     91        scheme.add_annotation(text_annot) 
     92        self.assertSequenceEqual(annotations_added, [text_annot]) 
     93        self.assertSequenceEqual(scheme.annotations, annotations_added) 
     94 
     95        arrow_annot = SchemeTextAnnotation((0, 100), (100, 100)) 
     96        scheme.add_annotation(arrow_annot) 
     97        self.assertSequenceEqual(annotations_added, [text_annot, arrow_annot]) 
     98        self.assertSequenceEqual(scheme.annotations, annotations_added) 
     99 
     100        scheme.remove_annotation(text_annot) 
     101        self.assertSequenceEqual(annotations_added, [arrow_annot]) 
     102        self.assertSequenceEqual(scheme.annotations, annotations_added) 
     103 
Note: See TracChangeset for help on using the changeset viewer.