summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2012-03-22 00:15:34 +0200
committerAlon Levy <alevy@redhat.com>2012-03-22 11:18:37 +0200
commita7d3f1de82e90da869775e8306e0dba7d95bd597 (patch)
tree54b4672a60c82c6cabc9991b315b8fe38c110fa3
parenta6f9797c79db969f0fe28ef30691d4c1b1002eac (diff)
server/tests: add resolution changes tester
-rw-r--r--server/tests/Makefile.am20
-rw-r--r--server/tests/test_display_resolution_changes.c66
2 files changed, 80 insertions, 6 deletions
diff --git a/server/tests/Makefile.am b/server/tests/Makefile.am
index 61fad758..52e55a88 100644
--- a/server/tests/Makefile.am
+++ b/server/tests/Makefile.am
@@ -24,13 +24,14 @@ COMMON_BASE = \
test_util.h \
$(NULL)
-noinst_PROGRAMS = \
- test_display_no_ssl \
- test_display_streaming \
- test_empty_success \
+noinst_PROGRAMS = \
+ test_display_no_ssl \
+ test_display_streaming \
+ test_empty_success \
test_fail_on_null_core_interface \
- test_just_sockets_no_ssl \
- test_playback \
+ test_just_sockets_no_ssl \
+ test_playback \
+ test_display_resolution_changes \
$(NULL)
test_display_streaming_SOURCES = \
@@ -47,6 +48,13 @@ test_display_no_ssl_SOURCES = \
test_display_no_ssl.c \
$(NULL)
+test_display_resolution_changes_SOURCES = \
+ $(COMMON_BASE) \
+ test_display_base.c \
+ test_display_base.h \
+ test_display_resolution_changes.c \
+ $(NULL)
+
test_just_sockets_no_ssl_SOURCES = \
$(COMMON_BASE) \
test_just_sockets_no_ssl.c \
diff --git a/server/tests/test_display_resolution_changes.c b/server/tests/test_display_resolution_changes.c
new file mode 100644
index 00000000..edf7fb2d
--- /dev/null
+++ b/server/tests/test_display_resolution_changes.c
@@ -0,0 +1,66 @@
+/**
+ * Recreate the primary surface endlessly.
+ */
+
+#include <math.h>
+#include <config.h>
+#include <stdlib.h>
+#include "test_display_base.h"
+
+SpiceServer *server;
+SpiceCoreInterface *core;
+SpiceTimer *ping_timer;
+
+void show_channels(SpiceServer *server);
+
+int ping_ms = 100;
+
+void pinger(void *opaque)
+{
+ // show_channels is not thread safe - fails if disconnections / connections occur
+ //show_channels(server);
+
+ core->timer_start(ping_timer, ping_ms);
+}
+
+void set_primary_params(void *cb_opaque, uint64_t *arg1, uint64_t *arg2)
+{
+#if 0
+ static int toggle = 0;
+
+ if (toggle) {
+ *arg1 = 800;
+ *arg2 = 600;
+ } else {
+ *arg1 = 1024;
+ *arg2 = 768;
+ }
+ toggle = 1 - toggle;
+#endif
+ static int count = 0;
+
+ *arg1 = 800 + sin((float)count / 6) * 200;
+ *arg2 = 600 + cos((float)count / 6) * 200;
+ count++;
+}
+
+static Command commands[] = {
+ {DESTROY_PRIMARY, 0, 0, NULL, NULL},
+ {CREATE_PRIMARY, 0, 0, set_primary_params, NULL},
+};
+
+int main(void)
+{
+ core = basic_event_loop_init();
+ server = test_init(core);
+ //spice_server_set_image_compression(server, SPICE_IMAGE_COMPRESS_OFF);
+ test_add_display_interface(server);
+ test_set_command_list(commands, COUNT(commands));
+
+ ping_timer = core->timer_add(pinger, NULL);
+ core->timer_start(ping_timer, ping_ms);
+
+ basic_event_loop_mainloop();
+
+ return 0;
+}