blob: e3b996a8aa575eea6d2424bde233dfde8bd0e3b9 [file] [log] [blame]
Benny Prijonocc1ada52008-06-15 19:43:43 +00001# $Id:$
2import time
3import imp
4import sys
5import inc_const as const
6
7# Load configuration
8cfg_file = imp.load_source("cfg_file", sys.argv[2])
9
10
11# Test body function
12def test_func(t):
13 u1 = t.process[0]
14 uri1 = cfg_file.test_param.inst_params[0].uri
15 acc1 = "-1"
16 u2 = t.process[1]
17 uri2 = cfg_file.test_param.inst_params[1].uri
18 acc2 = "-1"
19
20 # if have_reg then wait for couple of seconds for PUBLISH
21 # to complete (just in case pUBLISH is used)
22 if u1.inst_param.have_reg:
23 time.sleep(1)
24 if u2.inst_param.have_reg:
25 time.sleep(1)
26
27 # U1 adds U2 as buddy
28 u1.send("+b")
29 u1.send(uri2)
30 u1.expect("Subscription state changed NULL --> SENT")
31 u1.expect("Presence subscription.*is ACCEPTED")
32 if not u2.inst_param.have_publish:
33 # Process incoming SUBSCRIBE in U2
34 # Finds out which account gets the subscription in U2
35 line = u2.expect("pjsua_pres.*subscription.*using account")
36 acc2 = line.split("using account ")[1]
37 # wait until we've got Online notification
38 u1.expect(uri2 + ".*Online")
39
40 # Synchronize stdout
41 u1.sync_stdout()
42 u2.sync_stdout()
43
44 # U2 adds U1 as buddy
45 u2.send("+b")
46 u2.send(uri1)
47 u2.expect("Subscription state changed NULL --> SENT")
48 u2.expect("Presence subscription.*is ACCEPTED")
49 if not u1.inst_param.have_publish:
50 # Process incoming SUBSCRIBE in U1
51 # Finds out which account gets the subscription in U1
52 line = u1.expect("pjsua_pres.*subscription.*using account")
53 acc1 = line.split("using account ")[1]
54 # wait until we've got Online notification
55 u2.expect(uri1 + ".*Online")
56
57 # Synchronize stdout
58 u1.sync_stdout()
59 u2.sync_stdout()
60
61 # Set current account in both U1 and U2
62 if acc1!="-1":
63 u1.send(">")
64 u1.send(acc1)
65 u1.expect("Current account changed")
66 if acc2!="-1":
67 u2.send(">")
68 u2.send(acc2)
69 u2.expect("Current account changed")
70
71 # Synchronize stdout
72 u1.sync_stdout()
73 u2.sync_stdout()
74
75 # u2 toggles online status
76 u2.send("t")
77 u1.expect(uri2 + ".*status.*Offline")
78 u2.expect("offline")
79
80 # Synchronize stdout
81 u1.sync_stdout()
82 u2.sync_stdout()
83
84 # u1 toggles online status
85 u1.send("t")
86 u2.expect(uri1 + ".*status.*Offline")
87 u1.expect("offline")
88
89 # Synchronize stdout
90 u1.sync_stdout()
91 u2.sync_stdout()
92
93 # u2 set online status to On the phone
94 u2.send("T")
95 u2.send("3")
96 u1.expect(uri2 + ".*status.*On the phone")
97 u2.expect("On the phone")
98
99 # Synchronize stdout
100 u1.sync_stdout()
101 u2.sync_stdout()
102
103 # Synchronize stdout
104 u1.sync_stdout()
105 u2.sync_stdout()
106
107 # U1 send IM
108 im_text = "Hello World from U1"
109 u1.send("i")
110 u1.send("1")
111 u1.send(im_text)
112 u2.expect(" is typing")
113 u2.expect("MESSAGE from.*"+im_text)
114 u1.expect(im_text+".*delivered successfully")
115
116 # Synchronize stdout
117 u1.sync_stdout()
118 u2.sync_stdout()
119
120
121# Here where it all comes together
122test = cfg_file.test_param
123test.test_func = test_func
124