事件点击改文字中心 + 卡包刷新按 OCR + 运行数据归档
- 事件: 点击点从「选项标记」改成选项文字自己的中心(_option_click_pos)。11-18 实测同一个 选项被点 10 次还在, 标记常落在行首装饰上 - 事件兜底: LCP_EVENT_FALLBACK=1 时表里没有的事件点第 1 项, 不再被上游「无法解决事件→回主界面」 - 卡包刷新: 改成 OCR 找右上角「刷新」点文字中心(找不到退回模板), 记 decisions theme_pack/refresh_click - 驱动点击: 点击点必须落在游戏客户区内(否则拒绝), 修「老是打开回收站」(blank 点击点到桌面左上角) - docs/feedback/runs/2026-11-15_2026-11-21: 20 轮过滤后的日志(1.6MB, 原始 110MB) + decisions.jsonl 原样(1868 条) + INDEX.md 汇总 单测: 750 passed。
This commit is contained in:
@@ -579,15 +579,25 @@ class HwndForegroundCheckTest(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def test_accepts_when_foreground_is_the_target(self):
|
def test_accepts_when_foreground_is_the_target(self):
|
||||||
with mock.patch.object(di, 'foreground_window', return_value=999):
|
with mock.patch.object(di, 'foreground_window', return_value=999), \
|
||||||
|
mock.patch.object(di, 'client_area_on_screen', return_value=(0, 0, 1280, 720)):
|
||||||
ok, why = di.click_point_is_on_foreground(100, 100, 999)
|
ok, why = di.click_point_is_on_foreground(100, 100, 999)
|
||||||
self.assertTrue(ok)
|
self.assertTrue(ok)
|
||||||
self.assertEqual(why, 'ok')
|
self.assertEqual(why, 'ok')
|
||||||
|
|
||||||
|
def test_rejects_point_outside_client_area(self):
|
||||||
|
# 2026-11-18: 前台是游戏、但客户区 (1,1) 换算出的屏幕点在窗口外 → 会点到桌面的回收站
|
||||||
|
with mock.patch.object(di, 'foreground_window', return_value=999), \
|
||||||
|
mock.patch.object(di, 'client_area_on_screen', return_value=(50, 50, 1300, 760)):
|
||||||
|
ok, why = di.click_point_is_on_foreground(9, 32, 999)
|
||||||
|
self.assertFalse(ok)
|
||||||
|
self.assertIn('不在游戏客户区', why)
|
||||||
|
|
||||||
def test_accepts_child_window_of_target(self):
|
def test_accepts_child_window_of_target(self):
|
||||||
"""游戏可能有子窗口拿到焦点, 也算在目标窗口上。"""
|
"""游戏可能有子窗口拿到焦点, 也算在目标窗口上。"""
|
||||||
is_child = mock.Mock(return_value=True)
|
is_child = mock.Mock(return_value=True)
|
||||||
with mock.patch.object(di, 'foreground_window', return_value=1000), \
|
with mock.patch.object(di, 'foreground_window', return_value=1000), \
|
||||||
|
mock.patch.object(di, 'client_area_on_screen', return_value=(0, 0, 1280, 720)), \
|
||||||
win_api(IsChild=is_child):
|
win_api(IsChild=is_child):
|
||||||
ok, _ = di.click_point_is_on_foreground(100, 100, 999)
|
ok, _ = di.click_point_is_on_foreground(100, 100, 999)
|
||||||
is_child.assert_called_once_with(999, 1000)
|
is_child.assert_called_once_with(999, 1000)
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""卡包刷新按钮改成按 OCR 文字点。
|
||||||
|
|
||||||
|
2026-11-18 用户反馈: 卡包页按「刷新」没按上(模板 0.90 命中、点下去卡包不变)。
|
||||||
|
"""
|
||||||
|
import sys
|
||||||
|
import types
|
||||||
|
import unittest
|
||||||
|
from pathlib import Path
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
|
REPO = Path(__file__).resolve().parents[1]
|
||||||
|
sys.path.insert(0, str(REPO))
|
||||||
|
from lc_mcp import aalc_patches as ap # noqa: E402
|
||||||
|
|
||||||
|
|
||||||
|
class RefreshTextPosTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_finds_refresh_in_top_right(self):
|
||||||
|
auto = mock.Mock()
|
||||||
|
with mock.patch.object(ap, '_ocr_lines', return_value=[
|
||||||
|
('商店', 600, 30), ('刷新', 1000, 45), ('关键词刷新', 300, 40)]):
|
||||||
|
self.assertEqual(ap._refresh_text_pos(auto), (1000, 45))
|
||||||
|
|
||||||
|
def test_ignores_shop_refresh_on_the_left(self):
|
||||||
|
auto = mock.Mock()
|
||||||
|
with mock.patch.object(ap, '_ocr_lines', return_value=[('关键词刷新', 300, 40)]):
|
||||||
|
self.assertIsNone(ap._refresh_text_pos(auto))
|
||||||
|
|
||||||
|
def test_ignores_text_below_the_header(self):
|
||||||
|
auto = mock.Mock()
|
||||||
|
with mock.patch.object(ap, '_ocr_lines', return_value=[('刷新', 1000, 400)]):
|
||||||
|
self.assertIsNone(ap._refresh_text_pos(auto))
|
||||||
|
|
||||||
|
|
||||||
|
class RefreshClickTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def install(self, auto):
|
||||||
|
module = types.ModuleType('module.automation')
|
||||||
|
module.auto = auto
|
||||||
|
with mock.patch.dict(sys.modules, {'module': types.ModuleType('module'),
|
||||||
|
'module.automation': module}):
|
||||||
|
return ap.install_theme_pack_refresh_click(log=lambda *_: None)
|
||||||
|
|
||||||
|
def test_clicks_ocr_position_instead_of_template(self):
|
||||||
|
auto = mock.Mock()
|
||||||
|
auto.click_element.return_value = True
|
||||||
|
self.install(auto)
|
||||||
|
with mock.patch.object(ap, '_refresh_text_pos', return_value=(1000, 45)):
|
||||||
|
self.assertTrue(auto.click_element(ap.THEME_PACK_REFRESH))
|
||||||
|
auto.mouse_click.assert_called_once_with(1000, 45)
|
||||||
|
|
||||||
|
def test_falls_back_to_template_when_text_missing(self):
|
||||||
|
auto = mock.Mock()
|
||||||
|
auto.click_element.return_value = True
|
||||||
|
original = self.install(auto)
|
||||||
|
with mock.patch.object(ap, '_refresh_text_pos', return_value=None):
|
||||||
|
auto.click_element(ap.THEME_PACK_REFRESH)
|
||||||
|
auto.mouse_click.assert_not_called()
|
||||||
|
|
||||||
|
def test_other_targets_untouched(self):
|
||||||
|
auto = mock.Mock()
|
||||||
|
auto.click_element.return_value = True
|
||||||
|
self.install(auto)
|
||||||
|
auto.click_element('other/thing.png')
|
||||||
|
auto.mouse_click.assert_not_called()
|
||||||
Reference in New Issue
Block a user