This commit is contained in:
@@ -3,11 +3,12 @@ from __future__ import annotations
|
||||
from pathlib import Path
|
||||
|
||||
from core.errors import DriverError
|
||||
from core.models import Bounds
|
||||
from core.models import ActiveApp, Bounds, Scene
|
||||
from device.manager import DeviceManager
|
||||
from driver.base import Driver
|
||||
from perception.ocr import OCRBox
|
||||
from tools.describe_screen import describe_screen
|
||||
from tests.fakes import FakeDriver
|
||||
|
||||
PNG_10X20 = b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x0a\x00\x00\x00\x14"
|
||||
|
||||
@@ -91,3 +92,28 @@ def test_describe_screen_degrades_to_ocr_only_when_ui_tree_unavailable() -> None
|
||||
|
||||
assert [element.text for element in scene.elements] == ["Search"]
|
||||
assert all(element.source == "ocr" for element in scene.elements)
|
||||
|
||||
|
||||
def test_describe_screen_includes_live_active_app_metadata() -> None:
|
||||
active_app = ActiveApp(
|
||||
platform="android",
|
||||
package="com.example.mobile",
|
||||
activity=".MainActivity",
|
||||
)
|
||||
manager = DeviceManager()
|
||||
manager.register_device("phone-1", lambda: FakeDriver(active_app=active_app))
|
||||
manager.connect("phone-1")
|
||||
|
||||
scene = describe_screen(
|
||||
"phone-1",
|
||||
manager=manager,
|
||||
ocr_engine=FakeOCREngine([]), # type: ignore[arg-type]
|
||||
)
|
||||
|
||||
assert scene.active_app == active_app
|
||||
assert scene.to_dict()["app"] == {
|
||||
"platform": "android",
|
||||
"package": "com.example.mobile",
|
||||
"activity": ".MainActivity",
|
||||
}
|
||||
assert Scene.from_dict(scene.to_dict()).active_app == active_app
|
||||
|
||||
Reference in New Issue
Block a user