summaryrefslogtreecommitdiff
path: root/pjsip-apps/src/test-pjsua/mod_call.py
diff options
context:
space:
mode:
Diffstat (limited to 'pjsip-apps/src/test-pjsua/mod_call.py')
-rw-r--r--pjsip-apps/src/test-pjsua/mod_call.py92
1 files changed, 92 insertions, 0 deletions
diff --git a/pjsip-apps/src/test-pjsua/mod_call.py b/pjsip-apps/src/test-pjsua/mod_call.py
new file mode 100644
index 00000000..2cd81951
--- /dev/null
+++ b/pjsip-apps/src/test-pjsua/mod_call.py
@@ -0,0 +1,92 @@
+# $Id$
+import time
+import imp
+import sys
+import inc_param as param
+import inc_const as const
+
+# Load configuration
+cfg_file = imp.load_source("cfg_file", sys.argv[2])
+
+# Test title
+title = cfg_file.config.title
+port1 = "9060"
+
+# First pjsua
+p1 = param.Pjsua(
+ "callee",
+ args = cfg_file.config.callee_cfg.arg + " --local-port="+port1,
+ echo = cfg_file.config.callee_cfg.echo_enabled,
+ trace = cfg_file.config.callee_cfg.trace_enabled
+ )
+
+# Second pjsua, make call to the first one
+p2 = param.Pjsua(
+ "caller",
+ args = cfg_file.config.caller_cfg.arg + " --local-port=0",
+ echo = cfg_file.config.caller_cfg.echo_enabled,
+ trace = cfg_file.config.caller_cfg.trace_enabled
+ )
+
+# Test body function
+def test_func(t):
+ callee = t.process[0]
+ caller = t.process[1]
+
+ # Caller making call
+ caller.send("m")
+ caller.send("sip:localhost:" + port1)
+ caller.expect(const.STATE_CALLING)
+
+ # Callee answers with 200/OK
+ time.sleep(1)
+ callee.expect(const.EVENT_INCOMING_CALL)
+ callee.send("a")
+ callee.send("200")
+
+ # Wait until call is connected in both endpoints
+ time.sleep(1)
+ if callee.expect(const.STATE_CONFIRMED, False)==None:
+ raise TestError("Call failed")
+ caller.expect(const.STATE_CONFIRMED)
+
+ # Hold call
+ time.sleep(2)
+ caller.send("H")
+ caller.expect(const.MEDIA_HOLD)
+ callee.expect(const.MEDIA_HOLD)
+
+ # Release hold
+ time.sleep(2)
+ caller.send("v")
+ caller.expect(const.MEDIA_ACTIVE)
+ callee.expect(const.MEDIA_ACTIVE)
+
+ # UPDATE
+ time.sleep(2)
+ callee.send("U")
+ callee.expect(const.MEDIA_ACTIVE)
+ caller.expect(const.MEDIA_ACTIVE)
+
+ # Send DTMF
+ time.sleep(2)
+ caller.send("#")
+ caller.send("1122")
+ callee.expect(const.RX_DTMF + "1")
+ callee.expect(const.RX_DTMF + "1")
+ callee.expect(const.RX_DTMF + "2")
+ callee.expect(const.RX_DTMF + "2")
+
+ # Hangup call
+ time.sleep(1)
+ caller.send("h")
+
+ # Wait until calls are cleared in both endpoints
+ caller.expect(const.STATE_DISCONNECTED)
+ callee.expect(const.STATE_DISCONNECTED)
+
+
+# Here where it all comes together
+test = param.Test(title, run=[p1, p2], func=test_func)
+
+