fix: 合并近重叠地址入口候选 (#276)

This commit is contained in:
chengma
2026-08-18 17:42:47 +08:00
parent ff96f652c4
commit 7c56c29032
2 changed files with 90 additions and 3 deletions
@@ -18,6 +18,7 @@ from src.performance_timing import TaskPerformanceTrace
from src.pdd_u2_purchase_adapter import (
U2PddLivePurchaseAdapter,
U2PddPurchaseAdapter,
_address_entry_targets,
_final_submit_targets,
_needs_color_region_restore,
_page_kind,
@@ -544,6 +545,29 @@ def address_confirmation_xml(address: str) -> str:
</hierarchy>"""
def duplicate_address_entry_xml(*, separated: bool = False) -> str:
"""模拟同一卡片重复节点,或两个位置明显不同的真实候选。"""
second_top, second_bottom = ((620, 727) if separated else (366, 472))
return f"""<hierarchy>
<node package="com.xunmeng.pinduoduo" bounds="[0,0][1080,2376]">
<node package="com.xunmeng.pinduoduo" clickable="true"
enabled="true" visible-to-user="true"
bounds="[0,366][1080,473]">
<node package="com.xunmeng.pinduoduo"
text="测试用户,000****0000" bounds="[412,366][993,384]"/>
</node>
<node package="com.xunmeng.pinduoduo" clickable="true"
enabled="true" visible-to-user="true"
bounds="[0,{second_top}][1080,{second_bottom}]">
<node package="com.xunmeng.pinduoduo"
text="测试用户,111****1111"
bounds="[93,{second_top + 30}][960,{second_top + 76}]"/>
</node>
</node>
</hierarchy>"""
def clipped_address_confirmation_xml(address: str) -> str:
"""首次地址卡片被顶部裁剪时的脱敏控件树。"""
@@ -1075,6 +1099,16 @@ class AmbiguousAfterModifyAddressDevice(AddressFlowDevice):
class U2PddPurchaseAdapterTest(unittest.TestCase):
def test_address_entry_merges_one_pixel_duplicate_nodes(self):
root = ET.fromstring(duplicate_address_entry_xml())
self.assertEqual(_address_entry_targets(root), [(0, 366, 1080, 472)])
def test_address_entry_keeps_separate_cards_ambiguous(self):
root = ET.fromstring(duplicate_address_entry_xml(separated=True))
self.assertEqual(len(_address_entry_targets(root)), 2)
def _adapter(self, device, calls):
def select_color_fn(_device, _xml, target, **_kwargs):
calls.append(("color", target))