fix: acknowledge each legacy tip once per cleanup intent

This commit is contained in:
阿白叔 committed 2026-11-17 11:33:49 +08:00
1 parent 701e5cd3b4
commit 8818fa9841
3 files changed
+48 -16

No files matched your search

+19 -3
View File
@@ -263,7 +263,8 @@ def test_real_legacy_adapter_keeps_hidden_documents_before_any_native_action(tmp
@pytest.mark.parametrize('closed',[False,True])
def test_legacy_tip_continues_to_loaded_cleanup_only_without_prior_close(tmp_path,monkeypatch,closed):
@pytest.mark.parametrize('delayed_tip',[False,True])
def test_legacy_tip_continues_to_loaded_cleanup_only_without_prior_close(tmp_path,monkeypatch,closed,delayed_tip):
import win32con,win32gui
from copy import deepcopy
job,row,records,messages,state=registered_fixture(tmp_path,monkeypatch,closed=closed)
@@ -272,13 +273,28 @@ def test_legacy_tip_continues_to_loaded_cleanup_only_without_prior_close(tmp_pat
desktop=job['desktop'],children=[],documents=[]),
dict(hwnd=200,**{'class':'#32770'},title='Tip of the Day',enabled=True,
desktop=job['desktop'],documents=[],children=[dict(hwnd=201,**{'class':'Button'},id=1,text='OK',enabled=True)])]
monkeypatch.setattr(sessions,'_process_windows',lambda pids:{12:deepcopy(tip_windows) if state['tip'] else []})
def windows(pids):
state['ticks']+=.02
if delayed_tip and state.get('tip_posted') and state['ticks']>=.3:
state['tip']=False
if closed:records.clear()
return {12:deepcopy(tip_windows) if state['tip'] else []}
monkeypatch.setattr(sessions,'_process_windows',windows)
monkeypatch.setattr(win32gui,'GetWindow',lambda h,k:100 if h==200 and k==win32con.GW_OWNER else 0)
original=win32gui.PostMessage
def post(hwnd,message,*args):
original(hwnd,message,*args)
if closed and hwnd==201:records.clear()
if hwnd==201:
if delayed_tip:state.update(tip=True,tip_posted=True)
elif closed:records.clear()
monkeypatch.setattr(win32gui,'PostMessage',post)
if delayed_tip and closed:
original_wait=__import__('win32event').WaitForSingleObject
def wait(handle,ms):
value=original_wait(handle,ms)
if state.get('tip_posted') and state['ticks']>=.3:records.clear()
return value
monkeypatch.setattr(__import__('win32event'),'WaitForSingleObject',wait)
assert sessions._request_close(row)['release_status']=='RELEASED'
assert messages==([(201,245)] if closed else [(201,245),(31,245),(100,16)])
assert not records and state['ticks']<30