- ui: hybrid: an SDL game that also drives Tauri (Application::run() hands over to JumPHP\Tauri\Hybrid): native
dialogs, tray icon, shortcuts and HTML windows beside its own; a plain game headless, in the browser, on phones and
without FFI. bin/jumphp run uses the Tauri image; export:standalone a micro with SDL + FFI (tools/hybrid-extensions.txt).
games/hello-hybrid: SDL balls + an HTML control panel.
- JumPHP\Native\Clipboard (Tauri, browser copy), App::tray() (JumPHP\Tauri\Tray), App::globalShortcut();
native.copy / native.paste for pages; a command PHP waits for that fails now fails its Task ('result' event)
- runtime: clipboard-manager, global-shortcut, tray-icon; panics of a command stay on the native side; idle time
after each frame so WebViews keep painting beside a busy game; JUMPHP_TAURI_TRACE=1
- .github/workflows/tauri.yml: the library for Linux, Windows, macOS (universal), hello-desktop run for real on
each, release tauri-<key> (tools/tauri-key.sh); bin/jumphp tauri:download, used before building
- app:export --windows; the standalone workflow takes an extension list (the apps' / hybrid games' micros)
- docs/tauri.md, docs/tauri.fr.md, AGENTS.md §16, README, TODO
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JkYTqpYNZKwTnRZHQRD5HP
52 lines
2 KiB
PHP
52 lines
2 KiB
PHP
<?php
|
|
|
|
namespace Tests;
|
|
|
|
use App\Settings;
|
|
use JumPHP\Testing\AppTestCase;
|
|
|
|
/** The native side (App\Desktop) without a window: the HTML panel's commands, the tray menu. */
|
|
final class DesktopTest extends AppTestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
Settings::reset();
|
|
parent::setUp();
|
|
}
|
|
|
|
public function testThePanelOpensBesideTheGame(): void
|
|
{
|
|
$window = $this->runtime->sentOf('window.create')[0];
|
|
self::assertSame('index.html', $window['url']);
|
|
self::assertSame(340, $window['width']);
|
|
}
|
|
|
|
public function testThePanelChangesTheGame(): void
|
|
{
|
|
$answer = $this->invoke('set', ['balls' => 40, 'speed' => 2.5, 'colour' => '#33CCFF']);
|
|
self::assertSame(['balls' => 40, 'speed' => 2.5, 'colour' => '#33ccff', 'paused' => false], $answer);
|
|
self::assertSame(1, $this->invoke('set', ['balls' => -5])['balls']);
|
|
self::assertSame('#33ccff', $this->invoke('set', ['colour' => 'red'])['colour']);
|
|
}
|
|
|
|
public function testTheTrayMenuPausesAndAsksForAPicture(): void
|
|
{
|
|
$tray = $this->lastSent('tray.create');
|
|
self::assertSame(['pause', 'shot', null, 'quit'], array_map(static fn (array $i) => $i['id'] ?? null, $tray['menu']));
|
|
$this->runtime->push(['type' => 'tray', 'tray' => 'main', 'event' => 'menu', 'item' => 'pause']);
|
|
$this->frames(1);
|
|
self::assertTrue(Settings::$paused);
|
|
$this->runtime->push(['type' => 'tray', 'tray' => 'main', 'event' => 'menu', 'item' => 'shot']);
|
|
$this->frames(1);
|
|
self::assertTrue(Settings::$shotRequested);
|
|
}
|
|
|
|
public function testTheGlobalShortcutTogglesThePause(): void
|
|
{
|
|
self::assertSame('CmdOrCtrl+Shift+P', $this->lastSent('shortcut.register')['accelerator']);
|
|
$this->runtime->push(['type' => 'shortcut', 'accelerator' => 'CmdOrCtrl+Shift+P', 'state' => 'pressed']);
|
|
$this->frames(1);
|
|
self::assertTrue(Settings::$paused);
|
|
self::assertSame('settings', $this->lastSent('webview.emit')['name']);
|
|
}
|
|
}
|