Exemple #1
0
 def test_obj_id_with_at(self):
     m = parse('@7')
     self.assertTrue(m.matches(MockMessage(obj=MockObject(id=7))))
     self.assertTrue(
         m.matches(MockMessage(obj=MockObject(id=7, generation=3))))
     self.assertFalse(m.matches(MockMessage(obj=MockObject(id=8))))
     self.assertFalse(m.matches(MockMessage(obj=MockObject(type='7'))))
Exemple #2
0
 def test_obj_type_with_wildcard(self):
     m = parse('wl_*')
     self.assertTrue(
         m.matches(MockMessage(obj=MockObject(type='wl_pointer'))))
     self.assertTrue(m.matches(
         MockMessage(obj=MockObject(type='wl_touch'))))
     self.assertFalse(
         m.matches(MockMessage(obj=MockObject(type='xdg_shell'))))
Exemple #3
0
 def test_multiple_object_types(self):
     m = parse('[wl_pointer, wl_touch]')
     self.assertTrue(
         m.matches(MockMessage(obj=MockObject(type='wl_pointer'))))
     self.assertTrue(m.matches(
         MockMessage(obj=MockObject(type='wl_touch'))))
     self.assertFalse(
         m.matches(MockMessage(obj=MockObject(type='wl_keyboard'))))
Exemple #4
0
 def test_exclude_obje_types(self):
     m = parse('wl_* ! wl_keyboard')
     self.assertTrue(
         m.matches(MockMessage(obj=MockObject(type='wl_pointer'))))
     self.assertFalse(
         m.matches(MockMessage(obj=MockObject(type='wl_keyboard'))))
     self.assertFalse(
         m.matches(MockMessage(obj=MockObject(type='xdg_shell'))))
Exemple #5
0
 def test_not_message(self):
     m = parse('!.get_popup')
     self.assertTrue(
         m.matches(
             MockMessage(obj=MockObject(type='xdg_surface'),
                         name='commit')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(type='xdg_surface'),
                         name='get_popup')))
Exemple #6
0
 def test_title_does_not_overrite_app_id(self):
     last_part = 'last_part'
     app_id = 'some.app.id.' + last_part
     m0 = MockMessage(name='set_app_id', args=[Arg.String(app_id)])
     self.c.message(m0)
     title = 'some_app_title'
     m1 = MockMessage(name='set_title', args=[Arg.String(title)])
     self.c.message(m1)
     self.assertNotIn(title, str(self.c))
     self.assertIn(last_part, str(self.c))
Exemple #7
0
 def test_obj_type_and_message_name(self):
     m = parse('wl_pointer.motion')
     self.assertTrue(
         m.matches(
             MockMessage(obj=MockObject(type='wl_pointer'), name='motion')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(type='wl_touch'), name='motion')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(type='wl_pointer'), name='axis')))
Exemple #8
0
 def test_obj_id_and_generation(self):
     m = parse('5d')
     self.assertTrue(
         m.matches(MockMessage(obj=MockObject(id=5, generation=3))))
     self.assertFalse(
         m.matches(MockMessage(obj=MockObject(id=5, generation=None))))
     self.assertFalse(
         m.matches(MockMessage(obj=MockObject(id=5, generation=12))))
     self.assertFalse(
         m.matches(MockMessage(obj=MockObject(id=12, generation=3))))
     self.assertFalse(m.matches(MockMessage(obj=MockObject(type='5'))))
Exemple #9
0
 def test_obj_type(self):
     m = parse('wl_pointer')
     self.assertTrue(
         m.matches(MockMessage(obj=MockObject(type='wl_pointer'))))
     self.assertFalse(m.matches(MockMessage()))
     self.assertFalse(
         m.matches(MockMessage(obj=MockObject(type='wl_touch'))))
     self.assertFalse(m.matches(MockMessage(name='wl_pointer')))
     self.assertFalse(
         m.matches(
             MockMessage(
                 args=[Arg.Object(MockObject(type='wl_pointer'), False)])))
Exemple #10
0
class TestMockMessage(TestCase):
    def setUp(self):
        self.m = MockMessage()

    def test_convert_to_str(self):
        self.assertTrue(str(self.m))

    def test_resolve(self):
        db = mock.Mock(spec=interfaces.ObjectDB)
        self.m.resolve(db)

    def test_used_objects(self):
        self.assertEqual(self.m.used_objects(), ())
Exemple #11
0
 def test_obj_type_with_multiple_message_names(self):
     m = parse('wl_pointer.[motion, axis]')
     self.assertTrue(
         m.matches(
             MockMessage(obj=MockObject(type='wl_pointer'), name='motion')))
     self.assertTrue(
         m.matches(
             MockMessage(obj=MockObject(type='wl_pointer'), name='axis')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(type='wl_pointer'), name='frame')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(type='wl_touch'), name='motion')))
Exemple #12
0
 def test_object_wildcard_not_type_or_message_name(self):
     m = parse('xdg_* ! xdg_popup, .get_popup')
     self.assertTrue(
         m.matches(
             MockMessage(obj=MockObject(type='xdg_surface'),
                         name='commit')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(type='xdg_surface'),
                         name='get_popup')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(type='xdg_popup'), name='commit')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(type='wl_surface'), name='commit')))
Exemple #13
0
 def test_delete_id_can_be_matched(self):
     m = parse('wl_surface.destroyed')
     self.assertTrue(
         m.matches(
             MockMessage(obj=MockObject(type='wl_display', id=1),
                         name='delete_id',
                         destroyed_obj=MockObject(type='wl_surface'))))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(type='wl_display', id=1),
                         name='delete_id',
                         destroyed_obj=MockObject(type='wl_touch'))))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(type='wl_display', id=1),
                         name='delete_id')))
Exemple #14
0
 def test_obj_id_generation_and_message_name(self):
     m = parse('@5d.motion')
     self.assertTrue(
         m.matches(
             MockMessage(obj=MockObject(id=5, generation=3),
                         name='motion')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(id=12, generation=3),
                         name='motion')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(id=5, generation=12),
                         name='motion')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(id=5, generation=3), name='axis')))
     self.assertFalse(m.matches(MockMessage(name='3.motion')))
Exemple #15
0
 def test_object_id_with_multiple_messages(self):
     m = parse('55a.[motion, axis]')
     self.assertTrue(
         m.matches(
             MockMessage(obj=MockObject(id=55, generation=0),
                         name='motion')))
     self.assertTrue(
         m.matches(
             MockMessage(obj=MockObject(id=55, generation=0), name='axis')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(id=55, generation=0),
                         name='frame')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(id=55, generation=9),
                         name='motion')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(id=54, generation=0), name='axis')))
Exemple #16
0
 def test_description_includes_layer_namespace_from_message(self):
     title = 'some_app_title'
     m = MockMessage(name='get_layer_surface',
                     args=[
                         Arg.Null(),
                         Arg.Null(),
                         Arg.Null(),
                         Arg.Null(),
                         Arg.String(title)
                     ])
     self.c.message(m)
     self.assertIn(title, str(self.c))
Exemple #17
0
 def test_object_type_and_id_with_message(self):
     m = parse('[wl_pointer, 12].motion')
     self.assertTrue(
         m.matches(
             MockMessage(obj=MockObject(type='wl_pointer', id=6),
                         name='motion')))
     self.assertTrue(
         m.matches(
             MockMessage(obj=MockObject(type='wl_touch', id=12),
                         name='motion')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(type='wl_touch', id=6),
                         name='motion')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(type='wl_pointer', id=6),
                         name='frame')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(type='wl_touch', id=12),
                         name='frame')))
Exemple #18
0
 def test_object_name_but_not_ids_with_messages(self):
     m = parse('[wl_pointer ! 55, 62].motion')
     self.assertTrue(
         m.matches(
             MockMessage(obj=MockObject(type='wl_pointer', id=12),
                         name='motion')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(type='wl_pointer', id=12),
                         name='axis')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(type='wl_pointer', id=55),
                         name='motion')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(type='wl_pointer', id=62),
                         name='motion')))
     self.assertFalse(
         m.matches(
             MockMessage(obj=MockObject(type='wl_touch', id=12),
                         name='motion')))
Exemple #19
0
 def test_detects_app_id(self):
     app_id = 'some.app.id'
     m = MockMessage(name='set_app_id', args=[Arg.String(app_id)])
     self.c.message(m)
     self.assertEqual(self.c.app_id(), app_id)
Exemple #20
0
 def test_messages_are_stored(self):
     m0 = MockMessage()
     m1 = MockMessage()
     self.c.message(m0)
     self.c.message(m1)
     self.assertEqual(self.c.messages(), (m0, m1))
Exemple #21
0
 def test_warning_on_message_after_close(self):
     self.c.close(0.0)
     m = MockMessage()
     self.c.message(m)
Exemple #22
0
 def test_remove_listener(self):
     self.c.add_connection_listener(self.l)
     self.c.remove_connection_listener(self.l)
     m = MockMessage()
     self.c.message(m)
     self.l.connection_got_new_message.assert_not_called()
Exemple #23
0
 def test_messages_returns_tuple(self):
     self.c.message(MockMessage())
     self.c.message(MockMessage())
     self.assertIsInstance(self.c.messages(), tuple)
Exemple #24
0
 def test_listener_notified_of_message(self):
     self.c.add_connection_listener(self.l)
     m = MockMessage()
     self.c.message(m)
     self.l.connection_got_new_message.assert_called_once_with(self.c, m)
Exemple #25
0
 def test_listener_not_notified_on_no_description_change(self):
     m = MockMessage()
     self.c.add_connection_listener(self.l)
     self.c.message(m)
     self.l.connection_str_changed.assert_not_called()
Exemple #26
0
 def test_description_includes_app_id_from_message(self):
     last_part = 'last_part'
     app_id = 'some.app.id.' + last_part
     m = MockMessage(name='set_app_id', args=[Arg.String(app_id)])
     self.c.message(m)
     self.assertIn(last_part, str(self.c))
Exemple #27
0
 def test_listener_notified_of_app_id_change(self):
     app_id = 'some.app.id'
     m = MockMessage(name='set_app_id', args=[Arg.String(app_id)])
     self.c.add_connection_listener(self.l)
     self.c.message(m)
     self.l.connection_app_id_set.assert_called_once_with(self.c, app_id)
Exemple #28
0
 def test_description_only_includes_last_part_of_app_id(self):
     last_part = 'last_part'
     app_id = 'some.app.id.' + last_part
     m = MockMessage(name='set_app_id', args=[Arg.String(app_id)])
     self.c.message(m)
     self.assertNotIn(app_id, str(self.c))
Exemple #29
0
 def test_description_includes_title_from_message(self):
     title = 'some_app_title'
     m = MockMessage(name='set_title', args=[Arg.String(title)])
     self.c.message(m)
     self.assertIn(title, str(self.c))
Exemple #30
0
 def test_listener_notified_of_title_description_change(self):
     title = 'some_app_title'
     m = MockMessage(name='set_title', args=[Arg.String(title)])
     self.c.add_connection_listener(self.l)
     self.c.message(m)
     self.l.connection_str_changed.assert_called_once_with(self.c)