| 1 |
import time |
| 2 |
import sys |
| 3 |
import inc_const as const |
| 4 |
import inc_util as util |
| 5 |
from inc_cfg import * |
| 6 |
|
| 7 |
|
| 8 |
cfg_file = util.load_module_from_file("cfg_file", ARGS[1]) |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
def 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 |
|
| 21 |
|
| 22 |
if u1.inst_param.have_reg: |
| 23 |
time.sleep(1) |
| 24 |
if u2.inst_param.have_reg: |
| 25 |
time.sleep(1) |
| 26 |
|
| 27 |
|
| 28 |
if u1.use_telnet: |
| 29 |
u1.send("im add_b " + uri2) |
| 30 |
else: |
| 31 |
u1.send("+b") |
| 32 |
u1.send(uri2) |
| 33 |
u1.expect("Subscription state changed NULL --> SENT") |
| 34 |
u1.expect("Presence subscription.*is ACCEPTED") |
| 35 |
if not u2.inst_param.have_publish: |
| 36 |
|
| 37 |
|
| 38 |
line = u2.expect("pjsua_pres.*subscription.*using account") |
| 39 |
acc2 = line.split("using account ")[1] |
| 40 |
|
| 41 |
u1.expect(uri2 + ".*Online") |
| 42 |
|
| 43 |
|
| 44 |
u1.sync_stdout() |
| 45 |
u2.sync_stdout() |
| 46 |
|
| 47 |
|
| 48 |
if u2.use_telnet: |
| 49 |
u2.send("im add_b " + uri1) |
| 50 |
else: |
| 51 |
u2.send("+b") |
| 52 |
u2.send(uri1) |
| 53 |
u2.expect("Subscription state changed NULL --> SENT") |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
u2.expect("Presence subscription.*is ACTIVE") |
| 58 |
if not u1.inst_param.have_publish: |
| 59 |
|
| 60 |
|
| 61 |
line = u1.expect("pjsua_pres.*subscription.*using account") |
| 62 |
acc1 = line.split("using account ")[1] |
| 63 |
|
| 64 |
u2.expect(uri1 + ".*Online") |
| 65 |
|
| 66 |
|
| 67 |
u1.sync_stdout() |
| 68 |
u2.sync_stdout() |
| 69 |
|
| 70 |
|
| 71 |
if acc1!="-1": |
| 72 |
if u1.use_telnet: |
| 73 |
u1.send("acc prev " + acc1) |
| 74 |
else: |
| 75 |
u1.send(">") |
| 76 |
u1.send(acc1) |
| 77 |
u1.expect("Current account changed") |
| 78 |
if acc2!="-1": |
| 79 |
if u2.use_telnet: |
| 80 |
u2.send("acc prev " + acc2) |
| 81 |
else: |
| 82 |
u2.send(">") |
| 83 |
u2.send(acc2) |
| 84 |
u2.expect("Current account changed") |
| 85 |
|
| 86 |
|
| 87 |
u1.sync_stdout() |
| 88 |
u2.sync_stdout() |
| 89 |
|
| 90 |
|
| 91 |
if u2.use_telnet: |
| 92 |
u2.send("im tog_state") |
| 93 |
else: |
| 94 |
u2.send("t") |
| 95 |
u1.expect(uri2 + ".*status.*Offline") |
| 96 |
u2.expect("offline") |
| 97 |
|
| 98 |
|
| 99 |
u1.sync_stdout() |
| 100 |
u2.sync_stdout() |
| 101 |
|
| 102 |
|
| 103 |
if u1.use_telnet: |
| 104 |
u1.send("im tog_state") |
| 105 |
else: |
| 106 |
u1.send("t") |
| 107 |
u2.expect(uri1 + ".*status.*Offline") |
| 108 |
u1.expect("offline") |
| 109 |
|
| 110 |
|
| 111 |
u1.sync_stdout() |
| 112 |
u2.sync_stdout() |
| 113 |
|
| 114 |
|
| 115 |
if u2.use_telnet: |
| 116 |
u2.send("im pre_text 3") |
| 117 |
else: |
| 118 |
u2.send("T") |
| 119 |
u2.send("3") |
| 120 |
u1.expect(uri2 + ".*status.*On the phone") |
| 121 |
u2.expect("On the phone") |
| 122 |
|
| 123 |
|
| 124 |
u1.sync_stdout() |
| 125 |
u2.sync_stdout() |
| 126 |
|
| 127 |
|
| 128 |
u1.sync_stdout() |
| 129 |
u2.sync_stdout() |
| 130 |
|
| 131 |
|
| 132 |
if u1.use_telnet: |
| 133 |
im_text = "Hello-World-from-U1" |
| 134 |
u1.send("im send_im %s %s" % (uri2, im_text)) |
| 135 |
else: |
| 136 |
im_text = "Hello World from U1" |
| 137 |
u1.send("i") |
| 138 |
u1.send(uri2) |
| 139 |
u2.expect(" is typing") |
| 140 |
u1.send(im_text) |
| 141 |
u1.expect(im_text+".*delivered successfully") |
| 142 |
u2.expect("MESSAGE from.*"+im_text) |
| 143 |
|
| 144 |
|
| 145 |
u1.sync_stdout() |
| 146 |
u2.sync_stdout() |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
test = cfg_file.test_param |
| 151 |
test.test_func = test_func |
| 152 |
|