mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-29 09:09:21 +00:00
Add testing module in Python.
This commit is contained in:
parent
cd23673317
commit
581da48a50
3 changed files with 45 additions and 2 deletions
|
|
@ -272,6 +272,8 @@ static PyMethodDef pylinphone_{{enum_name}}_ModuleMethods[] = {
|
|||
|
||||
{{/enums}}
|
||||
|
||||
{{> linphone_testing_module}}
|
||||
|
||||
PyMODINIT_FUNC initlinphone(void) {
|
||||
PyObject *m;
|
||||
PyObject *menum;
|
||||
|
|
@ -318,4 +320,6 @@ PyMODINIT_FUNC initlinphone(void) {
|
|||
/* Hand-written classes. */
|
||||
Py_INCREF(&pylinphone_VideoSizeType);
|
||||
PyModule_AddObject(m, "VideoSize", (PyObject *)&pylinphone_VideoSizeType);
|
||||
|
||||
pylinphone_init_testing_module(m);
|
||||
}
|
||||
|
|
|
|||
40
tools/python/apixml2python/linphone_testing_module.mustache
Normal file
40
tools/python/apixml2python/linphone_testing_module.mustache
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#include "private.h"
|
||||
|
||||
static PyObject * pylinphone_testing_module_method_set_dns_user_hosts_file(PyObject *self, PyObject *args) {
|
||||
PyObject *_core;
|
||||
char *_path;
|
||||
LinphoneCore *_core_native_ptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "Oz", &_core, &_path)) {
|
||||
return NULL;
|
||||
}
|
||||
if ((_core != Py_None) && !PyObject_IsInstance(_core, (PyObject *)&pylinphone_CoreType)) {
|
||||
PyErr_SetString(PyExc_TypeError, "The '_core' argument must be a linphone.Core instance.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((_core != NULL) && (_core != Py_None)) {
|
||||
if ((_core_native_ptr = pylinphone_Core_get_native_ptr(_core)) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
pylinphone_trace(1, "[PYLINPHONE] >>> %s(%p [%p], %s)", __FUNCTION__, _core, _core_native_ptr, _path);
|
||||
sal_set_dns_user_hosts_file(_core_native_ptr->sal, _path);
|
||||
pylinphone_dispatch_messages();
|
||||
|
||||
pylinphone_trace(-1, "[PYLINPHONE] <<< %s -> None", __FUNCTION__);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyMethodDef pylinphone_TestingModuleMethods[] = {
|
||||
{ "set_dns_user_hosts_file", pylinphone_testing_module_method_set_dns_user_hosts_file, METH_VARARGS, "Allows to set a user specified hosts file." },
|
||||
/* Sentinel */
|
||||
{ NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
static void pylinphone_init_testing_module(PyObject *linphone_module) {
|
||||
PyObject *mtesting = Py_InitModule3("testing", pylinphone_TestingModuleMethods, "Python module adding some testing features for the Linphone library.");
|
||||
Py_INCREF(mtesting);
|
||||
if (PyModule_AddObject(linphone_module, "testing", mtesting) < 0) return;
|
||||
}
|
||||
|
|
@ -392,8 +392,6 @@ class CoreManager:
|
|||
else:
|
||||
proxy_count = 0
|
||||
if proxy_count:
|
||||
if self.logger is not None:
|
||||
self.logger.warning(self)
|
||||
CoreManager.wait_for_until(self, None, lambda manager: manager.stats.number_of_LinphoneRegistrationOk == proxy_count, 5000 * proxy_count)
|
||||
assert_equals(self.stats.number_of_LinphoneRegistrationOk, proxy_count)
|
||||
self.enable_audio_codec("PCMU", 8000)
|
||||
|
|
@ -411,6 +409,7 @@ class CoreManager:
|
|||
filepath = os.path.join(resources_path, rc_path)
|
||||
assert_equals(os.path.isfile(filepath), True)
|
||||
lc = linphone.Core.new(vtable, None, filepath)
|
||||
linphone.testing.set_dns_user_hosts_file(lc, os.path.join(resources_path, 'tester_hosts'))
|
||||
lc.root_ca = os.path.join(resources_path, 'certificates', 'cn', 'cafile.pem')
|
||||
lc.ring = os.path.join(resources_path, 'sounds', 'oldphone.wav')
|
||||
lc.ringback = os.path.join(resources_path, 'sounds', 'ringback.wav')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue