Fix background Unity input and shop boundaries; record login failure

Browse Source
This commit is contained in:
Codex Agent
2026-10-03 16:52:49 +08:00
parent 6cd0b2742a
commit 073e407346
13 changed files with 850 additions and 29 deletions
+53
View File
@@ -1,5 +1,6 @@
import sys import sys
import unittest import unittest
import tempfile
from pathlib import Path from pathlib import Path
from unittest import mock from unittest import mock
@@ -10,6 +11,58 @@ from decision_router import DecisionRouter
class EnglishMirrorBoundaryTest(unittest.TestCase): class EnglishMirrorBoundaryTest(unittest.TestCase):
def test_server_error_only_offers_retry_above_background_reward_cards(self):
state = {'items': [
{'text': text, 'x': 1000, 'y': 500, 'w': 120, 'h': 35, 'score': 1}
for text in ['Select Encounter Reward Card', 'A servererror hasoccurred.',
'Retry 4', 'Close', 'Gain55~83Cost', 'Confirm']]}
with mock.patch.object(agent, 'button_enabled', return_value=True):
options = agent.candidates(normalize(state))
self.assertEqual(set(options), {'wait', 'requires_analysis', 'retry_network'})
def test_purchased_badge_blocks_reopening_even_when_ocr_omits_it(self):
from PIL import Image
item = {'text': '替换奥提斯的技能', 'x': 838, 'y': 496, 'w': 196, 'h': 30}
with tempfile.TemporaryDirectory() as folder:
canvas = Image.new('L', (1920, 1080))
with Image.open(agent.REPO_ROOT / 'assets/ui/purchased_english.png') as badge:
canvas.paste(badge.convert('L'), (874, 330))
bought = str(Path(folder) / 'bought.png')
blank = str(Path(folder) / 'blank.png')
canvas.save(bought)
Image.new('L', (1920, 1080)).save(blank)
self.assertTrue(agent.purchased_slot({'screen': {'path': bought, 'w': 1920, 'h': 1080}}, item))
self.assertFalse(agent.purchased_slot({'screen': {'path': blank, 'w': 1920, 'h': 1080}}, item))
def test_english_skill_payment_confirm_requires_validated_skill_pair(self):
state = {'floor': 1, 'screen': {'w': 1920, 'h': 1080}, 'items': [
{'text': text, 'x': x, 'y': y, 'w': 100, 'h': 35, 'score': 1}
for text, x, y in [("Replace Outis's Skill", 382, 179),
('SKILL2', 781, 318), ('SKILL3', 1532, 319),
('Spend 75 Cost to replace this Skill?', 728, 734),
('Confirm', 1161, 796), ('Cancel', 732, 793)]]}
with mock.patch.object(agent, 'button_enabled', return_value=True):
self.assertIn('buy_swap', agent.candidates(normalize(state)))
state['items'][1]['text'] = 'SKILL1'
self.assertNotIn('buy_swap', agent.candidates(state))
def test_split_enhance_menu_and_truncated_skill_shop_label_are_recognized(self):
state = {'items': [
{'text': text, 'x': x, 'y': y, 'w': 100, 'h': 30, 'score': 1}
for text, x, y in [('Enhance', 222, 564), ('Gifts', 238, 587),
("Replace Outis's Skil", 838, 496)]]}
labels = [item['text'] for item in normalize(state)['items']]
self.assertIn('强化饰品', labels)
self.assertTrue(any('技能替换' in label and '奥提斯' in label for label in labels))
def test_stock_refresh_does_not_use_keyword_refresh(self):
state = {'floor': 1, 'symbol_upgraded': True, 'items': [
{'text': text, 'x': x, 'y': 167, 'w': 89, 'h': 31, 'score': 1}
for text, x in [('商店', 337), ('刷新', 1478), ('刷新', 1694), ('离开', 1626)]]}
with mock.patch.object(agent, 'button_enabled', return_value=True):
options = agent.candidates(state)
self.assertEqual(options['shop_refresh']['action']['args']['x'], 1522)
def test_map_header_without_recognized_floor_number_stops_battle(self): def test_map_header_without_recognized_floor_number_stops_battle(self):
for label in ('Exploring Floor', 'Exploring FloorT'): for label in ('Exploring Floor', 'Exploring FloorT'):
with self.subTest(label=label): with self.subTest(label=label):