Streak widget from 1x1 to 4x4 with an animated flame (orange while lit, grey when not), a streak keeper that writes the chosen message once a day to the chosen chats (off until switched on), avatar shapes, widgets and the keeper kept per account, Material 3 tonal surfaces instead of black (AMOLED keeps pure black), launcher previews of our own, and the mod runtime in a dex of its own. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
76 lines
2.5 KiB
Python
76 lines
2.5 KiB
Python
"""Run the per-account avatar shape book on a real JVM.
|
|
|
|
The book is plain Java (the Android part, AccountShapes, only keeps it in a private file), so the
|
|
tests compile it with javac and run each scenario in its own process.
|
|
"""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
SOURCE = ROOT / "src" / "lihont" / "two" / "account" / "AccountShapeBook.java"
|
|
HARNESS = ROOT / "tests" / "java" / "lihont" / "two" / "account" / "AccountShapeBookTest.java"
|
|
|
|
|
|
class AccountShapeBookTest(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
cls.javac = shutil.which("javac")
|
|
cls.java = shutil.which("java")
|
|
if not cls.javac or not cls.java:
|
|
raise RuntimeError("Account shape tests require a JDK with java and javac")
|
|
cls.temporary = tempfile.TemporaryDirectory(prefix="lihont-account-tests-")
|
|
cls.addClassCleanup(cls.temporary.cleanup)
|
|
cls.classes = Path(cls.temporary.name) / "classes"
|
|
cls.classes.mkdir()
|
|
cls.environment = dict(os.environ)
|
|
cls.environment.pop("JAVA_TOOL_OPTIONS", None)
|
|
cls.run_command([
|
|
cls.javac, "--release", "17", "-encoding", "UTF-8", "-Xlint:all", "-Werror",
|
|
"-d", str(cls.classes), str(SOURCE), str(HARNESS),
|
|
])
|
|
|
|
@classmethod
|
|
def run_command(cls, command):
|
|
result = subprocess.run(
|
|
command, capture_output=True, text=True, encoding="utf-8",
|
|
env=cls.environment, timeout=120,
|
|
)
|
|
if result.returncode:
|
|
raise AssertionError(
|
|
f"Command failed with exit {result.returncode}: {command[0]}\n"
|
|
+ result.stdout + result.stderr
|
|
)
|
|
return result
|
|
|
|
def run_scenario(self, name):
|
|
result = self.run_command([
|
|
self.java, "-cp", str(self.classes),
|
|
"lihont.two.account.AccountShapeBookTest", name,
|
|
])
|
|
self.assertEqual(result.stdout.strip(), "PASS " + name)
|
|
|
|
def test_every_account_keeps_its_own_shape(self):
|
|
self.run_scenario("perAccount")
|
|
|
|
def test_the_book_survives_the_file(self):
|
|
self.run_scenario("roundTrip")
|
|
|
|
def test_a_damaged_file_loses_only_the_damaged_lines(self):
|
|
self.run_scenario("damaged")
|
|
|
|
def test_bad_ids_and_names_are_refused(self):
|
|
self.run_scenario("invalid")
|
|
|
|
def test_the_old_single_shape_goes_to_the_first_known_account_once(self):
|
|
self.run_scenario("migrate")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|