aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/test
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-10-27 08:37:52 +0200
committermarha <marha@users.sourceforge.net>2011-10-27 08:37:52 +0200
commit2a9be4af293f20fa33cc34fbc3b72e2235d91090 (patch)
treed41608bda1d56be1aa96857dee20e988b53760a3 /xorg-server/test
parent9d53da0fbb9ae6df9a38ad40df4f53cd28287235 (diff)
parentd662d461634660f5c0f3998b5eb7d7ed3bd5a25f (diff)
downloadvcxsrv-2a9be4af293f20fa33cc34fbc3b72e2235d91090.tar.gz
vcxsrv-2a9be4af293f20fa33cc34fbc3b72e2235d91090.tar.bz2
vcxsrv-2a9be4af293f20fa33cc34fbc3b72e2235d91090.zip
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'xorg-server/test')
-rw-r--r--xorg-server/test/input.c99
-rw-r--r--xorg-server/test/xi2/protocol-eventconvert.c27
2 files changed, 115 insertions, 11 deletions
diff --git a/xorg-server/test/input.c b/xorg-server/test/input.c
index bc41c226d..5b4c8c193 100644
--- a/xorg-server/test/input.c
+++ b/xorg-server/test/input.c
@@ -40,6 +40,7 @@
#include "dixgrabs.h"
#include "eventstr.h"
#include "inpututils.h"
+#include "mi.h"
#include "assert.h"
/**
@@ -1199,14 +1200,19 @@ static void dix_input_valuator_masks(void)
assert(valuator_mask_num_valuators(mask) == num_vals);
for (i = 0; i < nvaluators; i++)
{
+ double val;
if (i < first_val || i >= first_val + num_vals)
+ {
assert(!valuator_mask_isset(mask, i));
- else
+ assert(!valuator_mask_fetch_double(mask, i, &val));
+ } else
{
assert(valuator_mask_isset(mask, i));
assert(valuator_mask_get(mask, i) == val_ranged[i - first_val]);
assert(valuator_mask_get_double(mask, i) ==
val_ranged[i - first_val]);
+ assert(valuator_mask_fetch_double(mask, i, &val));
+ assert(val_ranged[i - first_val] == val);
}
}
@@ -1218,10 +1224,18 @@ static void dix_input_valuator_masks(void)
for (i = 0; i < nvaluators; i++)
{
+ double a, b;
assert(valuator_mask_isset(mask, i) == valuator_mask_isset(copy, i));
+
+ if (!valuator_mask_isset(mask, i))
+ continue;
+
assert(valuator_mask_get(mask, i) == valuator_mask_get(copy, i));
assert(valuator_mask_get_double(mask, i) ==
valuator_mask_get_double(copy, i));
+ assert(valuator_mask_fetch_double(mask, i, &a));
+ assert(valuator_mask_fetch_double(copy, i, &b));
+ assert(a == b);
}
valuator_mask_free(&mask);
@@ -1467,8 +1481,6 @@ _test_double_fp16_values(double orig_d)
{
FP1616 first_fp16, final_fp16;
double final_d;
- char first_fp16_s[64];
- char final_fp16_s[64];
if (orig_d > 0x7FFF) {
printf("Test out of range\n");
@@ -1479,10 +1491,15 @@ _test_double_fp16_values(double orig_d)
final_d = fp1616_to_double(first_fp16);
final_fp16 = double_to_fp1616(final_d);
- snprintf(first_fp16_s, sizeof(first_fp16_s), "%d + %u * 2^-16", (first_fp16 & 0xffff0000) >> 16, first_fp16 & 0xffff);
- snprintf(final_fp16_s, sizeof(final_fp16_s), "%d + %u * 2^-16", (final_fp16 & 0xffff0000) >> 16, final_fp16 & 0xffff);
-
- printf("FP16: original double: %f first fp16: %s, re-encoded double: %f, final fp16: %s\n", orig_d, first_fp16_s, final_d, final_fp16_s);
+ /* {
+ * char first_fp16_s[64];
+ * char final_fp16_s[64];
+ * snprintf(first_fp16_s, sizeof(first_fp16_s), "%d + %u * 2^-16", (first_fp16 & 0xffff0000) >> 16, first_fp16 & 0xffff);
+ * snprintf(final_fp16_s, sizeof(final_fp16_s), "%d + %u * 2^-16", (final_fp16 & 0xffff0000) >> 16, final_fp16 & 0xffff);
+ *
+ * printf("FP16: original double: %f first fp16: %s, re-encoded double: %f, final fp16: %s\n", orig_d, first_fp16_s, final_d, final_fp16_s);
+ * }
+ */
/* since we lose precision, we only do rough range testing */
assert(final_d > orig_d - 0.1);
@@ -1590,6 +1607,73 @@ dix_double_fp_conversion(void)
}
}
+/* The mieq test verifies that events added to the queue come out in the same
+ * order that they went in.
+ */
+static uint32_t mieq_test_event_last_processed;
+
+static void
+mieq_test_event_handler(int screenNum, InternalEvent *ie, DeviceIntPtr dev) {
+ RawDeviceEvent *e = (RawDeviceEvent *)ie;
+
+ assert(e->type == ET_RawMotion);
+ assert(e->flags > mieq_test_event_last_processed);
+ mieq_test_event_last_processed = e->flags;
+}
+
+static void _mieq_test_generate_events(uint32_t start, uint32_t count) {
+ count += start;
+ while (start < count) {
+ RawDeviceEvent e = {0};
+ e.header = ET_Internal;
+ e.type = ET_RawMotion;
+ e.length = sizeof(e);
+ e.time = GetTimeInMillis();
+ e.flags = start;
+
+ mieqEnqueue(NULL, (InternalEvent*)&e);
+
+ start++;
+ }
+}
+
+#define mieq_test_generate_events(c) { _mieq_test_generate_events(next, c); next += c; }
+
+static void
+mieq_test(void) {
+ uint32_t next = 1;
+
+ mieq_test_event_last_processed = 0;
+ mieqInit();
+ mieqSetHandler(ET_RawMotion, mieq_test_event_handler);
+
+ /* Enough to fit the buffer but trigger a grow */
+ mieq_test_generate_events(180);
+
+ /* We should resize to 512 now */
+ mieqProcessInputEvents();
+
+ /* Some should now get dropped */
+ mieq_test_generate_events(500);
+
+ /* Tell us how many got dropped, 1024 now */
+ mieqProcessInputEvents();
+
+ /* Now make it 2048 */
+ mieq_test_generate_events(900);
+ mieqProcessInputEvents();
+
+ /* Now make it 4096 (max) */
+ mieq_test_generate_events(1950);
+ mieqProcessInputEvents();
+
+ /* Now overflow one last time with the maximal queue and reach the verbosity limit */
+ mieq_test_generate_events(10000);
+ mieqProcessInputEvents();
+
+ mieqFini();
+}
+
int main(int argc, char** argv)
{
dix_double_fp_conversion();
@@ -1608,6 +1692,7 @@ int main(int argc, char** argv)
dix_valuator_alloc();
dix_get_master();
input_option_test();
+ mieq_test();
return 0;
}
diff --git a/xorg-server/test/xi2/protocol-eventconvert.c b/xorg-server/test/xi2/protocol-eventconvert.c
index bfa23b51f..ba2d96ad1 100644
--- a/xorg-server/test/xi2/protocol-eventconvert.c
+++ b/xorg-server/test/xi2/protocol-eventconvert.c
@@ -30,6 +30,7 @@
#include "eventstr.h"
#include "eventconvert.h"
#include "exevents.h"
+#include "inpututils.h"
#include <X11/extensions/XI2proto.h>
static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out,
@@ -104,8 +105,7 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out,
value = (FP3232*)(((unsigned char*)&out[1]) + out->valuators_len * 4);
value += nvals;
- vi.integral = trunc(in->valuators.data[i]);
- vi.frac = in->valuators.data[i] - vi.integral;
+ vi = double_to_fp3232(in->valuators.data[i]);
vo.integral = value->integral;
vo.frac = value->frac;
@@ -120,8 +120,7 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out,
raw_value = value + bits_set;
- vi.integral = trunc(in->valuators.data_raw[i]);
- vi.frac = in->valuators.data_raw[i] - vi.integral;
+ vi = double_to_fp3232(in->valuators.data_raw[i]);
vo.integral = raw_value->integral;
vo.frac = raw_value->frac;
@@ -748,6 +747,26 @@ static void test_values_XIDeviceChangedEvent(DeviceChangedEvent *in,
}
break;
+ case XIScrollClass:
+ {
+ xXIScrollInfo *s = (xXIScrollInfo*)any;
+ assert(s->length ==
+ bytes_to_int32(sizeof(xXIScrollInfo)));
+
+ assert(s->sourceid == in->sourceid);
+ assert(s->number < in->num_valuators);
+ switch(s->type)
+ {
+ case XIScrollTypeVertical:
+ assert(in->valuators[s->number].scroll.type == SCROLL_TYPE_VERTICAL);
+ break;
+ case XIScrollTypeHorizontal:
+ assert(in->valuators[s->number].scroll.type == SCROLL_TYPE_HORIZONTAL);
+ break;
+ }
+ if (s->flags & XIScrollFlagPreferred)
+ assert(in->valuators[s->number].scroll.flags & SCROLL_FLAG_PREFERRED);
+ }
default:
printf("Invalid class type.\n\n");
assert(1);