Files
LihonT/tests/test_new_features.py
cheb0chik 3540ac84ea LihonT 2.3.0 (Serena): profile music, AI video dubbing, PiP & bg play, fonts, cleaner
- Shared moderated MP3 profile music (with floating mini-player and MediaSession controls, zero bubble when absent)
- AI video dubbing into Russian with burned-in ASS subtitles inside AgentChat (`services/members/dub.py`)
- Picture-in-Picture 9:16 and background audio playback (`PlayControl` + `play_patch.py`)
- System/custom .ttf fonts & emoji packs (`FontsAndEmoji`), account cleaner (`AccountCleaner`)
- Feed blacklist, muted sound restoration, OLED burn-in shift, A/B flag editor, presets, long comments
- Updated site homepage (`src/web/index.html`) for LihonT 2.3.0 Serena
2026-11-26 15:40:32 +03:00

107 lines
3.5 KiB
Python

import unittest
from pathlib import Path
from lihont import play_patch
ROOT = Path(__file__).resolve().parents[1]
SETTINGS = ROOT / "src" / "lihont" / "two" / "settings" / "LihonTSettingsActivity.java"
TRANSLATOR = ROOT / "src" / "lihont" / "two" / "comments" / "CommentTranslator.java"
FONTS = ROOT / "src" / "lihont" / "two" / "look" / "FontsAndEmoji.java"
CLEANER = ROOT / "src" / "lihont" / "two" / "account" / "AccountCleaner.java"
PLAY = ROOT / "src" / "lihont" / "two" / "play" / "PlayControl.java"
BG_GATE = """.class public final LX/08LC;
.super Ljava/lang/Object;
.method public static LIZ()I
.registers 1
const/4 v0, 0x0
return v0
.end method
.method public static LIZIZ()Z
.registers 2
const/4 v0, 0x0
return v0
.end method
"""
PIP_GATE = """.class public final LX/116m;
.super Ljava/lang/Object;
.method public static LIZ()Z
.registers 2
const/4 v0, 0x0
return v0
.end method
"""
MAIN = """.class public Lcom/ss/android/ugc/aweme/main/MainActivity;
.super LX/0tPX;
.method public onResume()V
.registers 1
return-void
.end method
"""
class NewFeaturesTest(unittest.TestCase):
def test_play_patch_gates_and_leave_hint(self):
bg = play_patch.rewrite_bg_gate(BG_GATE)
self.assertIn(play_patch.HOOK_BG_MODE, bg)
self.assertIn(play_patch.HOOK_BG_BOOL, bg)
with self.assertRaises(ValueError):
play_patch.rewrite_bg_gate(bg)
pip = play_patch.rewrite_pip_gate(PIP_GATE)
self.assertIn(play_patch.HOOK_PIP, pip)
with self.assertRaises(ValueError):
play_patch.rewrite_pip_gate(pip)
main = play_patch.rewrite_main_leave(MAIN)
self.assertIn(".method protected onUserLeaveHint()V", main)
self.assertIn("invoke-super {p0}, LX/0tPX;->onUserLeaveHint()V", main)
self.assertIn(play_patch.HOOK_LEAVE, main)
with self.assertRaises(ValueError):
play_patch.rewrite_main_leave(main)
def test_settings_rows_and_classes_exist(self):
settings = SETTINGS.read_text(encoding="utf-8")
for needle in (
"pipRow()",
"bgPlayRow()",
"fontsEmojiRow()",
"cleanerRow()",
"dialogOptionRow(",
"REQUEST_FONT",
"REQUEST_EMOJI",
):
self.assertIn(needle, settings)
for src in (FONTS, CLEANER, PLAY):
self.assertTrue(src.is_file(), f"Missing {src}")
self.assertIn("CustomFallbackBuilder", FONTS.read_text(encoding="utf-8"))
self.assertIn("tiktok/v1/upvote/delete", CLEANER.read_text(encoding="utf-8"))
self.assertIn("enterPictureInPictureMode", PLAY.read_text(encoding="utf-8"))
def test_profile_music_and_agent_dub_wiring(self):
music = (ROOT / "src" / "lihont" / "two" / "profile" / "ProfileMusic.java").read_text(encoding="utf-8")
self.assertIn("music_lookup", music)
self.assertIn("music_upload", music)
self.assertIn("removeIfPresent", music)
self.assertNotIn("AlertDialog", music)
self.assertNotIn("itunes.apple.com", music)
client = (ROOT / "src" / "lihont" / "two" / "agent" / "AgentClient.java").read_text(encoding="utf-8")
self.assertIn("dubStart", client)
self.assertIn("dubStatus", client)
chat = (ROOT / "src" / "lihont" / "two" / "settings" / "AgentChat.java").read_text(encoding="utf-8")
self.assertIn("dubVideo", chat)
self.assertIn("[DUB_VIDEO:", chat)
self.assertIn("MediaStore.Video.Media", chat)
if __name__ == "__main__":
unittest.main()