[pitivi] tests: Add test for asset_matches_target_res



commit 25d212681f644abe1a7d0b8f3887fe1dd2be108f
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Wed Oct 9 23:28:37 2019 +0200

    tests: Add test for asset_matches_target_res

 pitivi/utils/proxy.py |  4 +---
 tests/test_proxy.py   | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/pitivi/utils/proxy.py b/pitivi/utils/proxy.py
index 976bbeb8..a086430e 100644
--- a/pitivi/utils/proxy.py
+++ b/pitivi/utils/proxy.py
@@ -359,6 +359,7 @@ class ProxyManager(GObject.Object, Loggable):
         return False
 
     def asset_matches_target_res(self, asset):
+        """Returns whether the asset's size <= the scaled proxy size."""
         stream = asset.get_info().get_video_streams()[0]
 
         asset_res = (stream.get_width(), stream.get_height())
@@ -658,8 +659,6 @@ class ProxyManager(GObject.Object, Loggable):
                 self.__pending_transcoders.remove(transcoder)
                 self.emit("asset-preparing-cancelled", asset)
 
-        return
-
     def add_job(self, asset, scaled=False, shadow=False):
         """Adds a transcoding job for the specified asset if needed.
 
@@ -721,7 +720,6 @@ class ProxyManager(GObject.Object, Loggable):
             self.__createTranscoder(asset, width=t_width, height=t_height, shadow=shadow)
         else:
             self.__createTranscoder(asset, shadow=shadow)
-        return
 
 
 def get_proxy_target(obj):
diff --git a/tests/test_proxy.py b/tests/test_proxy.py
index be8f5c61..819f47d5 100644
--- a/tests/test_proxy.py
+++ b/tests/test_proxy.py
@@ -96,3 +96,17 @@ class TestProxyManager(common.TestCase):
         self._check_getProxyUri("file:///home/file.name.mp4",
                                 "file:///home/file.name.mp4.10.1280x720.scaledproxy.mkv",
                                 scaled=True)
+
+    def test_asset_matches_target_res(self):
+        """Checks the asset_matches_target_res method."""
+        uri = common.get_sample_uri("tears_of_steel.webm")
+        asset = GES.UriClipAsset.request_sync(uri)
+        stream = asset.get_info().get_video_streams()[0]
+        app = common.create_pitivi_mock()
+
+        for dw in (-1, 0, 1):
+            for dh in (-1, 0, 1):
+                app.project_manager.current_project.scaled_proxy_width = stream.get_width() + dw
+                app.project_manager.current_project.scaled_proxy_height = stream.get_height() + dh
+                matches = dw >= 0 and dh >= 0
+                self.assertEqual(app.proxy_manager.asset_matches_target_res(asset), matches, (dw, dh))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]