- engine: Widget, Container (column, row, grid with spans per breakpoint, stack, panels, scrolling), Label, Button, TextBox, CheckBox, Radio, ComboBox, ListBox, Slider, ProgressBar, Image, Video (frames + sound), Spacer, Separator; Form (a scene: form file, events wired to methods, focus, Tab, default / cancel buttons, double click, key repeat, scrolling by dragging); game.yaml view: window (the view follows the window); Renderer::translate() - skeleton-gui (Lato, OFL) + bin/jumphp gui:new [--mobile], bin/jumphp video (film -> frames for the Video widget) - ide: gui.read / gui.dump / gui.code (event methods and @property lines written for the visual editor) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01X3cUrsDZg7JngzTEgWW6Nj
53 lines
1.7 KiB
PHP
53 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Tests;
|
|
|
|
use App\Form\MainForm;
|
|
use JumPHP\Gui\Pointer;
|
|
use JumPHP\Kernel\Engine;
|
|
use JumPHP\Testing\GameTestCase;
|
|
|
|
final class MainFormTest extends GameTestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
Engine::get()->storage->delete('contacts.json'); // each test starts with no contact
|
|
}
|
|
|
|
public function testAContactTypedThenAddedShowsInTheList(): void
|
|
{
|
|
$this->game->start(MainForm::class);
|
|
/** @var MainForm $form */
|
|
$form = $this->game->scene();
|
|
$form->click($form->widget('name'));
|
|
$form->type('Grace Hopper');
|
|
$form->click($form->widget('add'));
|
|
$this->game->run(2);
|
|
self::assertSame(['Grace Hopper'], $form->widget('list')->props['items']);
|
|
self::assertSame('', $form->widget('name')->props['text'], 'the field is cleared');
|
|
$this->game->shot('added');
|
|
}
|
|
|
|
public function testAnEmptyNameIsRefused(): void
|
|
{
|
|
$this->game->start(MainForm::class);
|
|
/** @var MainForm $form */
|
|
$form = $this->game->scene();
|
|
$form->key(Pointer::RETURN); // Return clicks the default button: Add
|
|
self::assertSame([], $form->widget('list')->props['items']);
|
|
self::assertSame('A name, please', $form->widget('status')->props['text']);
|
|
}
|
|
|
|
public function testAContactCanBeRemoved(): void
|
|
{
|
|
$this->game->start(MainForm::class, ['demo' => true]);
|
|
/** @var MainForm $form */
|
|
$form = $this->game->scene();
|
|
$this->game->run(2);
|
|
$form->click($form->widget('list'));
|
|
$form->widget('list')->select(0);
|
|
$form->click($form->widget('remove'));
|
|
self::assertSame([], $form->widget('list')->props['items']);
|
|
}
|
|
}
|