options->set('gui_zoom', 1280 / $dp); $this->game->run(3); } private function demo(): MainForm { Engine::get()->storage->delete('servers.json'); $this->game->start(MainForm::class); /** @var MainForm $form */ $form = $this->game->scene(); $form->session->reset(); $this->game->start(MainForm::class, ['connectDemo' => true]); $this->game->run(30); return $form; } protected function tearDown(): void { Engine::get()->options->set('gui_zoom', 1.0); parent::tearDown(); } public function testOnAPhoneTheTreeThenTheTabsTakeTheWholeWidth(): void { $form = $this->demo(); $this->viewWidthDp($form, 390); self::assertTrue($form->isCompact()); self::assertTrue($form->left->visible, 'the tree first'); self::assertFalse($form->right->visible); self::assertEqualsWithDelta($form->viewWidth(), $form->left->w, 2, 'the tree is as wide as the screen'); self::assertLessThanOrEqual($form->viewWidth() + 1, $form->toolbar->x + $form->toolbar->w, 'the toolbar stays on the screen'); // tap the pool in the tree (the second row, under XenCenter): its tabs replace the tree $this->game->run(20); $index = 1; $pool = $form->tree->visibleIds()[$index]; self::assertStringStartsWith('OpaqueRef:', $pool); $row = $form->tree->rowHeight($form->theme); $form->clickAt($form->tree->x + $form->tree->w / 2, $form->tree->y + $form->theme->px(2) + $index * $row + $row / 2 - $form->tree->scrollY); $this->game->run(2); self::assertSame($pool, $form->tree->selected); self::assertFalse($form->left->visible); self::assertTrue($form->right->visible); self::assertTrue($form->paneBack->visible); self::assertEqualsWithDelta($form->viewWidth(), $form->right->w, 2, 'the tabs are as wide as the screen'); self::assertGreaterThan($form->theme->px(40), $form->tabs->h, 'a pool has more tabs than one line holds: they wrap'); self::assertGreaterThan($form->theme->px(28), $form->menu->h, 'the menus wrap too'); $this->game->shot('phone-details'); // "‹ Servers" goes back to the tree $form->click($form->paneBack); $this->game->run(2); self::assertTrue($form->left->visible); self::assertFalse($form->right->visible); $this->game->shot('phone-tree'); } public function testAWideWindowKeepsTheTreeBesideTheTabs(): void { $form = $this->demo(); $this->viewWidthDp($form, 390); $form->pane = 'details'; $this->viewWidthDp($form, 1280); self::assertFalse($form->isCompact()); self::assertTrue($form->left->visible); self::assertTrue($form->right->visible); self::assertTrue($form->split->visible); self::assertFalse($form->paneBack->visible); self::assertEqualsWithDelta($form->theme->px(300), $form->left->w, 2); self::assertSame($form->theme->px(28), $form->menu->h, 'one line of menus'); } }