summaryrefslogtreecommitdiff
path: root/tests/common/test_tablet_example.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common/test_tablet_example.c')
-rw-r--r--tests/common/test_tablet_example.c65
1 files changed, 0 insertions, 65 deletions
diff --git a/tests/common/test_tablet_example.c b/tests/common/test_tablet_example.c
deleted file mode 100644
index e291b2a..0000000
--- a/tests/common/test_tablet_example.c
+++ /dev/null
@@ -1,65 +0,0 @@
-#define main tablet_example_main
-#include "../../examples/tablet.c"
-#undef main
-#include <assert.h>
-
-static void pointer(struct app *app, enum yasl_event_type type,
- enum yasl_pointer_device device, enum yasl_pointer_button button, int x, int y, uint16_t pressure)
-{
- struct yasl_event event = {
- .type = type,
- .pointer = {
- .pos = (struct yasl_vector2i){x, y},
- .device = device,
- .button = button,
- .pen = { .pressure = pressure },
- },
- };
- input(app, &event);
-}
-
-int main(void)
-{
- struct app app = {0};
- assert(resize_canvas(&app, (struct yasl_geometry){{400, 300}, 120}));
- pointer(&app, YASL_EVENT_POINTER_MOTION, YASL_PTR_DEV_PEN, YASL_BUTTON_BACK, 80, 160, 65535);
- /* Hover never paints. */
- assert(app.canvas[(size_t)160 * app.geometry.size.x + 80] == PAPER);
- pointer(&app, YASL_EVENT_POINTER_DOWN, YASL_PTR_DEV_PEN, YASL_BUTTON_SECONDARY, 80, 160, 65535);
- /* Side button isn't the tip. */
- assert(!app.down &&
- app.canvas[(size_t)160 * app.geometry.size.x + 80] == PAPER);
- pointer(&app, YASL_EVENT_POINTER_DOWN, YASL_PTR_DEV_PEN, YASL_BUTTON_PRIMARY, 80, 160, 0);
- assert(app.down &&
- app.canvas[(size_t)160 * app.geometry.size.x + 80] == INK &&
- app.canvas[(size_t)160 * app.geometry.size.x + 90] == PAPER);
- pointer(&app, YASL_EVENT_POINTER_MOTION, YASL_PTR_DEV_PEN, YASL_BUTTON_PRIMARY, 80, 160, 65535);
- /* Stationary pressure widens brush. */
- assert(app.canvas[(size_t)160 * app.geometry.size.x + 100] == INK);
- pointer(&app, YASL_EVENT_POINTER_MOTION, YASL_PTR_DEV_PEN, YASL_BUTTON_PRIMARY, 180, 160, 20000);
- /* Segments are continuous. */
- assert(app.canvas[(size_t)160 * app.geometry.size.x + 130] == INK);
- pointer(&app, YASL_EVENT_POINTER_UP, YASL_PTR_DEV_PEN, YASL_BUTTON_PRIMARY, 180, 160, 0);
- pointer(&app, YASL_EVENT_POINTER_MOTION, YASL_PTR_DEV_PEN, YASL_BUTTON_BACK, 250, 160, 65535);
- assert(!app.down && app.canvas[(size_t)160 * app.geometry.size.x + 250] == PAPER);
- pointer(&app, YASL_EVENT_POINTER_DOWN, YASL_PTR_DEV_ERASER, YASL_BUTTON_PRIMARY, 80, 160, 65535);
- assert(app.canvas[(size_t)160 * app.geometry.size.x + 80] == PAPER &&
- app.canvas[(size_t)160 * app.geometry.size.x + 130] == INK);
- struct yasl_event reset = {.type = YASL_EVENT_INPUT_RESET};
- input(&app, &reset);
- pointer(&app, YASL_EVENT_POINTER_MOTION, YASL_PTR_DEV_ERASER, YASL_BUTTON_PRIMARY, 130, 160, 65535);
- assert(!app.down && app.canvas[(size_t)160 * app.geometry.size.x + 130] == INK);
- pointer(&app, YASL_EVENT_POINTER_DOWN, YASL_PTR_DEV_MOUSE, YASL_BUTTON_PRIMARY, 300, 200, 0);
- assert(app.canvas[(size_t)200 * app.geometry.size.x + 300] == INK);
- struct yasl_event blur = {.type = YASL_EVENT_FOCUS, .focus.focused = false};
- input(&app, &blur);
- assert(!app.down);
- assert(resize_canvas(&app, (struct yasl_geometry){{800, 600}, 240}));
- /* DPI preserves logical drawing. */
- assert(app.canvas[(size_t)400 * app.geometry.size.x + 600] == INK &&
- !app.previous);
- clear_canvas(&app);
- assert(app.canvas[(size_t)400 * app.geometry.size.x + 600] == PAPER);
- free(app.canvas);
- return 0;
-}