Files
LihonT/tests/test_seekbar_patch.py
cheb0chik d40c17b083 LihonT 2 Serena beta
Avatar frames that follow the outline of the avatar (ring and parts hung on it), packs of frames that arrive from a catalog on the
site by themselves, the frame shown to other members through the members service, save an avatar by user name, the diary of the
mod, the seek bar on every video, the beta version line and its what is new, plus tests, the catalog builder, the sprites and the
scripts that draw them.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-03 10:30:22 +03:00

64 lines
1.8 KiB
Python

import unittest
from pathlib import Path
from lihont import seekbar_patch
ROOT = Path(__file__).resolve().parents[1]
# LX/1Azi;->setSeekBarShowType of TikTok 47.1.3 (shortened to the parts the patch looks at).
SAMPLE = """.class public LX/1Azi;
.super Landroid/widget/LinearLayout;
.method public final setSeekBarShowType(I)V
.registers 9
iget v0, p0, LX/1Azi;->LLJJJJJIL:I
if-eq v0, p1, :cond_30
iput p1, p0, LX/1Azi;->LLJJJJJIL:I
const-string v0, "seekbar show type change, change to:"
const/4 v0, 0x3
if-eq p1, v0, :cond_86
:cond_30
return-void
:cond_86
const/16 v0, 0x8
return-void
.end method
"""
class SeekbarPatchTest(unittest.TestCase):
def test_type_is_changed_before_anything_else(self):
text = seekbar_patch.rewrite_seek_bar(SAMPLE)
self.assertIn("invoke-static {p1}, " + seekbar_patch.HOOK, text)
self.assertLess(text.index("move-result p1"), text.index("iget v0, p0, LX/1Azi;->LLJJJJJIL:I"))
def test_twice_is_refused(self):
with self.assertRaises(ValueError):
seekbar_patch.rewrite_seek_bar(seekbar_patch.rewrite_seek_bar(SAMPLE))
def test_other_shape_is_refused(self):
with self.assertRaises(ValueError):
seekbar_patch.rewrite_seek_bar(SAMPLE.replace("const/16 v0, 0x8", "const/16 v0, 0x4"))
def test_missing_method_is_refused(self):
with self.assertRaises(ValueError):
seekbar_patch.rewrite_seek_bar(".class public LX/1Azi;\n")
def test_runtime_hook_exists(self):
source = (ROOT / "src/lihont/two/look/Seekbar.java").read_text(encoding="utf-8")
self.assertIn("public static int type(int asked)", source)
self.assertEqual(seekbar_patch.runtime_targets(), [seekbar_patch.HOOK])
if __name__ == "__main__":
unittest.main()