feat: finally a halfway working prototype
This commit is contained in:
58
test/bds/desktop/main_window_test.exs
Normal file
58
test/bds/desktop/main_window_test.exs
Normal file
@@ -0,0 +1,58 @@
|
||||
defmodule BDS.Desktop.MainWindowTest do
|
||||
use ExUnit.Case, async: false
|
||||
|
||||
alias BDS.Desktop.MainWindow
|
||||
|
||||
setup do
|
||||
path = Path.join(System.tmp_dir!(), "bds-main-window-state-#{System.unique_integer([:positive])}.json")
|
||||
previous = Application.get_env(:bds, :desktop, [])
|
||||
updated =
|
||||
previous
|
||||
|> Keyword.put(:window_state_path, path)
|
||||
|> Keyword.put(:window_client_area_override, {0, 33, 1470, 851})
|
||||
|
||||
Application.put_env(:bds, :desktop, updated)
|
||||
|
||||
on_exit(fn ->
|
||||
Application.put_env(:bds, :desktop, previous)
|
||||
File.rm(path)
|
||||
end)
|
||||
|
||||
%{path: path}
|
||||
end
|
||||
|
||||
test "window options use a smaller safe default and restore persisted size and position", %{path: path} do
|
||||
opts = MainWindow.window_options()
|
||||
|
||||
assert opts[:size] == {1280, 780}
|
||||
assert opts[:min_size] == {800, 600}
|
||||
|
||||
:ok = MainWindow.persist_bounds(%{x: 120, y: 80, width: 1260, height: 820})
|
||||
|
||||
assert File.exists?(path)
|
||||
|
||||
restored = MainWindow.window_options()
|
||||
assert restored[:size] == {1260, 820}
|
||||
assert MainWindow.restore_bounds() == %{x: 120, y: 80, width: 1260, height: 820}
|
||||
end
|
||||
|
||||
test "window options clamp oversized startup bounds to the visible client area" do
|
||||
desktop = Application.get_env(:bds, :desktop, [])
|
||||
|
||||
Application.put_env(
|
||||
:bds,
|
||||
:desktop,
|
||||
desktop
|
||||
|> Keyword.put(:window_size, {1600, 950})
|
||||
|> Keyword.put(:window_client_area_override, {0, 33, 1200, 700})
|
||||
)
|
||||
|
||||
on_exit(fn ->
|
||||
Application.put_env(:bds, :desktop, desktop)
|
||||
end)
|
||||
|
||||
opts = MainWindow.window_options()
|
||||
|
||||
assert opts[:size] == {1200, 700}
|
||||
end
|
||||
end
|
||||
@@ -9,6 +9,7 @@ defmodule BDS.DesktopTest do
|
||||
|
||||
test "desktop child specs include the local shell server and desktop window in non-test environments" do
|
||||
children = BDS.Application.desktop_children(:dev)
|
||||
child_ids = Enum.map(children, &Supervisor.child_spec(&1, []).id)
|
||||
|
||||
assert Enum.any?(children, fn child ->
|
||||
match?({BDS.Desktop.Server, _opts}, child)
|
||||
@@ -18,6 +19,8 @@ defmodule BDS.DesktopTest do
|
||||
match?({Desktop.Window, opts} when is_list(opts), child) and
|
||||
Keyword.fetch!(elem(child, 1), :id) == BDS.Desktop.MainWindow
|
||||
end)
|
||||
|
||||
assert Enum.uniq(child_ids) == child_ids
|
||||
end
|
||||
|
||||
test "desktop children stay disabled in test so command-line tests do not spawn wx windows" do
|
||||
@@ -61,4 +64,4 @@ defmodule BDS.DesktopTest do
|
||||
assert conn.status == 200
|
||||
assert conn.resp_body =~ ~s(class="app")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -107,4 +107,21 @@ defmodule BDS.UI.ShellTest do
|
||||
assert File.exists?("/Users/gb/Projects/bDS2/priv/ui/app.css")
|
||||
assert File.exists?("/Users/gb/Projects/bDS2/priv/ui/app.js")
|
||||
end
|
||||
|
||||
test "static shell bundle keeps the old compact frame metrics and icon-based controls" do
|
||||
css = File.read!("/Users/gb/Projects/bDS2/priv/ui/app.css")
|
||||
js = File.read!("/Users/gb/Projects/bDS2/priv/ui/app.js")
|
||||
|
||||
assert css =~ ".window-titlebar"
|
||||
assert css =~ "height: 34px"
|
||||
assert css =~ "width: 48px"
|
||||
assert css =~ "height: 35px"
|
||||
assert css =~ "height: 22px"
|
||||
|
||||
assert js =~ "window-titlebar-sidebar-icon"
|
||||
assert js =~ "window-titlebar-panel-icon"
|
||||
assert js =~ "window-titlebar-assistant-icon"
|
||||
assert js =~ "activity-bar-top"
|
||||
assert js =~ "activity-bar-bottom"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user