aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/test
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/test')
-rw-r--r--xorg-server/test/input.c78
-rw-r--r--xorg-server/test/xi2/protocol-common.c63
-rw-r--r--xorg-server/test/xi2/protocol-eventconvert.c40
-rw-r--r--xorg-server/test/xi2/protocol-xiquerydevice.c49
4 files changed, 205 insertions, 25 deletions
diff --git a/xorg-server/test/input.c b/xorg-server/test/input.c
index b8dad1c60..afc4d4d99 100644
--- a/xorg-server/test/input.c
+++ b/xorg-server/test/input.c
@@ -52,6 +52,7 @@ static void dix_init_valuators(void)
{
DeviceIntRec dev;
ValuatorClassPtr val;
+ AxisInfoPtr axis;
const int num_axes = 2;
int i;
Atom atoms[MAX_VALUATORS] = { 0 };
@@ -78,6 +79,62 @@ static void dix_init_valuators(void)
}
assert(dev.last.numValuators == num_axes);
+
+ /* invalid increment */
+ assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_VERTICAL, 0.0, SCROLL_FLAG_NONE) == FALSE);
+ /* invalid type */
+ assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_VERTICAL - 1, 1.0, SCROLL_FLAG_NONE) == FALSE);
+ assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_HORIZONTAL + 1, 1.0, SCROLL_FLAG_NONE) == FALSE);
+ /* invalid axisnum */
+ assert(SetScrollValuator(&dev, 2, SCROLL_TYPE_HORIZONTAL, 1.0, SCROLL_FLAG_NONE) == FALSE);
+
+ /* valid */
+ assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_VERTICAL, 3.0, SCROLL_FLAG_NONE) == TRUE);
+ axis = &dev.valuator->axes[0];
+ assert(axis->scroll.increment == 3.0);
+ assert(axis->scroll.type == SCROLL_TYPE_VERTICAL);
+ assert(axis->scroll.flags == 0);
+
+ /* valid */
+ assert(SetScrollValuator(&dev, 1, SCROLL_TYPE_HORIZONTAL, 2.0, SCROLL_FLAG_NONE) == TRUE);
+ axis = &dev.valuator->axes[1];
+ assert(axis->scroll.increment == 2.0);
+ assert(axis->scroll.type == SCROLL_TYPE_HORIZONTAL);
+ assert(axis->scroll.flags == 0);
+
+ /* can add another non-preffered axis */
+ assert(SetScrollValuator(&dev, 1, SCROLL_TYPE_VERTICAL, 5.0, SCROLL_FLAG_NONE) == TRUE);
+ assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_HORIZONTAL, 5.0, SCROLL_FLAG_NONE) == TRUE);
+
+ /* can overwrite with Preferred */
+ assert(SetScrollValuator(&dev, 1, SCROLL_TYPE_VERTICAL, 5.5, SCROLL_FLAG_PREFERRED) == TRUE);
+ axis = &dev.valuator->axes[1];
+ assert(axis->scroll.increment == 5.5);
+ assert(axis->scroll.type == SCROLL_TYPE_VERTICAL);
+ assert(axis->scroll.flags == SCROLL_FLAG_PREFERRED);
+
+ assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_HORIZONTAL, 8.8, SCROLL_FLAG_PREFERRED) == TRUE);
+ axis = &dev.valuator->axes[0];
+ assert(axis->scroll.increment == 8.8);
+ assert(axis->scroll.type == SCROLL_TYPE_HORIZONTAL);
+ assert(axis->scroll.flags == SCROLL_FLAG_PREFERRED);
+
+ /* can overwrite as none */
+ assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_NONE, 5.0,
+ SCROLL_FLAG_NONE) == TRUE);
+ axis = &dev.valuator->axes[0];
+ assert(axis->scroll.type == SCROLL_TYPE_NONE);
+
+ /* can overwrite axis with new settings */
+ assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_VERTICAL, 5.0, SCROLL_FLAG_NONE) == TRUE);
+ axis = &dev.valuator->axes[0];
+ assert(axis->scroll.type == SCROLL_TYPE_VERTICAL);
+ assert(axis->scroll.increment == 5.0);
+ assert(axis->scroll.flags == SCROLL_FLAG_NONE);
+ assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_VERTICAL, 3.0, SCROLL_FLAG_NONE) == TRUE);
+ assert(axis->scroll.type == SCROLL_TYPE_VERTICAL);
+ assert(axis->scroll.increment == 3.0);
+ assert(axis->scroll.flags == SCROLL_FLAG_NONE);
}
/* just check the known success cases, and that error cases set the client's
@@ -1089,12 +1146,16 @@ static void dix_input_valuator_masks(void)
{
ValuatorMask *mask = NULL, *copy;
int nvaluators = MAX_VALUATORS;
- int valuators[nvaluators];
+ double valuators[nvaluators];
+ int val_ranged[nvaluators];
int i;
int first_val, num_vals;
for (i = 0; i < nvaluators; i++)
- valuators[i] = i;
+ {
+ valuators[i] = i + 0.5;
+ val_ranged[i] = i;
+ }
mask = valuator_mask_new(nvaluators);
assert(mask != NULL);
@@ -1104,9 +1165,10 @@ static void dix_input_valuator_masks(void)
for (i = 0; i < nvaluators; i++)
{
assert(!valuator_mask_isset(mask, i));
- valuator_mask_set(mask, i, valuators[i]);
+ valuator_mask_set_double(mask, i, valuators[i]);
assert(valuator_mask_isset(mask, i));
- assert(valuator_mask_get(mask, i) == valuators[i]);
+ assert(valuator_mask_get(mask, i) == trunc(valuators[i]));
+ assert(valuator_mask_get_double(mask, i) == valuators[i]);
assert(valuator_mask_size(mask) == i + 1);
assert(valuator_mask_num_valuators(mask) == i + 1);
}
@@ -1132,7 +1194,7 @@ static void dix_input_valuator_masks(void)
first_val = 5;
num_vals = 6;
- valuator_mask_set_range(mask, first_val, num_vals, valuators);
+ valuator_mask_set_range(mask, first_val, num_vals, val_ranged);
assert(valuator_mask_size(mask) == first_val + num_vals);
assert(valuator_mask_num_valuators(mask) == num_vals);
for (i = 0; i < nvaluators; i++)
@@ -1142,7 +1204,9 @@ static void dix_input_valuator_masks(void)
else
{
assert(valuator_mask_isset(mask, i));
- assert(valuator_mask_get(mask, i) == valuators[i - first_val]);
+ assert(valuator_mask_get(mask, i) == val_ranged[i - first_val]);
+ assert(valuator_mask_get_double(mask, i) ==
+ val_ranged[i - first_val]);
}
}
@@ -1156,6 +1220,8 @@ static void dix_input_valuator_masks(void)
{
assert(valuator_mask_isset(mask, i) == valuator_mask_isset(copy, i));
assert(valuator_mask_get(mask, i) == valuator_mask_get(copy, i));
+ assert(valuator_mask_get_double(mask, i) ==
+ valuator_mask_get_double(copy, i));
}
valuator_mask_free(&mask);
diff --git a/xorg-server/test/xi2/protocol-common.c b/xorg-server/test/xi2/protocol-common.c
index 423453358..56d6bd268 100644
--- a/xorg-server/test/xi2/protocol-common.c
+++ b/xorg-server/test/xi2/protocol-common.c
@@ -29,6 +29,8 @@
#include "extinit.h" /* for XInputExtensionInit */
#include "exglobals.h"
#include "xkbsrv.h" /* for XkbInitPrivates */
+#include "xserver-properties.h"
+#include <X11/extensions/XI2.h>
#include "protocol-common.h"
@@ -63,6 +65,65 @@ static void fake_init_sprite(DeviceIntPtr dev)
sprite->physLimits.y2 = screen.height;
}
+/* This is essentially CorePointerProc with ScrollAxes added */
+static int
+TestPointerProc(DeviceIntPtr pDev, int what)
+{
+#define NBUTTONS 10
+#define NAXES 4
+ BYTE map[NBUTTONS + 1];
+ int i = 0;
+ Atom btn_labels[NBUTTONS] = {0};
+ Atom axes_labels[NAXES] = {0};
+
+ switch (what) {
+ case DEVICE_INIT:
+ for (i = 1; i <= NBUTTONS; i++)
+ map[i] = i;
+
+ btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+ btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+ btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+ btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+ btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
+ btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
+ btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
+ /* don't know about the rest */
+
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_VSCROLL);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_HSCROLL);
+
+ if (!InitPointerDeviceStruct((DevicePtr)pDev, map, NBUTTONS, btn_labels,
+ (PtrCtrlProcPtr)NoopDDA,
+ GetMotionHistorySize(), NAXES, axes_labels))
+ {
+ ErrorF("Could not initialize device '%s'. Out of memory.\n",
+ pDev->name);
+ return BadAlloc;
+ }
+ pDev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2;
+ pDev->last.valuators[0] = pDev->valuator->axisVal[0];
+ pDev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2;
+ pDev->last.valuators[1] = pDev->valuator->axisVal[1];
+
+ SetScrollValuator(pDev, 2, SCROLL_TYPE_VERTICAL, 2.4, SCROLL_FLAG_NONE);
+ SetScrollValuator(pDev, 3, SCROLL_TYPE_HORIZONTAL, 3.5, SCROLL_FLAG_PREFERRED);
+ break;
+
+ case DEVICE_CLOSE:
+ break;
+
+ default:
+ break;
+ }
+
+ return Success;
+
+#undef NBUTTONS
+#undef NAXES
+}
/**
* Create and init 2 master devices (VCP + VCK) and two slave devices, one
* default mouse, one default keyboard.
@@ -84,7 +145,7 @@ struct devices init_devices(void)
EnableDevice(devices.vck, FALSE);
AllocDevicePair(&client, "", &devices.mouse, &devices.kbd,
- CorePointerProc, CoreKeyboardProc, FALSE);
+ TestPointerProc, CoreKeyboardProc, FALSE);
ActivateDevice(devices.mouse, FALSE);
ActivateDevice(devices.kbd, FALSE);
EnableDevice(devices.mouse, FALSE);
diff --git a/xorg-server/test/xi2/protocol-eventconvert.c b/xorg-server/test/xi2/protocol-eventconvert.c
index 6ec94be6c..bfa23b51f 100644
--- a/xorg-server/test/xi2/protocol-eventconvert.c
+++ b/xorg-server/test/xi2/protocol-eventconvert.c
@@ -41,6 +41,7 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out,
int nvals = 0;
int bits_set;
int len;
+ uint32_t flagmask = 0;
if (swap)
{
@@ -51,6 +52,7 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out,
swapl(&out->time);
swapl(&out->detail);
swaps(&out->valuators_len);
+ swapl(&out->flags);
}
@@ -61,7 +63,17 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out,
assert(out->detail == in->detail.button);
assert(out->deviceid == in->deviceid);
assert(out->valuators_len >= bytes_to_int32(bits_to_bytes(sizeof(in->valuators.mask))));
- assert(out->flags == 0); /* FIXME: we don't set the flags yet */
+
+ switch (in->type) {
+ case ET_RawMotion:
+ case ET_RawButtonPress:
+ case ET_RawButtonRelease:
+ flagmask = XIPointerEmulated;
+ break;
+ default:
+ flagmask = 0;
+ }
+ assert((out->flags & ~flagmask) == 0);
ptr = (unsigned char*)&out[1];
bits_set = 0;
@@ -92,8 +104,8 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out,
value = (FP3232*)(((unsigned char*)&out[1]) + out->valuators_len * 4);
value += nvals;
- vi.integral = in->valuators.data[i];
- vi.frac = in->valuators.data_frac[i];
+ vi.integral = trunc(in->valuators.data[i]);
+ vi.frac = in->valuators.data[i] - vi.integral;
vo.integral = value->integral;
vo.frac = value->frac;
@@ -108,8 +120,8 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out,
raw_value = value + bits_set;
- vi.integral = in->valuators.data_raw[i];
- vi.frac = in->valuators.data_raw_frac[i];
+ vi.integral = trunc(in->valuators.data_raw[i]);
+ vi.frac = in->valuators.data_raw[i] - vi.integral;
vo.integral = raw_value->integral;
vo.frac = raw_value->frac;
@@ -247,10 +259,8 @@ static void test_convert_XIRawEvent(void)
{
XISetMask(in.valuators.mask, i);
- in.valuators.data[i] = i;
- in.valuators.data_raw[i] = i + 10;
- in.valuators.data_frac[i] = i + 20;
- in.valuators.data_raw_frac[i] = i + 30;
+ in.valuators.data[i] = i + (i * 0.0010);
+ in.valuators.data_raw[i] = (i + 10) + (i * 0.0030);
test_XIRawEvent(&in);
XIClearMask(in.valuators.mask, i);
}
@@ -305,6 +315,11 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out,
assert(out->sourceid == in->sourceid);
switch (in->type) {
+ case ET_ButtonPress:
+ case ET_Motion:
+ case ET_ButtonRelease:
+ flagmask = XIPointerEmulated;
+ break;
case ET_KeyPress:
flagmask = XIKeyRepeat;
break;
@@ -375,8 +390,8 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out,
{
FP3232 vi, vo;
- vi.integral = in->valuators.data[i];
- vi.frac = in->valuators.data_frac[i];
+ vi.integral = trunc(in->valuators.data[i]);
+ vi.frac = (in->valuators.data[i] - vi.integral) * (1UL << 32);
vo = *values;
@@ -618,8 +633,7 @@ static void test_convert_XIDeviceEvent(void)
{
XISetMask(in.valuators.mask, i);
- in.valuators.data[i] = i;
- in.valuators.data_frac[i] = i + 20;
+ in.valuators.data[i] = i + (i * 0.0020);
test_XIDeviceEvent(&in);
XIClearMask(in.valuators.mask, i);
}
diff --git a/xorg-server/test/xi2/protocol-xiquerydevice.c b/xorg-server/test/xi2/protocol-xiquerydevice.c
index 47eb5b14c..63d725f28 100644
--- a/xorg-server/test/xi2/protocol-xiquerydevice.c
+++ b/xorg-server/test/xi2/protocol-xiquerydevice.c
@@ -127,7 +127,7 @@ static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void
dev = devices.mouse;
assert(info->use == XISlavePointer);
assert(info->attachment == devices.vcp->id);
- assert(info->num_classes == 3); /* 2 axes + button */
+ assert(info->num_classes == 7); /* 4 axes + button + 2 scroll*/
break;
case 5: /* keyboard */
dev = devices.kbd;
@@ -183,11 +183,48 @@ static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void
}
break;
}
- case 2: /* VCP and mouse have the same properties */
case 4:
{
assert(any->type == XIButtonClass ||
- any->type == XIValuatorClass);
+ any->type == XIValuatorClass ||
+ any->type == XIScrollClass);
+
+ if (any->type == XIScrollClass)
+ {
+ xXIScrollInfo *si = (xXIScrollInfo*)any;
+
+ if (client->swapped)
+ {
+ swaps(&si->number);
+ swaps(&si->scroll_type);
+ swapl(&si->increment.integral);
+ swapl(&si->increment.frac);
+ }
+ assert(si->length == 6);
+ assert(si->number == 2 || si->number == 3);
+ if (si->number == 2) {
+ assert(si->scroll_type == XIScrollTypeVertical);
+ assert(!si->flags);
+ }
+ if (si->number == 3) {
+ assert(si->scroll_type == XIScrollTypeHorizontal);
+ assert(si->flags & XIScrollFlagPreferred);
+ assert(!(si->flags & ~XIScrollFlagPreferred));
+ }
+
+ assert(si->increment.integral == si->number);
+ /* FIXME: frac testing with float/FP issues? */
+ assert(si->increment.frac > 0.3 * (1UL << 32));
+ assert(si->increment.frac < 0.6 * (1UL << 32));
+ }
+
+ }
+ /* fall through */
+ case 2: /* VCP and mouse have the same properties except for scroll */
+ {
+ if (info->deviceid == 2 ) /* VCP */
+ assert(any->type == XIButtonClass ||
+ any->type == XIValuatorClass);
if (any->type == XIButtonClass)
{
@@ -217,8 +254,10 @@ static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void
}
assert(vi->length == 11);
- assert(vi->number == 0 ||
- vi->number == 1);
+ assert(vi->number >= 0 && vi->number < 4);
+ if (info->deviceid == 2) /* VCP */
+ assert(vi->number < 2);
+
assert(vi->mode == XIModeRelative);
/* device was set up as relative, so standard
* values here. */