mirror of
https://github.com/lucannez64/darling-lol.git
synced 2026-10-26 19:47:42 +00:00
fix(launcher): address in-game helper review
- restore hidden windows even when the launcher output pipe is closed; - exit the hide watcher after ten idle minutes and start it only after the installed-client check; - reject missing, malformed or invalid close-during-game preferences instead of silently selecting hide; - document the preference contract and idle behavior.
This commit is contained in:
1 parent
732e9c8881
commit
f8bb14624e
8 files changed
+178
-69
No files matched your search
@@ -36,9 +36,12 @@ class ClientInGameTricksTests(unittest.TestCase):
|
||||
self.write(True, False)
|
||||
self.assertEqual(tricks.mode(self.path), 'hide')
|
||||
|
||||
def test_hide_when_close_preference_is_missing(self):
|
||||
def test_none_when_close_preference_is_missing_or_invalid(self):
|
||||
self.write(True)
|
||||
self.assertEqual(tricks.mode(self.path), 'hide')
|
||||
self.assertEqual(tricks.mode(self.path), 'none')
|
||||
for value in ('maybe', '"true', 'true#note', '"true"junk'):
|
||||
self.write(True, value)
|
||||
self.assertEqual(tricks.mode(self.path), 'none', value)
|
||||
|
||||
def test_none_when_optimizations_are_off(self):
|
||||
self.write(False, True)
|
||||
@@ -64,6 +67,7 @@ class ClientInGameTricksTests(unittest.TestCase):
|
||||
'lol-user-experience:\n'
|
||||
' data:\n'
|
||||
' potatoModeEnabled: true\n'
|
||||
' closeLeagueClientDuringGame: false\n'
|
||||
'other-section:\n'
|
||||
' potatoModeEnabled: true\n'
|
||||
' closeLeagueClientDuringGame: true\n')
|
||||
|
||||
@@ -217,6 +217,46 @@ class HideClientInGameTests(unittest.TestCase):
|
||||
watcher._hide_new()
|
||||
self.assertEqual(watcher.hidden, {0xabc})
|
||||
|
||||
def test_restore_log_failure_still_shows_the_window(self):
|
||||
class BrokenOutput:
|
||||
def write(self, _text):
|
||||
raise BrokenPipeError
|
||||
|
||||
def flush(self):
|
||||
pass
|
||||
|
||||
x11 = FakeX11()
|
||||
watcher = hide_in_game.Watcher(
|
||||
self.prefix, x11,
|
||||
window_source=lambda _prefix, _cache: [0xabc],
|
||||
state_source=lambda _prefix: True,
|
||||
sleep=lambda _seconds: None,
|
||||
out=BrokenOutput(),
|
||||
)
|
||||
watcher.hidden = {0xabc}
|
||||
watcher._show_all('test')
|
||||
self.assertEqual(x11.shown, [0xabc])
|
||||
self.assertEqual(watcher.hidden, set())
|
||||
|
||||
def test_idle_timeout_leaves_after_client_disappears(self):
|
||||
states = iter([True, False, False])
|
||||
windows = iter([[0xabc], [], []])
|
||||
times = iter([0.0, 10.0, 700.0])
|
||||
x11 = FakeX11()
|
||||
output = io.StringIO()
|
||||
watcher = hide_in_game.Watcher(
|
||||
self.prefix, x11,
|
||||
window_source=lambda _prefix, _cache: next(windows),
|
||||
state_source=lambda _prefix: next(states),
|
||||
sleep=lambda _seconds: None,
|
||||
out=output,
|
||||
clock=lambda: next(times),
|
||||
)
|
||||
self.assertEqual(watcher.run(max_steps=3), 0)
|
||||
self.assertEqual(x11.unmapped, [0xabc])
|
||||
self.assertEqual(x11.shown, [0xabc])
|
||||
self.assertIn('no client or match', output.getvalue())
|
||||
|
||||
def test_hides_then_shows_on_match_end(self):
|
||||
states = iter([True, True, False])
|
||||
x11 = FakeX11()
|
||||
@@ -278,6 +318,11 @@ class HideClientInGameTests(unittest.TestCase):
|
||||
}):
|
||||
self.assertEqual(hide_in_game.main([]), 0)
|
||||
|
||||
def test_helper_starts_after_the_installed_client_check(self):
|
||||
source = (ROOT / 'tools/run-riot-client.sh').read_text()
|
||||
self.assertLess(source.index('Riot Client is not installed in'),
|
||||
source.index('RCLOL_CLIENT_IN_GAME_TRICKS'))
|
||||
|
||||
def test_master_tricks_switch_enables_hide(self):
|
||||
class FakeX11:
|
||||
def close(self):
|
||||
|
||||
Reference in new issue
Block a user