Files
DroidDeck/tools/tests/test_picture_position_mapping.py
MaxsTechReview c5577478ca chore: remove source comments and unused code, translate every missing string (#1965)
* chore(i18n): translate every missing string in all locales

Adds the 87 strings the bottom-screen Dashboard and in-game stats pages
introduced to all 32 locales, plus the 51 older settings strings Japanese
and the 50 Chinese locales were still missing. Every locale now has all
3456 translatable strings with the same placeholders as English.

Also translates 36 entries that were still English where the language
does not use the English word, and makes es-419 touch_app_id use the same
%1$s placeholder as English.

* chore(patches): drop comments from the lines downstream patches add

Removes comment lines and trailing comments from lines our patches add,
with hunk headers recounted. Lines that a later patch uses as context
and the upstream backport 0123 are left as they are.

The gamescope, FEX, proot and xodus series still apply to their pinned
sources, and the patched trees differ only in those comments.
test_hud_frames now finds the HUD writer by its first declaration.

* docs: credit Greenlight, Better xCloud, viture-v2, GameNative and DiRTTelemetryErrorFix

These were credited only in source headers and NOTICE files.

* chore: remove source comments and unused functions

Removes explanatory comments from first-party Kotlin, Java, C, C++,
Rust, TypeScript, Python, shell, Gradle, CMake and workflow files.
License and attribution headers stay, and vendored third-party trees,
generated files and license files are untouched. A shellcheck directive
is kept, and udevmon's fallthrough comments became fallthrough attributes.

Syntax trees and token streams match the previous sources apart from the
comments and Python docstrings. Module docstrings that argparse prints
are kept, and device-smoke.sh prints the same --help text from a heredoc.

Also removes 37 functions and 4 fields that nothing referenced.

* chore: remove comments from the Syncthing integration and the latest main sources

* docs: credit Syncthing and the syncthing-android fork

* chore(i18n): translate the Syncthing strings in all locales

The 107 strings the Syncthing integration added are now in all 32 locales.
sync_web_path_locked names the Syncthing tab by its label.

* docs: credit @xXJSONDeruloXx for the HUD metric readers

The CPU, GPU load, thermal and battery readers come from their
PerformanceHudView pull requests #777, #877, #991, #1406 and #1573.
The FusionHUD credit line is unchanged.

* docs: credit the HUD metric readers to @xXJSONDeruloXx's work
2026-11-01 16:27:27 -05:00

74 lines
3.3 KiB
Python

import os
from pathlib import Path
import shutil
import subprocess
import tempfile
import unittest
REPO = Path(__file__).resolve().parents[2]
class GameTopMappingTest(unittest.TestCase):
def test_letterbox_alignment_and_touch_inverse(self):
cc = shutil.which(os.environ.get('CC', 'cc'))
if not cc:
self.skipTest('A host C compiler is required')
source = (REPO / 'app/src/main/cpp/waylandcomp/src/vk_present.c').read_text()
header = (REPO / 'app/src/main/cpp/waylandcomp/src/vk_present.h').read_text()
enums = header[header.index('enum vkp_scale_mode'):header.index('void vk_present_set_scale_mode')]
state = source[source.index('static volatile int g_mode'):source.index('static int64_t g_swap_retry_at_ns')]
def function(signature):
start = source.index(signature)
return source[start:source.index('\n}\n', start) + 3]
funcs = '\n'.join(function(name) for name in ['static const char *mode_name(',
'static const char *align_name(', 'static void update_map(', 'int vkp_output_to_scene(', 'int vkp_game_picture_rect('])
with tempfile.TemporaryDirectory() as tmp:
tmp = Path(tmp)
code = '#include <assert.h>\n#include <math.h>\n#include <stdio.h>\n#include <string.h>\n#include <pthread.h>\n'
code += '#define droiddeck_log(...) ((void)0)\nstatic struct { unsigned width, height; } g_extent;\n'
code += enums + state + funcs
code += r'''
static void near(double a, double b) { assert(fabs(a - b) < 0.01); }
static void check(int sw, int sh, int ow, int oh, int alignment) {
g_extent.width = ow; g_extent.height = oh;
g_mode = VKP_MODE_FIT; g_align = alignment;
update_map(sw, sh);
float rect[4];
assert(vkp_game_picture_rect(rect));
double top = alignment == VKP_ALIGN_PICTURE_TOP ? 0 : oh - sh * g_map.ky;
near(rect[0], g_map.off_x); near(rect[1], top);
near(rect[2], g_map.off_x + sw * g_map.kx);
near(rect[3], top + sh * g_map.ky);
near(g_map.off_y, top);
double sx, sy;
assert(vkp_output_to_scene(g_map.off_x + sw * g_map.kx / 2,
top + sh * g_map.ky / 2, &sx, &sy));
near(sx, sw / 2.0); near(sy, sh / 2.0);
near(g_map.kx, g_map.ky);
assert(sh * g_map.ky <= oh + 0.01);
g_align = VKP_ALIGN_CENTER; update_map(sw, sh);
assert(!vkp_game_picture_rect(rect));
near(g_map.off_y, (int)((oh - sh * g_map.ky) * 0.5));
}
int main(void) {
for (int alignment = VKP_ALIGN_PICTURE_TOP; alignment <= VKP_ALIGN_PICTURE_BOTTOM; alignment++) {
check(1240, 1100, 2480, 2200, alignment);
check(1280, 720, 2480, 2200, alignment);
check(1024, 768, 2480, 2200, alignment);
check(1920, 1080, 2400, 1080, alignment);
check(1240, 1100, 2480, 1394, alignment);
}
g_align = VKP_ALIGN_TOP; update_map(1280, 720);
assert(g_map.rh == 697 && g_map.ry == 0);
puts("PASS");
}
'''
(tmp / 'map.c').write_text(code)
subprocess.run([cc, '-std=c11', str(tmp / 'map.c'), '-lm', '-o', str(tmp / 'map')], check=True, capture_output=True, text=True)
result = subprocess.run([str(tmp / 'map')], capture_output=True, text=True)
self.assertEqual(result.returncode, 0, result.stderr)
if __name__ == '__main__':
unittest.main()