mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 06:15:58 +00:00
fix: Steam's Browse buttons open the file chooser with the x86-64 client too (#1557)
This commit is contained in:
1 parent
86ecb716eb
commit
8658ffff90
3 files changed
+91
-7
No files matched your search
@@ -69,6 +69,44 @@ class SteamCompatEnvironmentTest(unittest.TestCase):
|
||||
os.kill(helper_pid, 9)
|
||||
self.fail('droiddeck-steam-compat outlived the session')
|
||||
|
||||
def test_the_x86_64_client_gets_only_the_file_dialog_bridge(self):
|
||||
source = (BIN / 'droiddeck-session').read_text()
|
||||
start = source.index(' if [ "$steam_x64" = 1 ]; then\n { droiddeck-steam-compat --files-only')
|
||||
block = source[start:source.index(' fi\n', start) + len(' fi\n')]
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
helper = root / 'droiddeck-steam-compat'
|
||||
helper.write_text('#!/bin/sh\necho "$@" >> "$ARGS_FILE"\n')
|
||||
helper.chmod(0o755)
|
||||
for x64, expected in (('1', '--files-only /steam'), ('0', '/steam')):
|
||||
with self.subTest(x64=x64):
|
||||
args = root / ('args-' + x64)
|
||||
env = dict(os.environ, PATH=str(root) + os.pathsep + os.environ['PATH'],
|
||||
ARGS_FILE=str(args), steam_root='/steam', steam_x64=x64)
|
||||
subprocess.run(['bash', '-c', '_bl_compat_env=(env)\n' + block + 'wait\n'], env=env, timeout=10, check=True)
|
||||
self.assertEqual(args.read_text().split('\n')[0], expected)
|
||||
|
||||
def test_files_only_mode_installs_only_the_file_dialog_hook(self):
|
||||
import runpy
|
||||
compat = runpy.run_path(str(BIN / 'droiddeck-steam-compat'))
|
||||
calls = []
|
||||
|
||||
class Page:
|
||||
def __init__(self, port, path):
|
||||
self.ws = None
|
||||
def evaluate(self, expression):
|
||||
calls.append(('evaluate', expression[:40]))
|
||||
return True
|
||||
def call(self, method, params):
|
||||
calls.append((method, params['name']))
|
||||
|
||||
helper = compat['Helper']('/steam', 1234, files_only=True)
|
||||
helper.attach.__globals__.update(shared_context=lambda port: '/devtools/page/1', Page=Page)
|
||||
self.assertTrue(helper.attach())
|
||||
bindings = [name for method, name in calls if method == 'Runtime.addBinding']
|
||||
self.assertEqual(bindings, [compat['FILE_BINDING']])
|
||||
self.assertIn(('evaluate', compat['FILE_JS'][:40]), calls)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user