fix: shutdown moved to standard functionality
This commit is contained in:
@@ -44,6 +44,11 @@ defmodule BDS.Desktop.MainWindowTest do
|
||||
assert MainWindow.restore_bounds() == %{x: 120, y: 80, width: 1260, height: 820}
|
||||
end
|
||||
|
||||
test "window id and watcher process name do not collide" do
|
||||
assert MainWindow.window_id() == BDS.Desktop.MainWindow
|
||||
assert MainWindow.server_name() == BDS.Desktop.MainWindow.Watcher
|
||||
end
|
||||
|
||||
test "window options clamp oversized startup bounds to the visible client area" do
|
||||
desktop = Application.get_env(:bds, :desktop, [])
|
||||
|
||||
@@ -78,4 +83,22 @@ defmodule BDS.Desktop.MainWindowTest do
|
||||
"height" => 700
|
||||
}
|
||||
end
|
||||
|
||||
test "persist timer keeps last bounds when the wx frame is already gone", %{path: path} do
|
||||
bounds = %{x: 166, y: 57, width: 1280, height: 780}
|
||||
|
||||
assert {:noreply, state} =
|
||||
MainWindow.handle_info(:persist_bounds, %{
|
||||
frame: :invalid_wx_frame,
|
||||
last_bounds: bounds
|
||||
})
|
||||
|
||||
assert state.last_bounds == bounds
|
||||
|
||||
refute File.exists?(path)
|
||||
end
|
||||
|
||||
test "persist now is harmless when the window watcher is not running" do
|
||||
assert :ok = MainWindow.persist_now()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,6 +10,13 @@ defmodule BDS.DesktopTest do
|
||||
end
|
||||
end
|
||||
|
||||
defmodule FakeWindowQuit do
|
||||
def quit do
|
||||
send(Application.fetch_env!(:bds, :desktop_shutdown_test_pid), :window_quit_requested)
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
||||
test "desktop configuration no longer uses a pending adapter" do
|
||||
assert Application.get_env(:bds, BDS.Application)[:desktop_adapter] == :desktop
|
||||
end
|
||||
@@ -138,6 +145,29 @@ defmodule BDS.DesktopTest do
|
||||
assert_receive :quit_requested
|
||||
end
|
||||
|
||||
test "cmd-q remains handled by the desktop window quit handler" do
|
||||
refute function_exported?(BDS.Desktop.Shutdown, :command_menu_selected, 2)
|
||||
end
|
||||
|
||||
test "app-owned shutdown delegates final termination to the desktop hard quit path" do
|
||||
previous_module = Application.get_env(:bds, :desktop_shutdown_module)
|
||||
previous_quit_module = Application.get_env(:bds, :desktop_window_quit_module)
|
||||
previous_pid = Application.get_env(:bds, :desktop_shutdown_test_pid)
|
||||
|
||||
Application.put_env(:bds, :desktop_shutdown_module, BDS.Desktop.Shutdown)
|
||||
Application.put_env(:bds, :desktop_window_quit_module, FakeWindowQuit)
|
||||
Application.put_env(:bds, :desktop_shutdown_test_pid, self())
|
||||
|
||||
on_exit(fn ->
|
||||
restore_env(:desktop_shutdown_module, previous_module)
|
||||
restore_env(:desktop_window_quit_module, previous_quit_module)
|
||||
restore_env(:desktop_shutdown_test_pid, previous_pid)
|
||||
end)
|
||||
|
||||
assert :ok = BDS.Desktop.Shutdown.request_quit()
|
||||
assert_receive :window_quit_requested
|
||||
end
|
||||
|
||||
test "desktop root html is a LiveView shell and references only the live bootstrap assets" do
|
||||
conn = conn(:get, "/?k=#{Desktop.Auth.login_key()}")
|
||||
conn = BDS.Desktop.Endpoint.call(conn, BDS.Desktop.Endpoint.init([]))
|
||||
|
||||
Reference in New Issue
Block a user