From 768a2e6bd62e99127c09aa63518aa81f6de3db7d Mon Sep 17 00:00:00 2001 From: hyades Date: Thu, 8 Aug 2013 02:39:56 +0530 Subject: [PATCH] Chnaged structure of testsource --- python-api/gstswitch/helpers.py | 3 +- python-api/gstswitch/test_testsource.py | 243 ++++++++++++------------ python-api/gstswitch/testsource.py | 19 +- 3 files changed, 134 insertions(+), 131 deletions(-) diff --git a/python-api/gstswitch/helpers.py b/python-api/gstswitch/helpers.py index ed1edb3..6ad800f 100644 --- a/python-api/gstswitch/helpers.py +++ b/python-api/gstswitch/helpers.py @@ -40,8 +40,7 @@ def new_test_video(self, pattern, timeoverlay, clockoverlay) - if testsrc is None: - pass + testsrc.run() self.running_tests.append(testsrc) def get_test_video(self): diff --git a/python-api/gstswitch/test_testsource.py b/python-api/gstswitch/test_testsource.py index 222ec12..5253f5b 100644 --- a/python-api/gstswitch/test_testsource.py +++ b/python-api/gstswitch/test_testsource.py @@ -6,146 +6,149 @@ class TestVideoSrcPort(object): - def test_blank(self): - tests = ['', None, [], {}] - for test in tests: - with pytest.raises(ValueError): - VideoSrc(port=test) - - def test_range(self): - tests = [-100, 1e7, 65536] - for test in tests: - with pytest.raises(RangeError): - VideoSrc(port=test) - - def test_invalid(self): - tests = [[1, 2, 3, 4], {1: 2, 2: 3}, '1e10'] - for test in tests: - with pytest.raises(TypeError): - VideoSrc(port=test) - - def test_normal(self): - tests = [1, 65535, 1000] - for test in tests: - src = VideoSrc(port=test) - assert src.port == test + def test_blank(self): + tests = ['', None, [], {}] + for test in tests: + with pytest.raises(ValueError): + VideoSrc(port=test) + + def test_range(self): + tests = [-100, 1e7, 65536] + for test in tests: + with pytest.raises(RangeError): + VideoSrc(port=test) + + def test_invalid(self): + tests = [[1, 2, 3, 4], {1: 2, 2: 3}, '1e10'] + for test in tests: + with pytest.raises(TypeError): + VideoSrc(port=test) + + def test_normal(self): + tests = [1, 65535, 1000] + for test in tests: + src = VideoSrc(port=test) + assert src.port == test class TestVideoSrcWidth(object): - def test_blank(self): - tests = ['', None, [], {}] - port = 1000 - for test in tests: - with pytest.raises(ValueError): - VideoSrc(port=port, width=test) - - def test_non_positive(self): - tests = ['-1.111', -1.111, 0, -1e10] - port = 1000 - for test in tests: - with pytest.raises(ValueError): - VideoSrc(port=port, width=test) - - def test_invalid(self): - tests = [[1, 2, 3], {1: 2, 2: 3}, (1, 2)] - port = 1000 - for test in tests: - with pytest.raises(TypeError): - VideoSrc(port=port, width=test) - - def test_normal(self): - tests = [ 1e6, 300, '200'] - port = 1000 - for test in tests: - src = VideoSrc(port=port, width=test) - assert src.width == test + def test_blank(self): + tests = ['', None, [], {}] + port = 1000 + for test in tests: + with pytest.raises(ValueError): + VideoSrc(port=port, width=test) + + def test_non_positive(self): + tests = ['-1.111', -1.111, 0, -1e10] + port = 1000 + for test in tests: + with pytest.raises(ValueError): + VideoSrc(port=port, width=test) + + def test_invalid(self): + tests = [[1, 2, 3], {1: 2, 2: 3}, (1, 2)] + port = 1000 + for test in tests: + with pytest.raises(TypeError): + VideoSrc(port=port, width=test) + + def test_normal(self): + tests = [ 1e6, 300, '200'] + port = 1000 + for test in tests: + src = VideoSrc(port=port, width=test) + assert src.width == test class TestVideoSrcHeight(object): - def test_blank(self): - tests = ['', None, [], {}] - port = 1000 - for test in tests: - with pytest.raises(ValueError): - VideoSrc(port=port, height=test) - - def test_non_positive(self): - tests = ['-1.111', -1.111, 0, -1e10] - port = 1000 - for test in tests: - with pytest.raises(ValueError): - VideoSrc(port=port, height=test) - - def test_invalid(self): - tests = [[1, 2, 3], {1: 2, 2: 3}, (1, 2)] - port = 1000 - for test in tests: - with pytest.raises(TypeError): - VideoSrc(port=port, height=test) - - def test_normal(self): - tests = [1e6, 300, '200'] - port = 1000 - for test in tests: - src = VideoSrc(port=port, height=test) - assert src.height == test + def test_blank(self): + tests = ['', None, [], {}] + port = 1000 + for test in tests: + with pytest.raises(ValueError): + VideoSrc(port=port, height=test) + + def test_non_positive(self): + tests = ['-1.111', -1.111, 0, -1e10] + port = 1000 + for test in tests: + with pytest.raises(ValueError): + VideoSrc(port=port, height=test) + + def test_invalid(self): + tests = [[1, 2, 3], {1: 2, 2: 3}, (1, 2)] + port = 1000 + for test in tests: + with pytest.raises(TypeError): + VideoSrc(port=port, height=test) + + def test_normal(self): + tests = [1e6, 300, '200'] + port = 1000 + for test in tests: + src = VideoSrc(port=port, height=test) + assert src.height == test class TestVideoSrcPattern(object): - def test_range(self): - tests = [-100, 1e7, 65536, -1, 20] - port = 1000 - for test in tests: - with pytest.raises(RangeError): - VideoSrc(port=port, pattern=test) + def test_range(self): + tests = [-100, 1e7, 65536, -1, 20] + port = 1000 + for test in tests: + with pytest.raises(RangeError): + VideoSrc(port=port, pattern=test) - def test_invalid(self): - tests = [[1, 2, 3, 4], {1: 2, 2: 3}] - port = 1000 - for test in tests: - with pytest.raises(TypeError): - VideoSrc(port=port, pattern=test) + def test_invalid(self): + tests = [[1, 2, 3, 4], {1: 2, 2: 3}] + port = 1000 + for test in tests: + with pytest.raises(TypeError): + VideoSrc(port=port, pattern=test) - def test_normal(self): - tests = [1, 0, 19, 10] - port = 1000 - for test in tests: - src = VideoSrc(port=port, pattern=test) - assert src.pattern == str(test) + def test_normal(self): + tests = [1, 0, 19, 10] + port = 1000 + for test in tests: + src = VideoSrc(port=port, pattern=test) + assert src.pattern == str(test) class TestVideoSrcTimeOverlay(object): - def test_fail(self): - tests = ['', 1234, 'hi', [1, 2], {1: 2}, None, 0, []] - port = 1000 - for test in tests: - with pytest.raises(ValueError): - VideoSrc(port=port, timeoverlay=test) + def test_fail(self): + tests = ['', 1234, 'hi', [1, 2], {1: 2}, None, 0, []] + port = 1000 + for test in tests: + with pytest.raises(ValueError): + VideoSrc(port=port, timeoverlay=test) - def test_normal(self): - tests = [True, False] - port = 1000 - for test in tests: - src = VideoSrc(port=port, timeoverlay=test) - assert src.timeoverlay == test + def test_normal(self): + tests = [True, False] + port = 1000 + for test in tests: + src = VideoSrc(port=port, timeoverlay=test) + assert src.timeoverlay == test class TestVideoSrcClockOverlay(object): - def test_fail(self): - tests = ['', 1234, 'hi', [1, 2], {1: 2}, None, 0, []] - port = 1000 - for test in tests: - with pytest.raises(ValueError): - VideoSrc(port=port, clockoverlay=test) - - def test_normal(self): - tests = [True, False] - port = 1000 - for test in tests: - src = VideoSrc(port=port, clockoverlay=test) - assert src.clockoverlay == test \ No newline at end of file + def test_fail(self): + tests = ['', 1234, 'hi', [1, 2], {1: 2}, None, 0, []] + port = 1000 + for test in tests: + with pytest.raises(ValueError): + VideoSrc(port=port, clockoverlay=test) + + def test_normal(self): + tests = [True, False] + port = 1000 + for test in tests: + src = VideoSrc(port=port, clockoverlay=test) + assert src.clockoverlay == test + + +# class TestVideoSrc \ No newline at end of file diff --git a/python-api/gstswitch/testsource.py b/python-api/gstswitch/testsource.py index f93759d..042ff79 100644 --- a/python-api/gstswitch/testsource.py +++ b/python-api/gstswitch/testsource.py @@ -230,6 +230,7 @@ class VideoSrc(object): :param timeoverlay: True to enable a running time over video :param clockoverlay: True to enable current clock time over video """ + HOST = '127.0.0.1' def __init__( self, @@ -247,15 +248,6 @@ def __init__( self.timeoverlay = timeoverlay self.clockoverlay = clockoverlay - self.pipeline = VideoPipeline( - self.port, - self.width, - self.height, - self.pattern, - self.timeoverlay, - self.clockoverlay) - self.run() - @property def port(self): return self._port @@ -359,6 +351,15 @@ def clockoverlay(self, clockoverlay): def run(self): """Run the pipeline""" + self.pipeline = VideoPipeline( + self.port, + self.HOST, + self.width, + self.height, + self.pattern, + self.timeoverlay, + self.clockoverlay) + self.pipeline.play() def pause(self):