blob: 7dafd52f78c79a2c659919c8c45e666318a84a8c [file] [log] [blame]
Nanang Izzuddinf810f952008-06-18 21:04:14 +00001# $Id$
Benny Prijonocc1ada52008-06-15 19:43:43 +00002import time
3import imp
4import sys
5import inc_const as const
Nanang Izzuddina680bd62008-06-27 21:12:12 +00006from inc_cfg import *
Benny Prijonocc1ada52008-06-15 19:43:43 +00007
8# Load configuration
Nanang Izzuddina680bd62008-06-27 21:12:12 +00009cfg_file = imp.load_source("cfg_file", ARGS[1])
Benny Prijonocc1ada52008-06-15 19:43:43 +000010
11
12# Test body function
Nanang Izzuddina680bd62008-06-27 21:12:12 +000013def test_func(t):
Benny Prijonocc1ada52008-06-15 19:43:43 +000014 u1 = t.process[0]
15 uri1 = cfg_file.test_param.inst_params[0].uri
16 acc1 = "-1"
17 u2 = t.process[1]
18 uri2 = cfg_file.test_param.inst_params[1].uri
19 acc2 = "-1"
20
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:
24 time.sleep(1)
25 if u2.inst_param.have_reg:
26 time.sleep(1)
27
28 # U1 adds U2 as buddy
29 u1.send("+b")
30 u1.send(uri2)
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")
40
41 # Synchronize stdout
42 u1.sync_stdout()
43 u2.sync_stdout()
44
45 # U2 adds U1 as buddy
46 u2.send("+b")
47 u2.send(uri1)
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")
57
58 # Synchronize stdout
59 u1.sync_stdout()
60 u2.sync_stdout()
61
62 # Set current account in both U1 and U2
63 if acc1!="-1":
64 u1.send(">")
65 u1.send(acc1)
66 u1.expect("Current account changed")
67 if acc2!="-1":
68 u2.send(">")
69 u2.send(acc2)
70 u2.expect("Current account changed")
71
72 # Synchronize stdout
73 u1.sync_stdout()
74 u2.sync_stdout()
75
76 # u2 toggles online status
77 u2.send("t")
78 u1.expect(uri2 + ".*status.*Offline")
79 u2.expect("offline")
80
81 # Synchronize stdout
82 u1.sync_stdout()
83 u2.sync_stdout()
84
85 # u1 toggles online status
86 u1.send("t")
87 u2.expect(uri1 + ".*status.*Offline")
88 u1.expect("offline")
89
90 # Synchronize stdout
91 u1.sync_stdout()
92 u2.sync_stdout()
93
94 # u2 set online status to On the phone
95 u2.send("T")
96 u2.send("3")
97 u1.expect(uri2 + ".*status.*On the phone")
98 u2.expect("On the phone")
99
100 # Synchronize stdout
101 u1.sync_stdout()
102 u2.sync_stdout()
103
104 # Synchronize stdout
105 u1.sync_stdout()
106 u2.sync_stdout()
107
108 # U1 send IM
109 im_text = "Hello World from U1"
110 u1.send("i")
Benny Prijono8ca40142008-06-26 22:20:54 +0000111 u1.send(uri2)
Benny Prijonocc1ada52008-06-15 19:43:43 +0000112 u2.expect(" is typing")
Benny Prijono8ca40142008-06-26 22:20:54 +0000113 u1.send(im_text)
Benny Prijonocc1ada52008-06-15 19:43:43 +0000114 u1.expect(im_text+".*delivered successfully")
Benny Prijono8ca40142008-06-26 22:20:54 +0000115 u2.expect("MESSAGE from.*"+im_text)
Benny Prijonocc1ada52008-06-15 19:43:43 +0000116
117 # Synchronize stdout
118 u1.sync_stdout()
119 u2.sync_stdout()
120
121
122# Here where it all comes together
123test = cfg_file.test_param
124test.test_func = test_func
125