本文整理汇总了Python中tests.common.get_sample_uri函数的典型用法代码示例。如果您正苦于以下问题:Python get_sample_uri函数的具体用法?Python get_sample_uri怎么用?Python get_sample_uri使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_sample_uri函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_scanning
def test_scanning(self):
"""Checks the scanning of the URIs."""
valid_uri = common.get_sample_uri("tears_of_steel.webm")
uris = self._scan([valid_uri,
common.get_sample_uri("missing.webm"),
"http://pitivi.org/very_real.webm"])
self.assertEqual(len(uris), 1, uris)
self.assertIn(valid_uri, uris)
示例2: test_asset_added_signal
def test_asset_added_signal(self):
app = common.create_pitivi()
self.assertTrue(app.project_manager.newBlankProject())
project = app.project_manager.current_project
proxy_manager = app.proxy_manager
mainloop = common.create_main_loop()
def asset_added_cb(project, asset, assets):
assets.append(asset)
assets = []
project.connect("asset-added", asset_added_cb, assets)
def proxy_ready_cb(unused_proxy_manager, asset, proxy):
mainloop.quit()
proxy_manager.connect("proxy-ready", proxy_ready_cb)
uris = [common.get_sample_uri("tears_of_steel.webm")]
project.addUris(uris)
mainloop.run()
self.assertEqual(len(assets), 1, assets)
示例3: test_async_done_not_received
def test_async_done_not_received(self):
"""Checks the recovery when the ASYNC_DONE message timed out."""
ges_timeline = GES.Timeline.new()
self.assertTrue(ges_timeline.add_track(GES.VideoTrack.new()))
ges_layer = ges_timeline.append_layer()
uri = common.get_sample_uri("tears_of_steel.webm")
asset = GES.UriClipAsset.request_sync(uri)
ges_clip = asset.extract()
self.assertTrue(ges_layer.add_clip(ges_clip))
self.assertFalse(ges_timeline.is_empty())
pipe = Pipeline(app=common.create_pitivi_mock())
pipe.set_timeline(ges_timeline)
self.assertFalse(pipe._busy_async)
self.assertEqual(pipe._recovery_state, SimplePipeline.RecoveryState.NOT_RECOVERING)
# Pretend waiting for async-done timed out.
# We mock set_state because we don't actually care about the state,
# and setting the state to PAUSED could show a video window.
with mock.patch.object(pipe, "set_state"):
pipe._async_done_not_received_cb()
# Make sure the pipeline started a watchdog timer waiting for async-done
# as part of setting the state from NULL to PAUSED.
self.assertTrue(pipe._busy_async)
self.assertEqual(pipe._attempted_recoveries, 1)
self.assertEqual(pipe._recovery_state, SimplePipeline.RecoveryState.STARTED_RECOVERING)
# Pretend the state changed to READY.
message = mock.Mock()
message.type = Gst.MessageType.STATE_CHANGED
message.src = pipe._pipeline
message.parse_state_changed.return_value = (Gst.State.NULL, Gst.State.READY, Gst.State.PAUSED)
pipe._busMessageCb(None, message)
# Pretend the state changed to PAUSED.
message.parse_state_changed.return_value = (Gst.State.READY, Gst.State.PAUSED, Gst.State.VOID_PENDING)
self.assertEqual(pipe._next_seek, None)
pipe._busMessageCb(None, message)
self.assertEqual(pipe._recovery_state, SimplePipeline.RecoveryState.SEEKED_AFTER_RECOVERING)
self.assertTrue(pipe._busy_async)
# The pipeline should have tried to seek back to the last position.
self.assertEqual(pipe._next_seek, 0)
# Pretend the state change (to PAUSED) async operation succeeded.
message.type = Gst.MessageType.ASYNC_DONE
with mock.patch.object(pipe, "get_state") as get_state:
get_state.return_value = (0, Gst.State.PAUSED, 0)
pipe._busMessageCb(None, message)
self.assertEqual(pipe._recovery_state, SimplePipeline.RecoveryState.NOT_RECOVERING)
# Should still be busy because of seeking to _next_seek.
self.assertTrue(pipe._busy_async)
self.assertIsNone(pipe._next_seek)
# Pretend the seek async operation finished.
message.type = Gst.MessageType.ASYNC_DONE
pipe._busMessageCb(None, message)
self.assertEqual(pipe._recovery_state, SimplePipeline.RecoveryState.NOT_RECOVERING)
self.assertFalse(pipe._busy_async)
self.assertIsNone(pipe._next_seek)
示例4: testSaveProjectWithRemovedProxy
def testSaveProjectWithRemovedProxy(self):
sample_name = "30fps_numeroted_frames_red.mkv"
with common.cloned_sample(sample_name):
self.check_import([sample_name])
project = self.app.project_manager.current_project
asset = GES.UriClipAsset.request_sync(common.get_sample_uri(sample_name))
target = asset.get_proxy_target()
self.assertEqual(set(project.list_assets(GES.Extractable)), set([target, asset]))
# Remove the asset
self.medialibrary.remove_assets_action.emit("activate", None)
# Make sure that the project has not assets anymore
self.assertEqual(project.list_assets(GES.Extractable), [])
# Save the project and reload it, making sure there is no asset
# in that new project
project_uri = Gst.filename_to_uri(tempfile.NamedTemporaryFile().name)
project.save(project.ges_timeline, project_uri, None, True)
self._customSetUp(project_uri)
self.assertNotEqual(project, self.app.project_manager.current_project)
project = self.app.project_manager.current_project
self.assertEqual(project.list_assets(GES.Extractable), [])
示例5: load_project_with_missing_proxy
def load_project_with_missing_proxy(self):
"""Loads a project with missing proxies."""
uris = [common.get_sample_uri("1sec_simpsons_trailer.mp4")]
proxy_uri = uris[0] + ".232417.proxy.mkv"
PROJECT_STR = """<ges version='0.3'>
<project properties='properties;' metadatas='metadatas, name=(string)"New\ Project", author=(string)Unknown, render-scale=(double)100;'>
<encoding-profiles>
</encoding-profiles>
<ressources>
<asset id='%(uri)s' extractable-type-name='GESUriClip' properties='properties, supported-formats=(int)6, duration=(guint64)1228000000;' metadatas='metadatas, audio-codec=(string)"MPEG-4\ AAC\ audio", maximum-bitrate=(uint)130625, bitrate=(uint)130625, datetime=(datetime)2007-02-19T05:03:04Z, encoder=(string)Lavf54.6.100, container-format=(string)"ISO\ MP4/M4A", video-codec=(string)"H.264\ /\ AVC", file-size=(guint64)232417;' proxy-id='file:///home/thiblahute/devel/pitivi/flatpak/pitivi/tests/samples/1sec_simpsons_trailer.mp4.232417.proxy.mkv' />
<asset id='%(proxy_uri)s' extractable-type-name='GESUriClip' properties='properties, supported-formats=(int)6, duration=(guint64)1228020833;' metadatas='metadatas, container-format=(string)Matroska, audio-codec=(string)Opus, language-code=(string)en, encoder=(string)Lavf54.6.100, bitrate=(uint)64000, video-codec=(string)"Motion\ JPEG", file-size=(guint64)4695434;' />
</ressources>
<timeline properties='properties, auto-transition=(boolean)true, snapping-distance=(guint64)0;' metadatas='metadatas, duration=(guint64)0;'>
<track caps='video/x-raw(ANY)' track-type='4' track-id='0' properties='properties, async-handling=(boolean)false, message-forward=(boolean)true, caps=(string)"video/x-raw\(ANY\)", restriction-caps=(string)"video/x-raw\,\ width\=\(int\)720\,\ height\=\(int\)576\,\ framerate\=\(fraction\)25/1", mixing=(boolean)true;' metadatas='metadatas;'/>
<track caps='audio/x-raw(ANY)' track-type='2' track-id='1' properties='properties, async-handling=(boolean)false, message-forward=(boolean)true, caps=(string)"audio/x-raw\(ANY\)", restriction-caps=(string)"audio/x-raw\,\ format\=\(string\)S32LE\,\ channels\=\(int\)2\,\ rate\=\(int\)44100\,\ layout\=\(string\)interleaved", mixing=(boolean)true;' metadatas='metadatas;'/>
<layer priority='0' properties='properties, auto-transition=(boolean)true;' metadatas='metadatas, volume=(float)1;'>
<clip id='0' asset-id='%(proxy_uri)s' type-name='GESUriClip' layer-priority='0' track-types='6' start='0' duration='1228000000' inpoint='0' rate='0' properties='properties, name=(string)uriclip0, mute=(boolean)false, is-image=(boolean)false;' >
<source track-id='1' children-properties='properties, GstVolume::mute=(boolean)false, GstVolume::volume=(double)1;'>
<binding type='direct' source_type='interpolation' property='volume' mode='1' track_id='1' values =' 0:0.10000000000000001 1228000000:0.10000000000000001 '/>
</source>
<source track-id='0' children-properties='properties, GstFramePositioner::alpha=(double)1, GstDeinterlace::fields=(int)0, GstFramePositioner::height=(int)720, GstDeinterlace::mode=(int)0, GstFramePositioner::posx=(int)0, GstFramePositioner::posy=(int)0, GstDeinterlace::tff=(int)0, GstFramePositioner::width=(int)1280;'>
<binding type='direct' source_type='interpolation' property='alpha' mode='1' track_id='0' values =' 0:1 1228000000:1 '/>
</source>
</clip>
</layer>
<groups>
</groups>
</timeline>
</project>
</ges>""" % {"uri": uris[0], "proxy_uri": proxy_uri}
app = common.create_pitivi(proxyingStrategy=ProxyingStrategy.ALL)
proxy_manager = app.proxy_manager
project_manager = app.project_manager
mainloop = common.create_main_loop()
unused, xges_path = tempfile.mkstemp(suffix=".xges")
proj_uri = "file://" + os.path.abspath(xges_path)
app.project_manager.saveProject(uri=proj_uri)
medialib = medialibrary.MediaLibraryWidget(app)
with open(proj_uri[len("file://"):], "w") as f:
f.write(PROJECT_STR)
# Remove proxy
common.clean_proxy_samples()
def closing_project_cb(*args, **kwargs):
# Do not ask whether to save project on closing.
return True
def proxy_ready_cb(proxy_manager, asset, proxy):
self.assertEqual(proxy.props.id, proxy_uri)
mainloop.quit()
project_manager.connect("closing-project", closing_project_cb)
proxy_manager.connect_after("proxy-ready", proxy_ready_cb)
app.project_manager.loadProject(proj_uri)
return mainloop, app, medialib, proxy_uri
示例6: __check_simple
def __check_simple(self, left_click_also_seeks):
timeline_container = create_timeline_container()
timeline = timeline_container.timeline
timeline.app.settings.leftClickAlsoSeeks = left_click_also_seeks
ges_layer = timeline.ges_timeline.append_layer()
asset = GES.UriClipAsset.request_sync(
common.get_sample_uri("1sec_simpsons_trailer.mp4"))
ges_clip1 = ges_layer.add_asset(asset, 0 * Gst.SECOND, 0,
1 * Gst.SECOND, GES.TrackType.UNKNOWN)
ges_clip2 = ges_layer.add_asset(asset, 1 * Gst.SECOND, 0,
1 * Gst.SECOND, GES.TrackType.UNKNOWN)
event = mock.Mock()
event.get_button.return_value = (True, 1)
timeline._seek = mock.Mock()
timeline._seek.return_value = True
timeline.get_clicked_layer_and_pos = mock.Mock()
with mock.patch.object(Gtk, "get_event_widget") as get_event_widget:
get_event_widget.return_value = timeline
# Simulate click on first and shift+click on second clip.
timeline.get_clicked_layer_and_pos.return_value = (ges_layer, 0.5 * Gst.SECOND)
timeline._button_release_event_cb(None, event)
timeline.get_parent()._shiftMask = True
timeline.get_clicked_layer_and_pos.return_value = (ges_layer, 1.5 * Gst.SECOND)
timeline._button_release_event_cb(None, event)
self.__check_selected([ges_clip1, ges_clip2], [])
示例7: test_asset_added
def test_asset_added(self):
uris = [common.get_sample_uri("tears_of_steel.webm")]
mainloop = common.create_main_loop()
def loaded_cb(unused_project, unused_timeline):
self.project.addUris(uris)
self.project.connect_after("loaded", loaded_cb)
def progress_cb(unused_project, progress, unused_estimated_time):
if progress == 100:
mainloop.quit()
self.project.connect_after("asset-loading-progress", progress_cb)
mainloop.run()
self.assertTrue(self.action_log.has_assets_operations())
self.assertEqual(len(self.project.list_assets(GES.Extractable)), 1)
self.action_log.undo()
self.assertFalse(self.action_log.has_assets_operations())
self.assertEqual(len(self.project.list_assets(GES.Extractable)), 0)
self.action_log.redo()
self.assertTrue(self.action_log.has_assets_operations())
self.assertEqual(len(self.project.list_assets(GES.Extractable)), 1)
示例8: test_prop_keyframe
def test_prop_keyframe(self):
"""Checks the keyframe button effect."""
uri = common.get_sample_uri("tears_of_steel.webm")
asset = GES.UriClipAsset.request_sync(uri)
ges_clip = asset.extract()
# Add the clip to a timeline so it gets tracks.
timeline = common.create_timeline_container()
self.app = timeline.app
ges_timeline = timeline.ges_timeline
ges_timeline.append_layer()
ges_layer, = ges_timeline.get_layers()
ges_layer.add_clip(ges_clip)
self._register_alpha_widget(
("black_sens_adjustment", "GstAlpha::black-sensitivity", "GstAlpha::black-sensitivity::keyframe"))
ges_clip.add(self.alpha_effect)
track_element = self.element_settings_widget._GstElementSettingsWidget__get_track_element_of_same_type(
self.alpha_effect)
prop_keyframe_button = \
list(self.element_settings_widget._GstElementSettingsWidget__widgets_by_keyframe_button.keys())[0]
# Control the self.prop property on the timeline
prop_keyframe_button.set_active(True)
self.assertEqual(track_element.ui_element._TimelineElement__controlledProperty, self.prop)
# Revert to controlling the default property
prop_keyframe_button.set_active(False)
self.assertNotEqual(track_element.ui_element._TimelineElement__controlledProperty, self.prop)
示例9: addClipsSimple
def addClipsSimple(self, timeline, num_clips):
layer = timeline.ges_timeline.append_layer()
asset = GES.UriClipAsset.request_sync(
common.get_sample_uri("tears_of_steel.webm"))
clips = [layer.add_asset(asset, i * 10, 0, 10, GES.TrackType.UNKNOWN)
for i in range(num_clips)]
self.assertEqual(len(clips), num_clips)
return clips
示例10: add_clip
def add_clip(self, layer, start, inpoint=0, duration=10, clip_type=GES.TrackType.UNKNOWN):
"""Creates a clip on the specified layer."""
asset = GES.UriClipAsset.request_sync(
common.get_sample_uri("tears_of_steel.webm"))
clip = layer.add_asset(asset, start, inpoint, duration, clip_type)
self.assertIsNotNone(clip)
return clip
示例11: test_scanning_dir
def test_scanning_dir(self):
"""Checks the scanning of the directory URIs."""
assets_dir = os.path.dirname(os.path.abspath(__file__))
valid_dir_uri = Gst.filename_to_uri(os.path.join(assets_dir, "samples"))
uris = [valid_dir_uri]
received_uris = self._scan(uris)
self.assertGreater(len(received_uris), 1, received_uris)
valid_uri = common.get_sample_uri("tears_of_steel.webm")
self.assertIn(valid_uri, received_uris)
示例12: test_ungroup_group_clip
def test_ungroup_group_clip(self):
self.setup_timeline_container()
timeline = self.timeline_container.timeline
uri = common.get_sample_uri("tears_of_steel.webm")
asset = GES.UriClipAsset.request_sync(uri)
clip = asset.extract()
self.layer.add_clip(clip)
clips = list(self.getTimelineClips())
self.assertEqual(len(clips), 1, clips)
self.assertEqual(len(clips[0].get_children(False)), 2)
timeline.selection.select([clip])
timeline.resetSelectionGroup()
timeline.current_group.add(clip)
self.timeline_container.ungroup_action.activate(None)
clips = list(self.getTimelineClips())
self.assertEqual(len(clips), 2, clips)
self.assertEqual(len(clips[0].get_children(False)), 1)
self.assertEqual(len(clips[1].get_children(False)), 1)
timeline.selection.select(clips)
timeline.resetSelectionGroup()
for clip in clips:
timeline.current_group.add(clip)
self.timeline_container.group_action.activate(None)
clips = list(self.getTimelineClips())
self.assertEqual(len(clips), 1, clips)
self.assertEqual(len(clips[0].get_children(False)), 2)
for i in range(2):
# Undo grouping.
self.action_log.undo()
clips = list(self.getTimelineClips())
self.assertEqual(len(clips), 2, clips)
self.assertEqual(len(clips[0].get_children(False)), 1)
self.assertEqual(len(clips[1].get_children(False)), 1)
# Undo ungrouping.
self.action_log.undo()
clips = list(self.getTimelineClips())
self.assertEqual(len(clips), 1, clips)
self.assertEqual(len(clips[0].get_children(False)), 2)
# Redo ungrouping.
self.action_log.redo()
clips = list(self.getTimelineClips())
self.assertEqual(len(clips), 2, clips)
self.assertEqual(len(clips[0].get_children(False)), 1)
self.assertEqual(len(clips[1].get_children(False)), 1)
# Redo grouping.
self.action_log.redo()
clips = list(self.getTimelineClips())
self.assertEqual(len(clips), 1, clips)
self.assertEqual(len(clips[0].get_children(False)), 2)
示例13: testInitialization
def testInitialization(self):
mainloop = common.create_main_loop()
uris = collections.deque([
common.get_sample_uri("flat_colour1_640x480.png"),
common.get_sample_uri("tears_of_steel.webm"),
common.get_sample_uri("1sec_simpsons_trailer.mp4")])
def loaded_cb(project, timeline):
project.addUris([uris.popleft()])
def progress_cb(project, progress, estimated_time):
if progress == 100:
if uris:
project.addUris([uris.popleft()])
else:
mainloop.quit()
# Create a blank project and add some assets.
project = common.create_project()
self.assertTrue(project._has_default_video_settings)
self.assertTrue(project._has_default_audio_settings)
project.connect_after("loaded", loaded_cb)
project.connect_after("asset-loading-progress", progress_cb)
mainloop.run()
assets = project.list_assets(GES.UriClip)
self.assertEqual(3, len(assets), assets)
self.assertFalse(project._has_default_video_settings)
self.assertFalse(project._has_default_audio_settings)
# The audio settings should match tears_of_steel.webm
self.assertEqual(1, project.audiochannels)
self.assertEqual(44100, project.audiorate)
# The video settings should match tears_of_steel.webm
self.assertEqual(960, project.videowidth)
self.assertEqual(400, project.videoheight)
self.assertEqual(Gst.Fraction(24, 1), project.videorate)
self.assertEqual(Gst.Fraction(1, 1), project.videopar)
示例14: test_get
def test_get(self):
with self.assertRaises(ValueError):
ThumbnailCache.get(1)
with mock.patch("pitivi.timeline.previewers.xdg_cache_home") as xdg_config_home,\
tempfile.TemporaryDirectory() as temp_dir:
xdg_config_home.return_value = temp_dir
sample_uri = common.get_sample_uri("1sec_simpsons_trailer.mp4")
cache = ThumbnailCache.get(sample_uri)
self.assertIsNotNone(cache)
asset = GES.UriClipAsset.request_sync(sample_uri)
self.assertEqual(ThumbnailCache.get(asset), cache)
示例15: test_thumb_interval
def test_thumb_interval(self):
"""Checks the `thumb_interval` property."""
ges_elem = mock.Mock()
ges_elem.props.uri = common.get_sample_uri("1sec_simpsons_trailer.mp4")
ges_elem.props.id = common.get_sample_uri("1sec_simpsons_trailer.mp4")
previewer = VideoPreviewer(ges_elem, 94)
previewer.thumb_width = 1 # Just so it's not None.
def run_thumb_interval(interval):
"""Runs thumb_interval."""
with mock.patch("pitivi.utils.timeline.Zoomable.pixelToNs") as pixel_to_ns:
pixel_to_ns.return_value = interval
return previewer.thumb_interval
self.assertEqual(run_thumb_interval(1), THUMB_PERIOD)
self.assertEqual(run_thumb_interval(THUMB_PERIOD - 1), THUMB_PERIOD)
self.assertEqual(run_thumb_interval(THUMB_PERIOD), THUMB_PERIOD)
self.assertEqual(run_thumb_interval(THUMB_PERIOD + 1), 2 * THUMB_PERIOD)
self.assertEqual(run_thumb_interval(2 * THUMB_PERIOD - 1), 2 * THUMB_PERIOD)
self.assertEqual(run_thumb_interval(2 * THUMB_PERIOD), 2 * THUMB_PERIOD)