Exemplo n.º 1
0
 def test_label_controller(self):
     """Make sure that ChamplainLabels are behaving."""
     gui.open_files(DEMOFILES)
     for photo in photos.values():
         self.assertEqual(photo.label.get_scale(), (1, 1))
         photo.label.emit("enter-event", Clutter.Event())
         self.assertEqual(photo.label.get_scale(), (1.05, 1.05))
         photo.label.emit("leave-event", Clutter.Event())
         self.assertEqual(photo.label.get_scale(), (1, 1))
         
         # Are Labels clickable?
         photo.label.emit("button-press", Clutter.Event())
         for button in ('save', 'revert', 'apply', 'close'):
             self.assertTrue(get_obj(button + '_button').get_sensitive())
         self.assertTrue(gui.labels.selection.iter_is_selected(photo.iter))
         self.assertEqual(gui.labels.selection.count_selected_rows(), 1)
         self.assertTrue(photo in selected)
         self.assertEqual(len(selected), 1)
         self.assertEqual(photo.label.get_scale(), (1.1, 1.1))
         self.assertTrue(photo.label.get_selected())
         self.assertEqual(photo.label.get_property('opacity'), 255)
         
         # Make sure the Labels that we didn't click on are deselected.
         for other in photos.values():
             if other.filename == photo.filename: continue
             self.assertFalse(gui.labels.selection.iter_is_selected(other.iter))
             self.assertFalse(other in selected)
             self.assertEqual(other.label.get_scale(), (1, 1))
             self.assertFalse(other.label.get_selected())
             self.assertEqual(other.label.get_property('opacity'), 64)
def test_hoverability():
    """Labels should grow when hovered"""
    gui.open_files(DEMOFILES)
    assert Photograph.instances
    assert Label.instances
    for label in Label.instances:
        assert label.get_scale() == (1, 1)
        label.emit('enter-event', Clutter.Event())
        assert label.get_scale() == (1.05, 1.05)
        label.emit('leave-event', Clutter.Event())
        assert label.get_scale() == (1, 1)
def test_clickability():
    """Labels become selected when clicked"""
    gui.open_files(DEMOFILES)
    assert Photograph.instances
    assert Label.instances
    for label in Label.instances:
        label.emit('button-press', Clutter.Event())
        for button in ('save', 'revert', 'close'):
            assert Widgets[button + '_button'].get_sensitive()

        assert Widgets.photos_selection.iter_is_selected(label.photo.iter)
        assert Widgets.photos_selection.count_selected_rows() == 1
        assert label.photo in selected
        assert len(selected) == 1
        assert label.get_scale() == (1.1, 1.1)
        assert label.get_selected()
        assert label.get_property('opacity') == 255

        # Make sure the Labels that we didn't click on are deselected.
        for other in Label.instances:
            if other.get_name() == label.get_name():
                continue
            assert not Widgets.photos_selection.iter_is_selected(
                other.photo.iter)
            assert other.photo not in selected
            assert other.get_scale() == (1, 1)
            assert not other.get_selected()
            assert other.get_property('opacity') == 64
Exemplo n.º 4
0
 def test_drag_controller(self):
     """Make sure that we can drag photos around."""
     # Can we load files?
     data = Struct({'get_text': lambda: '\n'.join(DEMOFILES)})
     self.assertEqual(len(photos), 0)
     self.assertEqual(len(points), 0)
     gui.drag.photo_drag_end(None, None, 20, 20, data,
                             None, None, True)
     self.assertEqual(len(photos), 6)
     self.assertEqual(len(points), 374)
     for button in ('select_all', 'close', 'clear'):
         get_obj(button + '_button').emit('clicked')
     self.assertEqual(len(photos), 0)
     self.assertEqual(len(points), 0)
     
     gui.open_files(DEMOFILES)
     for photo in photos.values():
         # 'Drag' a ChamplainLabel and make sure the photo location matches.
         photo.label.set_location(random_coord(80), random_coord(180))
         photo.label.emit('drag-finish', Clutter.Event())
         self.assertEqual(photo.label.get_latitude(), photo.latitude)
         self.assertEqual(photo.label.get_longitude(), photo.longitude)
         self.assertGreater(len(photo.pretty_geoname()), 5)
         old = [photo.latitude, photo.longitude]
         
         # 'Drag' a photo onto the map and make sure that also works.
         selected.add(photo)
         data = Struct({'get_text': lambda: photo.filename})
         gui.drag.photo_drag_end(None, None, 20, 20, data,
                                 None, None, True)
         self.assertEqual(photo.label.get_latitude(), photo.latitude)
         self.assertEqual(photo.label.get_longitude(), photo.longitude)
         self.assertGreater(len(photo.pretty_geoname()), 5)
         self.assertNotEqual(photo.latitude, old[0])
         self.assertNotEqual(photo.longitude, old[1])
def test_drags_on_map():
    """Drag the ChamplainLabels around the map"""
    gui.open_files(DEMOFILES)
    assert Photograph.instances
    assert Label.instances
    for label in Label.instances:
        label.set_location(random_coord(80), random_coord(180))
        label.emit('drag-finish', Clutter.Event())
        assert label.get_latitude() == label.photo.latitude
        assert label.get_longitude() == label.photo.longitude
        label.photo.lookup_geodata()
        assert len(label.photo.geoname) > 5