Skip to content

Commit

Permalink
#1773: add webcam test
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@23117 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jul 10, 2019
1 parent f20fac5 commit 904c0ea
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/unittests/unit/client/mixins/audioclient_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,9 @@ def test_audio(self):
"sound.decoders" : ["mp3", "opus"],
"sound.ogg-latency-fix" : True,
})
def stop():
x.stop_all_sound()
self.stop()
self.glib.timeout_add(5000, stop)
try:
x.parse_server_capabilities()
self.main_loop.run()
finally:
x.stop_all_sound()
self.glib.timeout_add(5000, self.stop)
x.parse_server_capabilities()
self.main_loop.run()
#print("packets=%s" % (self.packets,))
assert len(self.packets)>2
assert self.verify_packet(0, ("sound-control", "start")) or self.verify_packet(1, ("sound-control", "start"))
Expand Down
50 changes: 50 additions & 0 deletions src/unittests/unit/client/mixins/webcam_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env python
# This file is part of Xpra.
# Copyright (C) 2019 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

import unittest

from xpra.os_util import PYTHON3
from xpra.util import AdHocStruct, typedict
from xpra.client.mixins.webcam import WebcamForwarder
from unit.client.mixins.clientmixintest_util import ClientMixinTest


class WebcamTest(ClientMixinTest):

def test_webcam(self):
x = WebcamForwarder()
self.mixin = x
opts = AdHocStruct()
opts.webcam = "on"
x.init(opts)
x.send = self.send
x.idle_add = self.glib.idle_add
x.timeout_add = self.glib.timeout_add
x.source_remove = self.glib.source_remove
assert x.get_caps() is not None
x.server_capabilities = typedict({
"webcam" : True,
"webcam.encodings" : ("png", "jpeg"),
"virtual-video-devices" : 1,
})
if x.webcam_forwarding>0:
self.glib.timeout_add(2500, x.stop_sending_webcam)
self.glib.timeout_add(5000, self.stop)
x.parse_server_capabilities()
self.main_loop.run()
print("packets=%s" % (self.packets,))
assert len(self.packets)>2
assert self.verify_packet(0, ("webcam-start", 0, ))
assert self.verify_packet(1, ("webcam-frame", 0, ))
assert self.verify_packet(-1, ("webcam-stop", 0, ))

def main():
if PYTHON3:
unittest.main()


if __name__ == '__main__':
main()

0 comments on commit 904c0ea

Please sign in to comment.