This commit is contained in:
eric
2026-05-19 06:47:07 +00:00
parent e1d7251545
commit 78e1308063
63 changed files with 2527 additions and 186 deletions

View File

@@ -3,7 +3,7 @@ from __future__ import annotations
import unittest
from unittest.mock import patch
from src.android_control import enrich_device_row
from src.android_control import _is_png, _strip_to_png, enrich_device_row
from src.redroid_control import load_redroid_env, redroid_instance_name, redroid_instance_port
@@ -25,6 +25,17 @@ class AndroidRedroidTests(unittest.TestCase):
self.assertEqual(row["transport"], "tcp")
self.assertEqual(row["kind"], "redroid")
def test_strip_to_png_preserves_valid_png_signature(self) -> None:
png = b"\x89PNG\r\n\x1a\n" + b"\x00\x00\x00\rIHDR" + b"\r\ninside-body"
self.assertEqual(_strip_to_png(png), png)
self.assertTrue(_is_png(_strip_to_png(png)))
def test_strip_to_png_repairs_only_normalized_signature(self) -> None:
corrupted_sig = b"\n\n\x89PNG\n\x1a\n" + b"\x00\x00\x00\rIHDR"
repaired = _strip_to_png(corrupted_sig)
self.assertTrue(repaired.startswith(b"\x89PNG\r\n\x1a\n"))
self.assertTrue(_is_png(repaired))
@patch("src.redroid_control.platform.machine", return_value="x86_64")
def test_redroid_env_prefers_x86_alt_image(self, _machine) -> None:
env = load_redroid_env()