@@ -59,49 +59,86 @@ def test_window_present_idle_skips_window_during_shutdown() -> None:
5959
6060def test_window_present_idle_presents_active_window () -> None :
6161 window = FakeWindow (ui_shutting_down = False )
62- application = SimpleNamespace (window = window , window_present_source_id = 123 )
62+ calls : list [str ] = []
63+ application = SimpleNamespace (
64+ window = window ,
65+ window_present_source_id = 123 ,
66+ finish_startup_notification = lambda : calls .append ("startup-complete" ),
67+ )
6368
6469 assert app .MiniEqApplication .on_window_present_idle (application ) is False
6570 assert application .window_present_source_id == 0
6671 assert window .present_count == 1
72+ assert calls == ["startup-complete" ]
6773
6874
69- def test_ensure_window_defers_existing_window_present_until_setup (monkeypatch ) -> None :
75+ def test_ensure_window_defers_existing_window_present_until_startup_ready (monkeypatch ) -> None :
7076 monkeypatch .setattr (app , "install_app_icon" , lambda : None )
7177 calls : list [object ] = []
7278 window = SimpleNamespace (
7379 ui_shutting_down = False ,
74- post_present_ready = False ,
75- present_after_setup = False ,
80+ startup_ready = False ,
81+ present_when_ready = False ,
7682 set_visible = lambda visible : calls .append (("visible" , visible )),
7783 present = lambda : calls .append ("present" ),
78- schedule_post_present_setup = lambda : calls .append ("setup" ),
84+ schedule_startup_ready = lambda : calls .append ("ready-scheduled" ),
85+ )
86+ application = SimpleNamespace (
87+ window = window ,
88+ emit_control_state_changed = lambda : calls .append ("state" ),
89+ finish_startup_notification = lambda : calls .append ("startup-complete" ),
7990 )
80- application = SimpleNamespace (window = window , emit_control_state_changed = lambda : calls .append ("state" ))
8191
8292 app .MiniEqApplication .ensure_window (application , present = True )
8393
84- assert window .present_after_setup is True
85- assert calls == ["setup " ]
94+ assert window .present_when_ready is True
95+ assert calls == ["ready-scheduled " ]
8696
8797
8898def test_ensure_window_presents_existing_ready_window_immediately (monkeypatch ) -> None :
8999 monkeypatch .setattr (app , "install_app_icon" , lambda : None )
90100 calls : list [object ] = []
91101 window = SimpleNamespace (
92102 ui_shutting_down = False ,
93- post_present_ready = True ,
94- present_after_setup = False ,
103+ startup_ready = True ,
104+ present_when_ready = False ,
95105 set_visible = lambda visible : calls .append (("visible" , visible )),
96106 present = lambda : calls .append ("present" ),
97- schedule_post_present_setup = lambda : calls .append ("setup" ),
107+ schedule_startup_ready = lambda : calls .append ("ready-scheduled" ),
108+ )
109+ application = SimpleNamespace (
110+ window = window ,
111+ emit_control_state_changed = lambda : calls .append ("state" ),
112+ finish_startup_notification = lambda : calls .append ("startup-complete" ),
98113 )
99- application = SimpleNamespace (window = window , emit_control_state_changed = lambda : calls .append ("state" ))
100114
101115 app .MiniEqApplication .ensure_window (application , present = True )
102116
103- assert window .present_after_setup is True
104- assert calls == [("visible" , True ), "present" , "state" , "setup" ]
117+ assert window .present_when_ready is True
118+ assert calls == [("visible" , True ), "present" , "startup-complete" , "state" , "ready-scheduled" ]
119+
120+
121+ def test_finish_startup_notification_completes_current_gdk_startup_id (monkeypatch ) -> None :
122+ calls : list [object ] = []
123+ display = SimpleNamespace (
124+ get_startup_notification_id = lambda : "mini-eq-startup" ,
125+ notify_startup_complete = lambda startup_id : calls .append (("complete" , startup_id )),
126+ )
127+ monkeypatch .setattr (app .Gdk .Display , "get_default" , lambda : display )
128+
129+ app .MiniEqApplication .finish_startup_notification (SimpleNamespace ())
130+
131+ assert calls == [("complete" , "mini-eq-startup" )]
132+
133+
134+ def test_finish_startup_notification_ignores_missing_gdk_startup_id (monkeypatch ) -> None :
135+ display = SimpleNamespace (
136+ get_startup_notification_id = lambda : None ,
137+ notify_startup_complete = lambda _startup_id : (_ for _ in ()).throw (AssertionError ("unexpected" )),
138+ )
139+ monkeypatch .setattr (app .Gdk .Display , "get_default" , lambda : display )
140+
141+ app .MiniEqApplication .finish_startup_notification (SimpleNamespace ())
105142
106143
107144def test_close_action_closes_active_window () -> None :
0 commit comments