def testUngroup(self): uri = common.getSampleUri("tears_of_steel.webm") asset = GES.UriClipAsset.request_sync(uri) clip1 = asset.extract() self.layer.add_clip(clip1) clip1.set_start(5 * Gst.SECOND) clip1.set_duration(0.5 * Gst.SECOND) timeline_clips = list(self.getTimelineClips()) self.assertEqual(1, len(timeline_clips), timeline_clips) self.assertEqual(5 * Gst.SECOND, timeline_clips[0].get_start()) self.assertEqual(0.5 * Gst.SECOND, timeline_clips[0].get_duration()) self.action_log.begin("ungroup") ungrouped = GES.Container.ungroup(clip1, False) self.assertEqual(2, len(ungrouped), ungrouped) self.action_log.commit() timeline_clips = list(self.getTimelineClips()) self.assertEqual(2, len(timeline_clips), timeline_clips) self.assertEqual(5 * Gst.SECOND, timeline_clips[0].get_start()) self.assertEqual(0.5 * Gst.SECOND, timeline_clips[0].get_duration()) self.assertEqual(5 * Gst.SECOND, timeline_clips[1].get_start()) self.assertEqual(0.5 * Gst.SECOND, timeline_clips[1].get_duration()) self.action_log.undo() timeline_clips = list(self.getTimelineClips()) self.assertEqual(1, len(timeline_clips)) self.assertEqual(5 * Gst.SECOND, timeline_clips[0].get_start()) self.assertEqual(0.5 * Gst.SECOND, timeline_clips[0].get_duration())
def testCheckMediaTypesWhenNoUI(self): ges_layer = GES.Layer() png = common.getSampleUri("flat_colour1_640x480.png") video_clip = GES.UriClipAsset.request_sync(png).extract() self.assertTrue(ges_layer.add_clip(video_clip)) self.assertEqual(len(ges_layer.get_clips()), 1) timeline = Timeline(container=None, app=None) layer = Layer(ges_layer, timeline)
def testInitialization(self): def loadedCb(project, timeline, mainloop, uris): project.addUris(uris) def progressCb(project, progress, estimated_time, mainloop): if progress == 100: mainloop.quit() def quit(mainloop): mainloop.quit() # Create a blank project and add some assets. project = _createRealProject() self.assertTrue(project._has_default_video_settings) self.assertTrue(project._has_default_audio_settings) uris = [common.getSampleUri("flat_colour1_640x480.png"), common.getSampleUri("tears_of_steel.webm"), common.getSampleUri("1sec_simpsons_trailer.mp4")] project.connect("loaded", loadedCb, self.mainloop, uris) project.connect("asset-loading-progress", progressCb, self.mainloop) self.assertTrue(project.createTimeline()) GLib.timeout_add_seconds(5, quit, self.mainloop) self.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)
def addClipsSimple(self, timeline, num_clips): layer = timeline.bTimeline.append_layer() asset = GES.UriClipAsset.request_sync( common.getSampleUri("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
def stopUsingProxies(self, delete_proxies=False): sample_name = "30fps_numeroted_frames_red.mkv" self.runCheckImport([sample_name]) asset_uri = common.getSampleUri(sample_name) proxy = self.medialibrary.storemodel[0][medialibrary.COL_ASSET] self.assertEqual(proxy.props.proxy_target.props.id, asset_uri) self.app.project_manager.current_project.disableProxiesForAssets( [proxy], delete_proxies) self.assertEqual(len(self.medialibrary.storemodel), len(self.samples)) self.assertEqual(self.medialibrary.storemodel[0][medialibrary.COL_URI], asset_uri)
def testAssetAddingRemovingAdding(self): def loadingProgressCb(project, progress, estimated_time, self, result, uris): def readd(mainloop, result, uris): project.addUris(uris) result[2] = True mainloop.quit() if progress < 100: return result[1] = True assets = project.list_assets(GES.UriClip) self.assertEqual(len(assets), 1) asset = assets[0] project.remove_asset(asset) GLib.idle_add(readd, self.mainloop, result, uris) def loadedCb(project, timeline, mainloop, result, uris): result[0] = True project.addUris(uris) # Create a blank project and add an asset. project = _createRealProject() result = [False, False, False] uris = [common.getSampleUri("tears_of_steel.webm")] project.connect("loaded", loadedCb, self.mainloop, result, uris) project.connect("asset-loading-progress", loadingProgressCb, self, result, uris) def quit(mainloop): mainloop.quit() self.assertTrue(project.createTimeline()) GLib.timeout_add_seconds(5, quit, self.mainloop) self.mainloop.run() self.assertTrue( result[0], "Project creation failed to trigger signal: loaded") self.assertTrue( result[1], "Asset add failed to trigger asset-loading-progress" "with progress == 100") self.assertTrue(result[2], "Asset re-adding failed")
def testWaveFormAndThumbnailCreated(self): testmedialib = TestMediaLibrary() sample_name = "1sec_simpsons_trailer.mp4" testmedialib.runCheckImport([sample_name]) sample_uri = common.getSampleUri(sample_name) asset = GES.UriClipAsset.request_sync(sample_uri) thumb_cache = getThumbnailCache(asset) width, height = thumb_cache.getImagesSize() self.assertEqual(height, THUMB_HEIGHT) self.assertTrue(thumb_cache[0] is not None) self.assertTrue(thumb_cache[Gst.SECOND / 2] is not None) wavefile = get_wavefile_location_for_uri(sample_uri) self.assertTrue(os.path.exists(wavefile), wavefile) with open(wavefile, "rb") as fsamples: samples = pickle.load(fsamples) self.assertTrue(bool(samples))
def _createAssets(self, samples): self.samples = samples for sample_name in samples: self.app.project_manager.current_project.create_asset( common.getSampleUri(sample_name), GES.UriClip,)