1
# $Id: mod_pres.py 2078 2008-06-27 21:12:12Z nanang $
5
import inc_const as const
9
cfg_file = imp.load_source("cfg_file", ARGS[1])
15
uri1 = cfg_file.test_param.inst_params[0].uri
18
uri2 = cfg_file.test_param.inst_params[1].uri
21
# if have_reg then wait for couple of seconds for PUBLISH
22
# to complete (just in case pUBLISH is used)
23
if u1.inst_param.have_reg:
25
if u2.inst_param.have_reg:
31
u1.expect("Subscription state changed NULL --> SENT")
32
u1.expect("Presence subscription.*is ACCEPTED")
33
if not u2.inst_param.have_publish:
34
# Process incoming SUBSCRIBE in U2
35
# Finds out which account gets the subscription in U2
36
line = u2.expect("pjsua_pres.*subscription.*using account")
37
acc2 = line.split("using account ")[1]
38
# wait until we've got Online notification
39
u1.expect(uri2 + ".*Online")
48
u2.expect("Subscription state changed NULL --> SENT")
49
u2.expect("Presence subscription.*is ACCEPTED")
50
if not u1.inst_param.have_publish:
51
# Process incoming SUBSCRIBE in U1
52
# Finds out which account gets the subscription in U1
53
line = u1.expect("pjsua_pres.*subscription.*using account")
54
acc1 = line.split("using account ")[1]
55
# wait until we've got Online notification
56
u2.expect(uri1 + ".*Online")
62
# Set current account in both U1 and U2
66
u1.expect("Current account changed")
70
u2.expect("Current account changed")
76
# u2 toggles online status
78
u1.expect(uri2 + ".*status.*Offline")
85
# u1 toggles online status
87
u2.expect(uri1 + ".*status.*Offline")
94
# u2 set online status to On the phone
97
u1.expect(uri2 + ".*status.*On the phone")
98
u2.expect("On the phone")
109
im_text = "Hello World from U1"
112
u2.expect(" is typing")
114
u1.expect(im_text+".*delivered successfully")
115
u2.expect("MESSAGE from.*"+im_text)
122
# Here where it all comes together
123
test = cfg_file.test_param
124
test.test_func = test_func