def test_unpack(self): """Test if unpack fails""" controller = Controller(address='unix:abstract=abcdefghijk') controller.establish_connection = Mock(return_value=None) controller.connection = MockConnection(True) with pytest.raises(ConnectionReturnError): controller.set_composite_mode(1)
def adjust_pip(self, xpos, ypos, width, heigth, index, generate_frames=False): """Create Controller object and call adjust_pip""" for _ in range(self.NUM): serv = Server(path=PATH, video_format="debug") try: serv.run() sources = TestSources(video_port=3000) preview = PreviewSinks() preview.run() out_file = "output-{0}.data".format(index) video_sink = VideoFileSink(3001, out_file) sources.new_test_video(pattern=4) sources.new_test_video(pattern=5) controller = Controller() controller.set_composite_mode(Controller.COMPOSITE_PIP) time.sleep(3) res = controller.adjust_pip(xpos, ypos, width, heigth) time.sleep(3) sources.terminate_video() preview.terminate() video_sink.terminate() serv.terminate(1) if not generate_frames: assert res is not None assert self.verify_output(index, out_file) is True finally: serv.terminate_and_output_status(cov=True)
def do_set_composite_mode(self, line): try: val = self.COMPOSITE_MAPPING[line.lower()] except KeyError: print "Invalid" return c = Controller() c.establish_connection() print c.set_composite_mode(val)
def adjust_pip( self, xpos, ypos, width, heigth, index, generate_frames=False): """Create Controller object and call adjust_pip""" for _ in range(self.NUM): serv = Server(path=PATH) try: serv.run() sources = TestSources(video_port=3000) preview = PreviewSinks() preview.run() out_file = "output-{0}.data".format(index) video_sink = VideoFileSink(PATH, 3001, out_file) sources.new_test_video(pattern=4) sources.new_test_video(pattern=5) controller = Controller() controller.set_composite_mode(1) time.sleep(3) res = controller.adjust_pip(xpos, ypos, width, heigth) time.sleep(3) sources.terminate_video() preview.terminate() video_sink.terminate() serv.terminate(1) if not generate_frames: assert res is not None assert self.verify_output(index, out_file) is True finally: if serv.proc: poll = serv.proc.poll() print self.__class__ if poll == -11: print "SEGMENTATION FAULT OCCURRED" print "ERROR CODE - {0}".format(poll) serv.terminate(1) log = open('server.log') print log.read()
def adjust_pip(self, xpos, ypos, width, heigth, index, generate_frames=False): """Create Controller object and call adjust_pip""" for _ in range(self.NUM): serv = Server(path=PATH) try: serv.run() sources = TestSources(video_port=3000) preview = PreviewSinks() preview.run() out_file = "output-{0}.data".format(index) video_sink = VideoFileSink(PATH, 3001, out_file) sources.new_test_video(pattern=4) sources.new_test_video(pattern=5) controller = Controller() controller.set_composite_mode(1) time.sleep(3) res = controller.adjust_pip(xpos, ypos, width, heigth) time.sleep(3) sources.terminate_video() preview.terminate() video_sink.terminate() serv.terminate(1) if not generate_frames: assert res is not None assert self.verify_output(index, out_file) is True finally: if serv.proc: poll = serv.proc.poll() print self.__class__ if poll == -11: print "SEGMENTATION FAULT OCCURRED" print "ERROR CODE - {0}".format(poll) serv.terminate(1) log = open('server.log') print log.read()
def test_on_new_mode_online(self): """Create a Controller object, call on_new_mode_online method and check that the callback fires """ serv = Server(path=PATH) try: serv.run() controller = Controller() controller.establish_connection() test_cb = Mock(side_effect=self.quit_mainloop) controller.on_new_mode_online(test_cb) controller.set_composite_mode(0) GLib.timeout_add_seconds(5, self.quit_mainloop) self.run_mainloop() test_cb.assert_called_once_with(0) serv.terminate(1) finally: serv.terminate_and_output_status(cov=True)
def permutate_composite_mode(num, delay): """Change composite mode num number of times""" import random video_port = 3000 serv = Server(path=PATH, video_port=video_port) try: serv.run() sources = TestSources(video_port=video_port) sources.new_test_video(pattern=6) sources.new_test_video(pattern=5) preview = PreviewSinks() preview.run() controller = Controller() res = controller.set_composite_mode(0) assert res is True prev_mode = 0 for _ in range(num-1): time.sleep(delay) mode = random.randint(0,3) expected_res = bool(prev_mode ^ mode) prev_mode = mode assert expected_res == controller.set_composite_mode(mode) preview.terminate() sources.terminate_video() finally: if serv.proc: poll = serv.proc.poll() if poll == -11: print "SEGMENTATION FAULT OCCURRED" print "ERROR CODE - {0}".format(poll) serv.terminate(1) log = open('server.log') print log.read()
def permutate_composite_mode(num, delay): """Change composite mode num number of times""" import random video_port = 3000 serv = Server(path=PATH, video_port=video_port) try: serv.run() sources = TestSources(video_port=video_port) sources.new_test_video(pattern=6) sources.new_test_video(pattern=5) preview = PreviewSinks() preview.run() controller = Controller() res = controller.set_composite_mode(0) assert res is True prev_mode = 0 for _ in range(num - 1): time.sleep(delay) mode = random.randint(0, 3) expected_res = bool(prev_mode ^ mode) prev_mode = mode assert expected_res == controller.set_composite_mode(mode) preview.terminate() sources.terminate_video() finally: if serv.proc: poll = serv.proc.poll() if poll == -11: print "SEGMENTATION FAULT OCCURRED" print "ERROR CODE - {0}".format(poll) serv.terminate(1) log = open('server.log') print log.read()
def set_composite_mode(self, mode, generate_frames=False): """Create Controller object and call set_composite_mode method""" for _ in range(self.NUM): serv = Server(path=PATH) try: serv.run() preview = PreviewSinks() preview.run() out_file = 'output-{0}.data'.format(mode) video_sink = VideoFileSink(PATH, serv.video_port + 1, out_file) sources = TestSources(video_port=3000) sources.new_test_video(pattern=4) sources.new_test_video(pattern=5) time.sleep(3) # expected_result = [mode != 3] * self.FACTOR # print mode, expected_result controller = Controller() res = controller.set_composite_mode(mode) print res time.sleep(3) video_sink.terminate() preview.terminate() sources.terminate_video() serv.terminate(1) if not generate_frames: if mode == 3: assert res is False else: assert res is True assert self.verify_output(mode, out_file) is True # assert expected_result == res finally: if serv.proc: poll = serv.proc.poll() print self.__class__ if poll == -11: print "SEGMENTATION FAULT OCCURRED" print "ERROR CODE - {0}".format(poll) serv.terminate(1) log = open('server.log') print log.read()
def set_composite_mode(self, mode, generate_frames=False): """Create Controller object and call set_composite_mode method""" for _ in range(self.NUM): serv = Server(path=PATH) try: serv.run() preview = PreviewSinks() preview.run() out_file = 'output-{0}.data'.format(mode) video_sink = VideoFileSink(serv.video_port + 1, out_file) sources = TestSources(video_port=3000) sources.new_test_video(pattern=4) sources.new_test_video(pattern=5) time.sleep(3) # expected_result = [mode != 3] * self.FACTOR # print mode, expected_result controller = Controller() res = controller.set_composite_mode(mode) print res time.sleep(3) video_sink.terminate() preview.terminate() sources.terminate_video() serv.terminate(1) if not generate_frames: if mode == 3: assert res is False else: assert res is True assert self.verify_output(mode, out_file) is True # assert expected_result == res finally: if serv.proc: poll = serv.proc.poll() print self.__class__ if poll == -11: print "SEGMENTATION FAULT OCCURRED" print "ERROR CODE - {0}".format(poll) serv.terminate(1) log = open('server.log') print log.read()
def set_composite_mode(self, mode, generate_frames=False): """Create Controller object and call set_composite_mode method""" for _ in range(self.NUM): serv = Server(path=PATH, video_format="debug") try: serv.run() preview = PreviewSinks() preview.run() out_file = 'output-{0}.data'.format(mode) video_sink = VideoFileSink(serv.video_port + 1, out_file) sources = TestSources(video_port=3000) sources.new_test_video(pattern=4) sources.new_test_video(pattern=5) time.sleep(3) # expected_result = [mode != 3] * self.FACTOR # print(mode, expected_result) controller = Controller() res = controller.set_composite_mode(mode) print(res) time.sleep(3) video_sink.terminate() preview.terminate() sources.terminate_video() serv.terminate(1) if not generate_frames: controller = Controller() if mode == Controller.COMPOSITE_DUAL_EQUAL: assert res is False else: assert res is True assert self.verify_output(mode, out_file) is True # assert expected_result == res finally: serv.terminate_and_output_status(cov=True)
def test_normal_unpack(self): """Test if valid""" controller = Controller(address='unix:abstract=abcdef') controller.establish_connection = Mock(return_value=None) controller.connection = MockConnection(False) assert controller.set_composite_mode(1) is True