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_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 #3
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 #4
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 #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_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 #7
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 #8
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 #9
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 #10
0
 def test_resolves_to_object_returned_by_db(self):
     o = UnresolvedObject(7, None)
     db = Mock(spec=interfaces.ObjectDB)
     expected_obj = MockObject()
     db.retrieve_object = Mock(return_value=expected_obj)
     r = o.resolve(db)
     self.assertEqual(r, expected_obj)
Exemple #11
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 #12
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 #13
0
 def test_requests_right_object_with_non_null_type_from_db(self):
     o = UnresolvedObject(7, 'some_type')
     db = Mock(spec=interfaces.ObjectDB)
     expected_obj = MockObject()
     db.retrieve_object = Mock(return_value=expected_obj)
     o.resolve(db)
     db.retrieve_object.assert_called_once_with(7, -1, 'some_type')
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_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 #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_convert_to_str(self):
     o = MockObject()
     self.assertTrue(str(o))
Exemple #19
0
 def test_obj_type_matches_for_new_obj(self):
     m = parse('wl_pointer')
     self.assertFalse(
         m.matches(
             MockMessage(
                 args=[Arg.Object(MockObject(type='wl_pointer'), True)])))
Exemple #20
0
 def test_message_name(self):
     m = parse('.axis')
     self.assertTrue(m.matches(MockMessage(name='axis')))
     self.assertFalse(m.matches(MockMessage()))
     self.assertFalse(m.matches(MockMessage(obj=MockObject(type='axis'))))
Exemple #21
0
 def test_obj_type_with_at(self):
     m = parse('wl_pointer@')
     self.assertTrue(
         m.matches(MockMessage(obj=MockObject(type='wl_pointer'))))
     self.assertFalse(m.matches(MockMessage(name='wl_pointer')))
Exemple #22
0
 def test_is_object(self):
     o = MockObject()
     self.assertIsInstance(o, ObjectBase)