test: SAE execution loop coverage

This commit is contained in:
2026-05-02 22:40:52 +02:00
parent d1e0995148
commit 936da47f61

View File

@@ -134,3 +134,30 @@ class TestSAECompression:
compressed = sae._compress_xml(broken_xml)
assert "PACKAGES: com.instagram.android" in compressed
assert "TEXTS: Hello" in compressed
class TestSAELoop:
"""Tests the higher-level engine loops."""
def test_ensure_clear_screen_returns_true_immediately_if_normal(self, sae):
"""If the screen is NORMAL, the SAE should return True without taking actions."""
xml_dump = '''
<node package="com.instagram.android">
<node resource-id="com.instagram.android:id/row_feed_button_like" />
</node>
'''
# Bypass dump_hierarchy
sae.device.dump_hierarchy = lambda: xml_dump
assert sae.ensure_clear_screen(max_attempts=3) is True
assert sae._consecutive_failures == 0
def test_is_instagram_foreground(self, sae):
xml_dump = '''
<node package="com.instagram.android">
<node resource-id="com.instagram.android:id/row_feed_button_like" />
</node>
'''
assert sae.is_instagram_foreground(xml_dump=xml_dump) is True
foreign_xml = '<node package="com.apple.ios" />'
assert sae.is_instagram_foreground(xml_dump=foreign_xml) is False