mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
ges: Add test for the newly added DiscovererManager object
Making pep8 happy on the way Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3911>
This commit is contained in:
parent
98e5c5e862
commit
e8e5508d1d
1 changed files with 60 additions and 22 deletions
|
@ -27,6 +27,7 @@ gi.require_version("Gst", "1.0")
|
|||
gi.require_version("GES", "1.0")
|
||||
|
||||
from gi.repository import Gst # noqa
|
||||
from gi.repository import GstPbutils # noqa
|
||||
from gi.repository import GLib # noqa
|
||||
from gi.repository import GES # noqa
|
||||
import unittest # noqa
|
||||
|
@ -74,6 +75,7 @@ class TestTimeline(GESSimpleTimelineTest):
|
|||
|
||||
with common.created_video_asset(uri, 6, framerate="2/1") as uri:
|
||||
mainloop = common.create_main_loop()
|
||||
|
||||
def asset_loaded_cb(_, res, mainloop):
|
||||
asset2 = GES.Asset.request_finish(res)
|
||||
self.assertEqual(asset2.props.duration, 3 * Gst.SECOND)
|
||||
|
@ -98,11 +100,10 @@ class TestTimeline(GESSimpleTimelineTest):
|
|||
</asset>
|
||||
</ressources>
|
||||
</project>
|
||||
</ges>"""% {"uri": asset_uri}
|
||||
</ges>""" % {"uri": asset_uri}
|
||||
with open(xges_path, "w") as xges_file:
|
||||
xges_file.write(xges)
|
||||
|
||||
|
||||
def loaded_cb(project, timeline):
|
||||
asset = project.list_assets(GES.Extractable)[0]
|
||||
self.assertEqual(asset.get_meta("foo"), "bar")
|
||||
|
@ -112,3 +113,40 @@ class TestTimeline(GESSimpleTimelineTest):
|
|||
loaded_project.connect("loaded", loaded_cb)
|
||||
timeline = loaded_project.extract()
|
||||
mainloop.run()
|
||||
|
||||
def test_asset_load_serialized_info(self):
|
||||
mainloop = GLib.MainLoop()
|
||||
|
||||
serialized_infos = {}
|
||||
n_calls = 0
|
||||
n_cache_hits = 0
|
||||
|
||||
def load_serialized_info_cb(_manager, uri):
|
||||
nonlocal n_calls, n_cache_hits, serialized_infos
|
||||
|
||||
n_calls += 1
|
||||
res = serialized_infos.get(uri)
|
||||
if res:
|
||||
n_cache_hits += 1
|
||||
return res
|
||||
|
||||
GES.DiscovererManager.get_default().connect("load-serialized-info",
|
||||
load_serialized_info_cb)
|
||||
|
||||
self.assertEqual(n_calls, 0)
|
||||
asset = GES.UriClipAsset.request_sync(Gst.filename_to_uri(os.path.join(__file__, "../../assets/audio_video.ogg")))
|
||||
self.assertEqual(n_calls, 1)
|
||||
self.assertEqual(n_cache_hits, 0)
|
||||
|
||||
serialized_infos[asset.get_id()] = asset.get_info()
|
||||
|
||||
# Clear the GES internal asset cache
|
||||
GES.deinit()
|
||||
GES.init()
|
||||
|
||||
# Connect to the new manager, previous one was destroyed on deinit
|
||||
GES.DiscovererManager.get_default().connect("load-serialized-info",
|
||||
load_serialized_info_cb)
|
||||
asset = GES.UriClipAsset.request_sync(Gst.filename_to_uri(os.path.join(__file__, "../../assets/audio_video.ogg")))
|
||||
self.assertEqual(n_calls, 2)
|
||||
self.assertEqual(n_cache_hits, 1)
|
||||
|
|
Loading…
Reference in a new issue