Modules/GraphicApplication/tests/PlatformInfoTests.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

47 lines
1.3 KiB
C++

#include "UnitTest++/UnitTest++.h"
#include "PlatformInfo.hpp"
using namespace tp;
SUITE(PlatformInfo) {
TEST(DefaultsDescribeAnUnknownPlatform) {
const PlatformInfo info;
CHECK(info.system == OperatingSystem::Unknown);
CHECK(info.formFactor == FormFactor::Unknown);
CHECK(!info.isTouchFirst());
}
TEST(TabletsAndPhonesAreTouchFirst) {
PlatformInfo info;
info.formFactor = FormFactor::Tablet;
CHECK(info.isTouchFirst());
info.formFactor = FormFactor::Phone;
CHECK(info.isTouchFirst());
info.formFactor = FormFactor::Desktop;
CHECK(!info.isTouchFirst());
}
TEST(DescriptionNamesSystemFormFactorAndCapabilities) {
PlatformInfo info;
info.system = OperatingSystem::Android;
info.systemVersion = "16";
info.formFactor = FormFactor::Tablet;
info.deviceName = "Google Pixel Tablet";
info.contentScale = 2;
info.screenSize = { 1280, 800 };
info.hasTouch = true;
info.hasPen = true;
const std::string text = describe(info);
CHECK(text.find("Android 16") != std::string::npos);
CHECK(text.find("tablet Google Pixel Tablet") != std::string::npos);
CHECK(text.find("scale 2.00") != std::string::npos);
CHECK(text.find("screen 1280x800") != std::string::npos);
CHECK(text.find("touch pen") != std::string::npos);
CHECK(text.find("mouse") == std::string::npos);
}
}