From d44975a1fe624e39f9ef480ae0694a77311247c1 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Mon, 27 Mar 2017 14:59:24 -0400 Subject: array/list: Make gvalue conversion symmetric This is needed to support matrix. Otherwise, getting a matrix would remove the rows envelopess, which would make the "cast" fails, since it would not know if the internal rows are ValueArray or ValueList. I think reading, modifying and setting back the matrix is an important use case. --- testsuite/test_valuearray.py | 12 ++++++++++++ testsuite/test_valuelist.py | 8 ++++++++ 2 files changed, 20 insertions(+) (limited to 'testsuite') diff --git a/testsuite/test_valuearray.py b/testsuite/test_valuearray.py index 9a77715..99ddc99 100644 --- a/testsuite/test_valuearray.py +++ b/testsuite/test_valuearray.py @@ -82,6 +82,18 @@ class TestFraction(TestCase): st = Gst.Structure.new_empty("video/x-raw") st["array"] = A([Gst.Fraction(1, 30), Gst.Fraction(1, 2)]) value = st["array"] + st["array"] = A(value) self.failUnlessEqual(value[0], Gst.Fraction(1, 30)) self.failUnlessEqual(value[1], Gst.Fraction(1, 2)) + + st["matrix"] = A([A([0, 1]), A([-1, 0])]) + value = st["matrix"] + + self.failUnlessEqual(value[0][0], 0) + self.failUnlessEqual(value[0][1], 1) + self.failUnlessEqual(value[1][0], -1) + self.failUnlessEqual(value[1][1], 0) + + + diff --git a/testsuite/test_valuelist.py b/testsuite/test_valuelist.py index b9fa129..fcada68 100644 --- a/testsuite/test_valuelist.py +++ b/testsuite/test_valuelist.py @@ -54,3 +54,11 @@ class TestFraction(TestCase): self.failUnlessEqual(value[0], Gst.Fraction(1, 30)) self.failUnlessEqual(value[1], Gst.Fraction(1, 2)) + + st["matrix"] = L([L([0, 1]), L([-1 ,0])]) + value = st["matrix"] + + self.failUnlessEqual(value[0][0], 0) + self.failUnlessEqual(value[0][1], 1) + self.failUnlessEqual(value[1][0], -1) + self.failUnlessEqual(value[1][1], 0) -- cgit v1.2.3