Add tests for SGR protocol encoding

This commit is contained in:
Kovid Goyal
2018-01-07 23:48:16 +05:30
parent 13d5f04ad9
commit ce230b071b
3 changed files with 49 additions and 0 deletions

View File

@@ -185,6 +185,7 @@ extern bool init_state(PyObject *module);
extern bool init_keys(PyObject *module);
extern bool init_graphics(PyObject *module);
extern bool init_shaders(PyObject *module);
extern bool init_mouse(PyObject *module);
#ifdef __APPLE__
extern int init_CoreText(PyObject *);
extern bool init_cocoa(PyObject *module);
@@ -217,6 +218,7 @@ PyInit_fast_data_types(void) {
if (!init_keys(m)) return NULL;
if (!init_graphics(m)) return NULL;
if (!init_shaders(m)) return NULL;
if (!init_mouse(m)) return NULL;
#ifdef __APPLE__
if (!init_CoreText(m)) return NULL;
if (!init_cocoa(m)) return NULL;

View File

@@ -385,3 +385,23 @@ scroll_event(double UNUSED xoffset, double yoffset) {
}
}
}
static PyObject*
test_encode_mouse(PyObject *self UNUSED, PyObject *args) {
unsigned int x, y;
int mouse_tracking_protocol, button, action, mods;
if (!PyArg_ParseTuple(args, "IIiiii", &x, &y, &mouse_tracking_protocol, &button, &action, &mods)) return NULL;
int sz = encode_mouse_event_impl(x, y, mouse_tracking_protocol, button, action, mods);
return PyUnicode_FromStringAndSize(mouse_event_buf, sz);
}
static PyMethodDef module_methods[] = {
METHODB(test_encode_mouse, METH_VARARGS),
{NULL, NULL, 0, NULL} /* Sentinel */
};
bool
init_mouse(PyObject *module) {
if (PyModule_AddFunctions(module, module_methods) != 0) return false;
return true;
}