Modules/GraphicApplication/tests/LinuxInputCodesTests.cpp
agent 711793ffd7 GraphicApplication: GPU device, window surfaces, window and platform backends
gpu/ replaces the OpenGL path and is split by lifetime:
- GpuDevice is the instance, device, graphics queue, command pool, one-shot
  uploads and render-target registry, shared by every window.
- WindowSurface is one window's surface, swapchain, render pass,
  depth-stencil and frames in flight. beginFrame() returns a GpuFrame
  (command buffer, frame slot, extent), the narrow view renderers record
  into. Render-finished semaphores are per swapchain image, Vulkan results
  are checked and failures throw GpuError.

backends/contract/ is the only thing a backend and the window share.
PlatformWindow is what a backend implements; it knows no coalescer or GPU
object. PlatformWindowHost is all a backend may call back: rawInput(),
onContentResized(), onSurfaceAvailable() and onSurfaceLost(), so the window
drives the GPU surface. Desktop-only manipulation is the optional
DesktopWindowControls interface. A backend also defines its surface
extensions, its resource directory and createPlatformWindow(), which
receives a typed PlatformContext.

- backends/wayland/ keeps xdg configure handling to itself and acknowledges
  it when the frame loop applies it. The seat is split per device
  (keyboard, pointer, tablet, text input, clipboard); clipboard contents are
  read asynchronously on the event loop. evdev key codes and the touchpad
  pinch converter live here. Resources resolve next to the executable.
- backends/android/ runs on native_app_glue and finishes the activity when
  the application returns or fails.

window/ owns the platform window, its WindowSurface, the coalescer and the
input queue, and exposes roles: WindowEventLoop, WindowInput (state,
injection, raw tap, delivery policies, the one place input is muted),
WindowControls (with desktop() for the optional controls) and
WindowServices. Window's public header names no backend.
2026-10-29 05:24:06 +03:00

39 lines
1.2 KiB
C++

#include "UnitTest++/UnitTest++.h"
#include "LinuxInputCodes.hpp"
#include <linux/input-event-codes.h>
using namespace tp;
SUITE(LinuxInputCodes) {
TEST(LettersAndDigitsKeepTheirKeys) {
CHECK(keyFromEvdev(KEY_A) == Key::A);
CHECK(keyFromEvdev(KEY_Z) == Key::Z);
CHECK(keyFromEvdev(KEY_0) == Key::Digit0);
CHECK(keyFromEvdev(KEY_9) == Key::Digit9);
}
TEST(NavigationAndEditingKeysAreMapped) {
CHECK(keyFromEvdev(KEY_ESC) == Key::Escape);
CHECK(keyFromEvdev(KEY_ENTER) == Key::Enter);
CHECK(keyFromEvdev(KEY_BACKSPACE) == Key::Backspace);
CHECK(keyFromEvdev(KEY_LEFT) == Key::Left);
CHECK(keyFromEvdev(KEY_PAGEDOWN) == Key::PageDown);
}
TEST(ModifiersKeepSides) {
CHECK(keyFromEvdev(KEY_LEFTCTRL) == Key::LeftControl);
CHECK(keyFromEvdev(KEY_RIGHTSHIFT) == Key::RightShift);
CHECK(keyFromEvdev(KEY_LEFTALT) == Key::LeftAlt);
}
TEST(UnknownKeysAreIgnored) { CHECK(!keyFromEvdev(KEY_MAX).has_value()); }
TEST(LinuxButtonsMapToPointerButtons) {
CHECK(pointerButtonFromLinux(BTN_LEFT) == PointerButton::Left);
CHECK(pointerButtonFromLinux(BTN_RIGHT) == PointerButton::Right);
CHECK(pointerButtonFromLinux(BTN_MIDDLE) == PointerButton::Middle);
CHECK(!pointerButtonFromLinux(BTN_TOUCH).has_value());
}
}