27 lines
1.0 KiB
Python
27 lines
1.0 KiB
Python
"""Flight tutorial text fits the existing dialog using actual engine layout."""
|
|
import json
|
|
from pathlib import Path
|
|
import unittest
|
|
from test_cjk_layout import layout
|
|
|
|
|
|
class FlightTests(unittest.TestCase):
|
|
def test_flight_instructions_fit_and_share_dialog_center(self):
|
|
mapping = json.loads(Path(__file__).with_name('tutorial_cn.json').read_text(encoding='utf-8'))
|
|
bodies = [v for k, v in mapping.items() if k.startswith('\fYou can fly')]
|
|
self.assertEqual(len(bodies), 2)
|
|
self.assertEqual(bodies[0], bodies[1])
|
|
for body in bodies:
|
|
for width in (360, 400, 480):
|
|
lines, _ = layout(body, width=width, alignment=0)
|
|
self.assertEqual(len(lines), 2)
|
|
for raw, x, y in lines:
|
|
text = raw.decode('gb2312')
|
|
self.assertEqual(x, (width - len(text) * 12) // 2)
|
|
self.assertNotIn(text[0], ',。;:、')
|
|
self.assertEqual(lines[1][2] - lines[0][2], 17)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|