Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
liblinphone
Commits
e07c0194
Commit
e07c0194
authored
Feb 21, 2017
by
Ghislain MARY
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix unittests in Python module.
parent
be79d631
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
21 deletions
+33
-21
tools/python/apixml2python/linphone_module.mustache
tools/python/apixml2python/linphone_module.mustache
+7
-7
tools/python/unittests/linphonetester.py
tools/python/unittests/linphonetester.py
+3
-0
tools/python/unittests/test_message.py
tools/python/unittests/test_message.py
+22
-12
tools/python/unittests/test_setup.py
tools/python/unittests/test_setup.py
+1
-2
No files found.
tools/python/apixml2python/linphone_module.mustache
View file @
e07c0194
...
...
@@ -46,32 +46,32 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size,
#endif
#if
ndef PyInt_Check
#if
PY_MAJOR_VERSION >= 3
#define PyInt_Check(p) PyLong_Check(p)
#endif
#if
ndef PyInt_AsLong
#if
PY_MAJOR_VERSION >= 3
#define PyInt_AsLong(io) PyLong_AsLong(io)
#endif
#if
ndef PyInt_AS_LONG
#if
PY_MAJOR_VERSION >= 3
static int pylinphone_aslongoverflow;
#define PyInt_AS_LONG(io) PyLong_AsLongAndOverflow(io,
&
pylinphone_aslongoverflow)
#endif
#if
ndef PyInt_AsSsize_t
#if
PY_MAJOR_VERSION >= 3
#define PyInt_AsSsize_t(io) PyLong_AsSsize_t(io)
#endif
#if
ndef PyInt_AsUnsignedLongMask
#if
PY_MAJOR_VERSION >= 3
#define PyInt_AsUnsignedLongMask(io) PyLong_AsUnsignedLongMask(io)
#endif
#if
ndef PyString_Check
#if
PY_MAJOR_VERSION >= 3
#define PyString_Check(io) PyUnicode_Check(io)
#endif
#if
ndef PyString_FromString
#if
PY_MAJOR_VERSION >= 3
#define PyString_FromString(v) PyUnicode_FromString(v)
#endif
...
...
tools/python/unittests/linphonetester.py
View file @
e07c0194
...
...
@@ -216,6 +216,9 @@ class CoreManagerStats:
self
.
number_of_LinphoneMessageInProgress
=
0
self
.
number_of_LinphoneMessageDelivered
=
0
self
.
number_of_LinphoneMessageNotDelivered
=
0
self
.
number_of_LinphoneMessageFileTransferDone
=
0
self
.
number_of_LinphoneMessageDeliveredToUser
=
0
self
.
number_of_LinphoneMessageDisplayed
=
0
self
.
number_of_LinphoneIsComposingActiveReceived
=
0
self
.
number_of_LinphoneIsComposingIdleReceived
=
0
self
.
number_of_LinphoneFileTransferDownloadSuccessful
=
0
...
...
tools/python/unittests/test_message.py
View file @
e07c0194
...
...
@@ -22,6 +22,12 @@ class TestMessage:
stats
.
number_of_LinphoneMessageInProgress
+=
1
elif
state
==
linphone
.
ChatMessageState
.
FileTransferError
:
stats
.
number_of_LinphoneMessageNotDelivered
+=
1
elif
state
==
linphone
.
ChatMessageState
.
FileTransferDone
:
stats
.
number_of_LinphoneMessageFileTransferDone
+=
1
elif
state
==
linphone
.
ChatMessageState
.
DeliveredToUser
:
stats
.
number_of_LinphoneMessageDeliveredToUser
+=
1
elif
state
==
linphone
.
ChatMessageState
.
Displayed
:
stats
.
number_of_LinphoneMessageDisplayed
+=
1
else
:
linphonetester_logger
.
error
(
"[TESTER] Unexpected state [{state}] for message [{msg}]"
.
format
(
msg
=
msg
,
state
=
linphone
.
ChatMessageState
.
string
(
state
)))
...
...
@@ -65,13 +71,15 @@ class TestMessage:
f
.
write
(
buf
.
content
)
f
.
close
()
def
create_message_from_
no_webcam
(
self
,
chat_room
):
send_filepath
=
os
.
path
.
join
(
tester_resources_path
,
'
images'
,
'nowebcamCIF.jpg
'
)
def
create_message_from_
sintel_trailer
(
self
,
chat_room
):
send_filepath
=
os
.
path
.
join
(
tester_resources_path
,
'
sounds'
,
'sintel_trailer_opus_h264.mkv
'
)
content
=
chat_room
.
core
.
create_content
()
content
.
type
=
'image'
content
.
subtype
=
'jpeg'
content
.
type
=
'video'
content
.
subtype
=
'mkv'
linphonetester_logger
.
info
(
"[TESTER] os.path.getsize(send_filepath)={}"
.
format
(
os
.
path
.
getsize
(
send_filepath
)))
content
.
size
=
os
.
path
.
getsize
(
send_filepath
)
# total size to be transfered
content
.
name
=
'nowebcamCIF.jpg'
linphonetester_logger
.
info
(
"[TESTER] content.size={}"
.
format
(
content
.
size
))
content
.
name
=
'sintel_trailer_opus_h264.mkv'
message
=
chat_room
.
create_file_transfer_message
(
content
)
message
.
callbacks
.
msg_state_changed
=
TestMessage
.
msg_state_changed
message
.
callbacks
.
file_transfer_send
=
TestMessage
.
file_transfer_send
...
...
@@ -119,14 +127,16 @@ class TestMessage:
def
test_transfer_message
(
self
):
marie
=
CoreManager
(
'marie_rc'
)
pauline
=
CoreManager
(
'pauline_tcp_rc'
)
send_filepath
=
os
.
path
.
join
(
tester_resources_path
,
'
images'
,
'nowebcamCIF.jpg
'
)
send_filepath
=
os
.
path
.
join
(
tester_resources_path
,
'
sounds'
,
'sintel_trailer_opus_h264.mkv
'
)
receive_filepath
=
'receive_file.dump'
if
os
.
path
.
exists
(
receive_filepath
):
os
.
remove
(
receive_filepath
)
pauline
.
lc
.
file_transfer_server
=
"https://www.linphone.org:444/lft.php"
self
.
wait_for_server_to_purge_messages
(
marie
,
pauline
)
chat_room
=
pauline
.
lc
.
get_chat_room
(
marie
.
identity
)
message
=
self
.
create_message_from_
no_webcam
(
chat_room
)
message
=
self
.
create_message_from_
sintel_trailer
(
chat_room
)
chat_room
.
send_chat_message_2
(
message
)
assert_equals
(
CoreManager
.
wait_for
(
pauline
,
marie
,
lambda
pauline
,
marie
:
marie
.
stats
.
number_of_LinphoneMessageReceivedWithFile
==
1
),
True
)
assert_equals
(
CoreManager
.
wait_for
_until
(
pauline
,
marie
,
lambda
pauline
,
marie
:
marie
.
stats
.
number_of_LinphoneMessageReceivedWithFile
==
1
,
60000
),
True
)
if
marie
.
stats
.
last_received_chat_message
is
not
None
:
cbs
=
marie
.
stats
.
last_received_chat_message
.
callbacks
cbs
.
msg_state_changed
=
TestMessage
.
msg_state_changed
...
...
@@ -134,7 +144,7 @@ class TestMessage:
cbs
.
file_transfer_progress_indication
=
TestMessage
.
file_transfer_progress_indication
marie
.
stats
.
last_received_chat_message
.
user_data
=
receive_filepath
marie
.
stats
.
last_received_chat_message
.
download_file
()
assert_equals
(
CoreManager
.
wait_for
(
pauline
,
marie
,
lambda
pauline
,
marie
:
marie
.
stats
.
number_of_LinphoneFileTransferDownloadSuccessful
==
1
),
True
)
assert_equals
(
CoreManager
.
wait_for
_until
(
pauline
,
marie
,
lambda
pauline
,
marie
:
marie
.
stats
.
number_of_LinphoneFileTransferDownloadSuccessful
==
1
,
55000
),
True
)
assert_equals
(
pauline
.
stats
.
number_of_LinphoneMessageInProgress
,
2
)
assert_equals
(
CoreManager
.
wait_for
(
pauline
,
marie
,
lambda
pauline
,
marie
:
pauline
.
stats
.
number_of_LinphoneMessageDelivered
==
1
),
True
)
assert_equals
(
filecmp
.
cmp
(
send_filepath
,
receive_filepath
,
shallow
=
False
),
True
)
...
...
@@ -147,10 +157,10 @@ class TestMessage:
pauline
.
lc
.
file_transfer_server
=
"https://www.linphone.org:444/lft.php"
self
.
wait_for_server_to_purge_messages
(
marie
,
pauline
)
chat_room
=
pauline
.
lc
.
get_chat_room
(
marie
.
identity
)
message
=
self
.
create_message_from_
no_webcam
(
chat_room
)
message
=
self
.
create_message_from_
sintel_trailer
(
chat_room
)
chat_room
.
send_chat_message_2
(
message
)
# Wait for file to be at least 5
0
% uploaded and cancel the transfer
assert_equals
(
CoreManager
.
wait_for
(
pauline
,
marie
,
lambda
pauline
,
marie
:
pauline
.
stats
.
progress_of_LinphoneFileTransfer
>=
5
0
),
True
)
# Wait for file to be at least
2
5% uploaded and cancel the transfer
assert_equals
(
CoreManager
.
wait_for
_until
(
pauline
,
marie
,
lambda
pauline
,
marie
:
pauline
.
stats
.
progress_of_LinphoneFileTransfer
>=
25
,
6000
0
),
True
)
message
.
cancel_file_transfer
()
assert_equals
(
CoreManager
.
wait_for
(
pauline
,
marie
,
lambda
pauline
,
marie
:
pauline
.
stats
.
number_of_LinphoneMessageNotDelivered
==
1
),
True
)
assert_equals
(
pauline
.
stats
.
number_of_LinphoneMessageNotDelivered
,
1
)
...
...
tools/python/unittests/test_setup.py
View file @
e07c0194
...
...
@@ -9,8 +9,7 @@ class TestSetup:
linphone
.
Factory
.
clean
()
def
test_version
(
self
):
lc
=
linphone
.
Factory
.
get
().
create_core
(
None
,
None
,
None
)
assert_equals
(
lc
.
version
.
find
(
"unknown"
),
-
1
)
assert_equals
(
linphone
.
Core
.
get_version
().
find
(
"unknown"
),
-
1
)
def
test_address
(
self
):
create_address
(
None
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment