Ejemplo n.º 1
0
    def test_loaded_callback(self):
        mainloop = common.create_main_loop()

        def loaded(project, timeline):
            # If not called, the timeout of the mainloop will fail the test.
            mainloop.quit()

        # Create a blank project and save it.
        project = common.create_project()
        project.connect("loaded", loaded)
        mainloop.run()
        # The blank project loading succeeded emitting signal "loaded".

        self.assertIsNotNone(project.ges_timeline)
        self.assertEqual(len(project.ges_timeline.get_layers()), 1)

        # Load the blank project and make sure "loaded" is triggered.
        unused, xges_path = tempfile.mkstemp()
        uri = "file://%s" % xges_path
        try:
            # Save so we can close it without complaints.
            project.save(project.ges_timeline, uri, None, overwrite=True)

            project2 = common.create_project()
            project2.connect("loaded", loaded)
            mainloop.run()
            # The blank project loading succeeded emitting signal "loaded".

            self.assertIsNotNone(project2.ges_timeline)
            self.assertEqual(len(project2.ges_timeline.get_layers()), 1)
        finally:
            os.remove(xges_path)
Ejemplo n.º 2
0
    def test_loaded_callback(self):
        mainloop = common.create_main_loop()

        def loaded(project, timeline):
            # If not called, the timeout of the mainloop will fail the test.
            mainloop.quit()

        # Create a blank project and save it.
        project = common.create_project()
        project.connect("loaded", loaded)
        mainloop.run()
        # The blank project loading succeeded emitting signal "loaded".

        self.assertIsNotNone(project.ges_timeline)
        self.assertEqual(len(project.ges_timeline.get_layers()), 1)

        # Load the blank project and make sure "loaded" is triggered.
        unused, xges_path = tempfile.mkstemp()
        uri = "file://%s" % xges_path
        try:
            # Save so we can close it without complaints.
            project.save(project.ges_timeline, uri, None, overwrite=True)

            project2 = common.create_project()
            project2.connect("loaded", loaded)
            mainloop.run()
            # The blank project loading succeeded emitting signal "loaded".

            self.assertIsNotNone(project2.ges_timeline)
            self.assertEqual(len(project2.ges_timeline.get_layers()), 1)
        finally:
            os.remove(xges_path)
Ejemplo n.º 3
0
    def test_set_rendering(self):
        """Checks the set_rendering method."""
        mainloop = common.create_main_loop()

        def loaded_cb(project, timeline):
            project.addUris([common.get_sample_uri("tears_of_steel.webm")])

        def progress_cb(project, progress, estimated_time):
            if progress == 100:
                mainloop.quit()

        # Create a blank project and add some assets.
        project = common.create_project()

        project.connect_after("loaded", loaded_cb)
        project.connect_after("asset-loading-progress", progress_cb)

        mainloop.run()

        # The video settings should match tears_of_steel.webm
        self.assertEqual(project.videowidth, 960)
        self.assertEqual(project.videoheight, 400)

        project.render_scale = 3
        # Pretend we're rendering.
        project.set_rendering(True)
        self.assertEqual(project.videowidth, 28)
        self.assertEqual(project.videoheight, 12)

        # Pretend we're not rendering anymore.
        project.set_rendering(False)
        self.assertEqual(project.videowidth, 960)
        self.assertEqual(project.videoheight, 400)
Ejemplo n.º 4
0
    def _check_master_attribute(self, attr, dependant_attr):
        """Test changing the specified attr has effect on its dependent attr."""
        project = common.create_project()

        attr_value1 = "%s_value1" % attr
        attr_value2 = "%s_value2" % attr

        setattr(project, attr, attr_value1)
        setattr(project, dependant_attr, {})
        getattr(project, dependant_attr)["key1"] = "v1"

        setattr(project, attr, attr_value2)
        setattr(project, dependant_attr, {})
        getattr(project, dependant_attr)["key2"] = "v2"

        setattr(project, attr, attr_value1)
        self.assertTrue("key1" in getattr(project, dependant_attr))
        self.assertFalse("key2" in getattr(project, dependant_attr))
        self.assertEqual("v1", getattr(project, dependant_attr)["key1"])
        setattr(project, dependant_attr, {})

        setattr(project, attr, attr_value2)
        self.assertFalse("key1" in getattr(project, dependant_attr))
        self.assertTrue("key2" in getattr(project, dependant_attr))
        self.assertEqual("v2", getattr(project, dependant_attr)["key2"])
        setattr(project, dependant_attr, {})

        setattr(project, attr, attr_value1)
        self.assertFalse("key1" in getattr(project, dependant_attr))
        self.assertFalse("key2" in getattr(project, dependant_attr))

        setattr(project, attr, attr_value2)
        self.assertFalse("key1" in getattr(project, dependant_attr))
        self.assertFalse("key2" in getattr(project, dependant_attr))
Ejemplo n.º 5
0
    def test_with_video(self):
        """Checks the value of the with_video field."""
        audio_clip = common.get_sample_clip("mp3_sample.mp3")
        video_clip = common.get_sample_clip("one_fps_numeroted_blue.mkv")
        audio_video_clip = common.get_sample_clip("tears_of_steel.webm")

        # Add the clips to a layer so they have TrackElements.
        project = common.create_project()
        layer = project.ges_timeline.append_layer()
        layer.add_clip(audio_clip)
        layer.add_clip(video_clip)
        layer.add_clip(audio_video_clip)

        self.__check_with_video(audio_clip, False)
        self.__check_with_video(video_clip, True)
        self.__check_with_video(audio_video_clip, True)

        # Check the track elements of a clip with audio only.
        audio_track_element = audio_clip.find_track_element(None, GES.AudioSource)
        self.__check_with_video(audio_track_element, False)

        # Check the track elements of a clip with video only.
        video_track_element = video_clip.find_track_element(None, GES.VideoSource)
        self.__check_with_video(video_track_element, True)

        # Check the track elements of a clip with both audio and video.
        audio_track_element = audio_video_clip.find_track_element(None, GES.AudioSource)
        video_track_element = audio_video_clip.find_track_element(None, GES.VideoSource)
        self.__check_with_video(audio_track_element, True)
        self.__check_with_video(video_track_element, True)
Ejemplo n.º 6
0
    def test_set_rendering(self):
        """Checks the set_rendering method."""
        mainloop = common.create_main_loop()

        def loaded_cb(project, timeline):
            project.addUris([common.get_sample_uri("tears_of_steel.webm")])

        def progress_cb(project, progress, estimated_time):
            if progress == 100:
                mainloop.quit()

        # Create a blank project and add some assets.
        project = common.create_project()

        project.connect_after("loaded", loaded_cb)
        project.connect_after("asset-loading-progress", progress_cb)

        mainloop.run()

        # The video settings should match tears_of_steel.webm
        self.assertEqual(project.videowidth, 960)
        self.assertEqual(project.videoheight, 400)

        project.render_scale = 3
        # Pretend we're rendering.
        project.set_rendering(True)
        self.assertEqual(project.videowidth, 28)
        self.assertEqual(project.videoheight, 12)

        # Pretend we're not rendering anymore.
        project.set_rendering(False)
        self.assertEqual(project.videowidth, 960)
        self.assertEqual(project.videoheight, 400)
Ejemplo n.º 7
0
    def _check_master_attribute(self, attr, dependant_attr):
        """Test changing the specified attr has effect on its dependent attr."""
        project = common.create_project()

        attr_value1 = "%s_value1" % attr
        attr_value2 = "%s_value2" % attr

        setattr(project, attr, attr_value1)
        setattr(project, dependant_attr, {})
        getattr(project, dependant_attr)["key1"] = "v1"

        setattr(project, attr, attr_value2)
        setattr(project, dependant_attr, {})
        getattr(project, dependant_attr)["key2"] = "v2"

        setattr(project, attr, attr_value1)
        self.assertTrue("key1" in getattr(project, dependant_attr))
        self.assertFalse("key2" in getattr(project, dependant_attr))
        self.assertEqual("v1", getattr(project, dependant_attr)["key1"])
        setattr(project, dependant_attr, {})

        setattr(project, attr, attr_value2)
        self.assertFalse("key1" in getattr(project, dependant_attr))
        self.assertTrue("key2" in getattr(project, dependant_attr))
        self.assertEqual("v2", getattr(project, dependant_attr)["key2"])
        setattr(project, dependant_attr, {})

        setattr(project, attr, attr_value1)
        self.assertFalse("key1" in getattr(project, dependant_attr))
        self.assertFalse("key2" in getattr(project, dependant_attr))

        setattr(project, attr, attr_value2)
        self.assertFalse("key1" in getattr(project, dependant_attr))
        self.assertFalse("key2" in getattr(project, dependant_attr))
Ejemplo n.º 8
0
 def testVideo(self):
     project = common.create_project()
     project.videowidth = 1920
     self.assertEqual(1920, project.videowidth)
     project.videoheight = 1080
     self.assertEqual(1080, project.videoheight)
     project.videorate = Gst.Fraction(50, 7)
     self.assertEqual(Gst.Fraction(50, 7), project.videorate)
Ejemplo n.º 9
0
 def testVideo(self):
     project = common.create_project()
     project.videowidth = 1920
     self.assertEqual(1920, project.videowidth)
     project.videoheight = 1080
     self.assertEqual(1080, project.videoheight)
     project.videorate = Gst.Fraction(50, 7)
     self.assertEqual(Gst.Fraction(50, 7), project.videorate)
Ejemplo n.º 10
0
    def test_set_safe_area_sizes(self):
        """Checks to ensure that the safe areas values are set correctly."""
        project = common.create_project()
        title_horizontal_factor = 0.8
        title_vertical_factor = 0.9
        action_horizontal_factor = 0.6
        action_vertical_factor = 0.7

        project.set_safe_areas_sizes(title_horizontal_factor,
                                     title_vertical_factor,
                                     action_horizontal_factor,
                                     action_vertical_factor)

        self.assertEqual(project.title_safe_area_horizontal, title_horizontal_factor)
        self.assertEqual(project.title_safe_area_vertical, title_vertical_factor)
        self.assertEqual(project.action_safe_area_horizontal, action_horizontal_factor)
        self.assertEqual(project.action_safe_area_vertical, action_vertical_factor)
Ejemplo n.º 11
0
    def test_missing_x264(self):
        # Simulate no encoder being available for the profile's format.
        targets = GstPbutils.encoding_list_all_targets()
        for target in targets:
            for profile in target.get_profiles():
                for sub_profile in profile.get_profiles():
                    raw_caps = "audio/non_existing_whatever_it_s_true"
                    sub_profile.get_format = mock.Mock(return_value=raw_caps)

        with mock.patch.object(
                GstPbutils,
                "encoding_list_all_targets") as encoding_list_all_targets:
            encoding_list_all_targets.return_value = targets

            project = common.create_project()
            manager = PresetsManager(project)

            self.assertIsNone(manager.initial_preset())
Ejemplo n.º 12
0
    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)
Ejemplo n.º 13
0
    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)
Ejemplo n.º 14
0
 def testAudio(self):
     project = common.create_project()
     project.audiochannels = 2
     self.assertEqual(2, project.audiochannels)
     project.audiorate = 44100
     self.assertEqual(44100, project.audiorate)
Ejemplo n.º 15
0
    def test_initial_preset(self):
        project = common.create_project()
        manager = PresetsManager(project)

        self.assertEqual(manager.initial_preset().name, "youtube")
Ejemplo n.º 16
0
 def testAudio(self):
     project = common.create_project()
     project.audiochannels = 2
     self.assertEqual(2, project.audiochannels)
     project.audiorate = 44100
     self.assertEqual(44100, project.audiorate)