本文整理汇总了Python中gstswitch.controller.Controller类的典型用法代码示例。如果您正苦于以下问题:Python Controller类的具体用法?Python Controller怎么用?Python Controller使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Controller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_action_fails
def test_action_fails(self):
"""Test what happens if the requested action fails"""
controller = Controller(address='unix:abstract=abcde')
controller.establish_connection = Mock(return_value=None)
controller.connection = MockConnection(
return_variant=True, should_fail=True)
assert controller.click_video(1, 2, 3, 4) is False
示例2: test_unpack
def test_unpack(self):
"""Test if unpack fails"""
controller = Controller(address='unix:abstract=abcde')
controller.establish_connection = Mock(return_value=None)
controller.connection = MockConnection(True)
with pytest.raises(ConnectionReturnError):
controller.switch(Controller.VIDEO_CHANNEL_A, 2)
示例3: test_normal
def test_normal(self):
"""Test if valid"""
controller = Controller(address='unix:abstract=abcde')
controller.establish_connection = Mock(return_value=None)
controller.connection = MockConnection(True)
face = [(1, 2, 3, 4), (1, 1, 1, 1)]
controller.mark_tracking(face)
示例4: adjust_pip
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)
示例5: do_adjust_pip
def do_adjust_pip(self, line):
c = Controller()
c.establish_connection()
if len(line.split()) != 4:
print "Inavlid number of arguments"
return
print c.adjust_pip(*map(int, line.split()))
示例6: new_record
def new_record(self):
"""Create a Controller object and call new_record method"""
res = []
controller = Controller()
for _ in range(self.NUM * self.FACTOR):
res.append(controller.new_record())
return res
示例7: test_unpack
def test_unpack(self):
"""Test if unpack fails"""
controller = Controller(address='unix:abstract=abcde')
controller.establish_connection = Mock(return_value=None)
controller.connection = MockConnection(return_variant=False)
with pytest.raises(ConnectionReturnError):
controller.new_record()
示例8: test_on_preview_port_added
def test_on_preview_port_added(self):
"""Create a Controller object, call add a source method and
check that the callback fires
"""
serv = Server(path=PATH, video_port=3000)
try:
serv.run()
controller = Controller()
controller.establish_connection()
test_cb = Mock(side_effect=lambda mode, serve, type:
self.quit_mainloop_after(2))
controller.on_preview_port_added(test_cb)
sources = TestSources(video_port=3000)
sources.new_test_video()
sources.new_test_video()
GLib.timeout_add_seconds(5, self.quit_mainloop)
self.run_mainloop()
print(test_cb.call_args_list)
test_cb.assert_any_call(3003, 1, 7)
test_cb.assert_any_call(3004, 1, 8)
assert test_cb.call_count == 2
serv.terminate(1)
finally:
serv.terminate_and_output_status(cov=True)
示例9: get_preview_ports
def get_preview_ports(num):
"""Get Preview Ports when num number of sources are added"""
video_port = 3000
serv = Server(path=PATH, video_port=video_port)
try:
serv.run()
sources = TestSources(video_port=video_port)
expected_res = [ i for i in range(3003, 3003 + num)]
controller = Controller()
res = []
for _ in range(num):
sources.new_test_video()
controller.establish_connection()
res = controller.get_preview_ports()
print res
assert expected_res == res
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()
示例10: test_multiple_handler_calls
def test_multiple_handler_calls(self, monkeypatch):
"""Test that the various Handler gets calles"""
monkeypatch.setattr(Connection, 'connect_dbus', Mock())
controller = Controller(address='unix:abstract=abcd')
signals = ('preview_port_added', 'preview_port_removed',
'new_mode_online', 'show_face_marker',
'show_track_marker', 'select_face')
test_cbs = {}
for signal in signals:
test_cbs[signal] = Mock()
getattr(controller, 'on_'+signal)(test_cbs[signal])
getattr(controller, 'on_'+signal)(test_cbs[signal])
getattr(controller, 'on_'+signal)(test_cbs[signal])
for signal in signals:
controller.cb_signal_handler(
None,
':0',
'/us/timvideos/gstswitch/SwitchControllerInterface',
'us.timvideos.gstswitch.SwitchControllerInterface',
signal,
GLib.Variant('(i)', (123,)),
None)
for signal in signals:
test_cbs[signal].assert_called_with(123)
assert test_cbs[signal].call_count == 3
示例11: switch
def switch(self, channel, port, index):
"""Create Controller object and call switch method"""
for _ in range(self.NUM):
serv = Server(path=PATH)
try:
serv.run()
sources = TestSources(3000)
sources.new_test_video(pattern=4)
sources.new_test_video(pattern=5)
preview = PreviewSinks(3001)
preview.run()
out_file = "output-{0}.data".format(index)
video_sink = VideoFileSink(3001, out_file)
time.sleep(3)
controller = Controller()
res = controller.switch(channel, port)
print res
time.sleep(3)
video_sink.terminate()
sources.terminate_video()
preview.terminate()
serv.terminate(1)
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()
示例12: test_normal
def test_normal(self, monkeypatch):
"""Test if the parameters are valid"""
monkeypatch.setattr(Connection, 'connect_dbus', Mock())
monkeypatch.setattr(Connection, 'signal_subscribe', Mock())
controller = Controller(address='unix:abstract=abcd')
controller.establish_connection()
assert controller.connection is not None
示例13: test_unpack
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)
示例14: get_encode_port
def get_encode_port(num):
"""Test get_encode_port - num times"""
video_port = 3000
serv = Server(path=PATH, video_port=video_port)
try:
serv.run()
sources = TestSources(video_port=video_port)
sources.new_test_video()
expected_res = [video_port + 2] * num
controller = Controller()
controller.establish_connection()
res = []
for _ in range(num):
res.append(controller.get_encode_port())
assert expected_res == res
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()
示例15: get_audio_port
def get_audio_port(num):
"""Test get_audio_port"""
audio_port = 8000
serv = Server(path=PATH, audio_port=audio_port)
try:
serv.run()
sources = TestSources(audio_port=audio_port)
sources.new_test_audio()
expected_res = [3003] * num
controller = Controller()
controller.establish_connection()
res = []
for _ in range(num):
res.append(controller.get_audio_port())
assert expected_res == res
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())