def testPropertyMarshalling(self): Gst.init(None) obj = Gst.ElementFactory.make("rawvideoparse") if not obj: # no rawvideoparse and I don't know of any elements in core or -base using # fraction properties. Skip this test. return value = obj.props.plane_strides self.assertEqual(value[0], 320) self.assertEqual(value[1], 160) self.assertEqual(value[2], 160) obj.props.plane_strides = Gst.ValueArray([640, 320, 320]) value = obj.props.plane_strides self.assertEqual(value[0], 640) self.assertEqual(value[1], 320) self.assertEqual(value[2], 320) def bad(): obj.props.plane_strides = 1 self.assertRaises(TypeError, bad) value = obj.props.plane_strides self.assertEqual(value[0], 640) self.assertEqual(value[1], 320) self.assertEqual(value[2], 320)
def testConstructor(self): Gst.init(None) a = Gst.ValueArray((1, 2, 3)) self.assertEqual(a.array, [1, 2, 3]) self.assertRaises(TypeError, Gst.ValueArray, 1) self.assertRaises(TypeError, Gst.ValueArray)
def testGetValue(self): Gst.init(None) st = Gst.Structure.new_empty("video/x-raw") st["array"] = Gst.ValueArray([Gst.Fraction(1, 30), Gst.Fraction(1, 2)]) value = st["array"] st["array"] = Gst.ValueArray(value) self.assertEqual(value[0], Gst.Fraction(1, 30)) self.assertEqual(value[1], Gst.Fraction(1, 2)) st["matrix"] = Gst.ValueArray( [Gst.ValueArray([0, 1]), Gst.ValueArray([-1, 0])]) value = st["matrix"] self.assertEqual(value[0][0], 0) self.assertEqual(value[0][1], 1) self.assertEqual(value[1][0], -1) self.assertEqual(value[1][1], 0)
def testRepr(self): Gst.init(None) self.assertEqual(repr(Gst.ValueArray([1, 2, 3])), '<Gst.ValueArray <1,2,3>>')