"""
E2E: Locked Screen Workflow
=============================
Tests the FULL production pipeline when the device screen is locked.

Mock: ONLY the device (XML dumps).
Real: Cognitive stack, PluginRegistry, SessionState, Config.
"""

LOCKED_SCREEN_XML = """<?xml version="1.0" encoding="utf-8"?>
<hierarchy rotation="0">
    <node class="android.widget.FrameLayout" package="com.android.systemui"
          bounds="[0,0][1080,2400]">
        <node resource-id="com.android.systemui:id/keyguard_status_area"
              class="android.widget.LinearLayout" bounds="[0,200][1080,600]">
            <node text="12:34" class="android.widget.TextView"
                  resource-id="com.android.systemui:id/clock_view" />
            <node text="Wednesday, April 30" class="android.widget.TextView" />
        </node>
        <node resource-id="com.android.systemui:id/lock_icon"
              class="android.widget.ImageView"
              content-desc="Unlock" bounds="[440,1800][640,2000]" />
    </node>
</hierarchy>
"""


def test_locked_screen_does_not_interact(make_real_device_with_xml, e2e_workflow_ctx):
    """
    A locked screen must not trigger any interaction plugins.
    The obstacle_guard currently doesn't handle OBSTACLE_LOCKED_SCREEN
    explicitly — this test documents whether it falls through.
    """

    device = make_real_device_with_xml([LOCKED_SCREEN_XML])
    results, ctx = e2e_workflow_ctx(device, context_xml=LOCKED_SCREEN_XML)

    # No interactions may happen on a locked screen
    total_interactions = sum(r.interactions for r in results)
    assert total_interactions == 0, f"{total_interactions} interaction(s) performed on a locked screen!"
