mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 13:05:47 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94ae2ce846 | ||
|
|
0438887e91 | ||
|
|
2def4735fc |
No files matched your search
@@ -158,7 +158,17 @@ def ask(channel, request, timeout=TIMEOUT, claim=False):
|
|||||||
|
|
||||||
def windows_path(unix):
|
def windows_path(unix):
|
||||||
tool = bionic_tool(os.environ.get("DD_STORE_PROTON", ""))
|
tool = bionic_tool(os.environ.get("DD_STORE_PROTON", ""))
|
||||||
return (tool and bionic_path(tool, unix)) or "Z:" + unix.replace("/", "\\")
|
if tool:
|
||||||
|
return bionic_path(tool, unix) or "Z:" + unix.replace("/", "\\")
|
||||||
|
return "Z:" + guest_path(unix).replace("/", "\\")
|
||||||
|
|
||||||
|
|
||||||
|
def guest_path(unix):
|
||||||
|
root = os.environ.get("DDNATV_ROOT", "").rstrip("/")
|
||||||
|
for host in dict.fromkeys(filter(None, (root, root and os.path.realpath(root)))):
|
||||||
|
if unix == host or unix.startswith(host + "/"):
|
||||||
|
return unix[len(host):] or "/"
|
||||||
|
return unix
|
||||||
|
|
||||||
|
|
||||||
def bionic_tool(proton):
|
def bionic_tool(proton):
|
||||||
|
|||||||
@@ -170,10 +170,28 @@ class StorePaths(unittest.TestCase):
|
|||||||
os.environ.pop('DDNATV_ROOT', None)
|
os.environ.pop('DDNATV_ROOT', None)
|
||||||
self.assertEqual('Z:\\home\\games\\b.reg', store.windows_path('/home/games/b.reg'))
|
self.assertEqual('Z:\\home\\games\\b.reg', store.windows_path('/home/games/b.reg'))
|
||||||
|
|
||||||
|
def test_other_tools_name_rootfs_host_paths_by_their_guest_paths(self):
|
||||||
|
(self.tool / 'bionic/launch.sh').unlink()
|
||||||
|
with self.env():
|
||||||
|
self.assertEqual('Z:\\tmp\\droiddeck-ea-1\\probe.bat', store.windows_path(ANDROID + '/tmp/droiddeck-ea-1/probe.bat'))
|
||||||
|
self.assertEqual('Z:\\', store.windows_path(ANDROID))
|
||||||
|
self.assertEqual('Z:\\data\\user\\0\\com.droiddeck.launcher\\files\\linuxfs2\\a.reg',
|
||||||
|
store.windows_path(ANDROID + '2/a.reg'))
|
||||||
|
self.assertEqual('Z:\\storage\\emulated\\0\\Games\\a.reg', store.windows_path('/storage/emulated/0/Games/a.reg'))
|
||||||
|
real = '/data/data/com.droiddeck.launcher/files/linuxfs'
|
||||||
|
with self.env(), patch.object(store.os.path, 'realpath', lambda path: real if path == ANDROID else path):
|
||||||
|
self.assertEqual('Z:\\tmp\\droiddeck-ea-2\\registry.reg', store.windows_path(real + '/tmp/droiddeck-ea-2/registry.reg'))
|
||||||
|
with patch.dict(os.environ, {'DD_STORE_PROTON': str(self.tool / 'proton')}):
|
||||||
|
os.environ.pop('DDNATV_ROOT', None)
|
||||||
|
self.assertEqual('Z:\\data\\user\\0\\com.droiddeck.launcher\\files\\linuxfs\\tmp\\c.reg',
|
||||||
|
store.windows_path(ANDROID + '/tmp/c.reg'))
|
||||||
|
|
||||||
def test_a_failing_tool_keeps_the_guest_path(self):
|
def test_a_failing_tool_keeps_the_guest_path(self):
|
||||||
(self.tool / 'proton').write_text('#!/bin/sh\nexit 1\n')
|
(self.tool / 'proton').write_text('#!/bin/sh\nexit 1\n')
|
||||||
with self.env():
|
with self.env():
|
||||||
self.assertEqual('Z:\\home\\games\\c.reg', store.windows_path('/home/games/c.reg'))
|
self.assertEqual('Z:\\home\\games\\c.reg', store.windows_path('/home/games/c.reg'))
|
||||||
|
self.assertEqual('Z:\\data\\user\\0\\com.droiddeck.launcher\\files\\linuxfs\\tmp\\c.reg',
|
||||||
|
store.windows_path(ANDROID + '/tmp/c.reg'))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@@ -921,6 +921,31 @@ class GogRegistry(unittest.TestCase):
|
|||||||
self.assertFalse((Path(root) / 'compat/pfx' / store.GOG_REGISTRY_MARK).exists())
|
self.assertFalse((Path(root) / 'compat/pfx' / store.GOG_REGISTRY_MARK).exists())
|
||||||
self.assertEqual('no-proton', store.apply_gog_registry(folder, root + '/compat', root + '/missing'))
|
self.assertEqual('no-proton', store.apply_gog_registry(folder, root + '/compat', root + '/missing'))
|
||||||
|
|
||||||
|
def test_a_native_import_names_its_file_and_the_game_by_their_guest_paths(self):
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
root = Path(tmp) / 'linuxfs'
|
||||||
|
(root / 'tmp').mkdir(parents=True)
|
||||||
|
folder = game(root / 'root', store_id='gog', ident='7')
|
||||||
|
gog_script(folder, '7', [set_registry(root='HKLM', subkey='Software\\Game', valueName='Path',
|
||||||
|
valueData='{app}', valueType='string')])
|
||||||
|
proton = Path(tmp) / 'proton'
|
||||||
|
proton.write_text('selected Proton')
|
||||||
|
data = root / 'root/compat'
|
||||||
|
imported = []
|
||||||
|
def run(argv, **kwargs):
|
||||||
|
source = argv[4]
|
||||||
|
self.assertTrue(source.startswith('Z:\\tmp\\droiddeck-gog-'), source)
|
||||||
|
self.assertTrue(source.endswith('\\registry.reg'), source)
|
||||||
|
imported.append((root / source[3:].replace('\\', '/')).read_bytes()[2:].decode('utf-16-le'))
|
||||||
|
(data / 'pfx').mkdir(parents=True, exist_ok=True)
|
||||||
|
(data / 'pfx/system.reg').write_text('Wine registry')
|
||||||
|
return subprocess.CompletedProcess(argv, 0)
|
||||||
|
with patch.dict(os.environ, {'DDNATV_ROOT': str(root), 'DD_STORE_PROTON': str(proton)}), \
|
||||||
|
patch.object(tempfile, 'tempdir', str(root / 'tmp')), \
|
||||||
|
patch.object(store.subprocess, 'run', side_effect=run):
|
||||||
|
self.assertEqual('written=1', store.apply_gog_registry(folder, str(data), str(proton)))
|
||||||
|
self.assertIn('"Path"="Z:\\\\root\\\\Games\\\\Stores\\\\Epic\\\\Metalstorm"', imported[0])
|
||||||
|
|
||||||
def test_every_gog_launch_brings_the_registry_in(self):
|
def test_every_gog_launch_brings_the_registry_in(self):
|
||||||
with tempfile.TemporaryDirectory() as root:
|
with tempfile.TemporaryDirectory() as root:
|
||||||
folder = game(root, store_id='gog')
|
folder = game(root, store_id='gog')
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import importlib.machinery
|
|||||||
import importlib.util
|
import importlib.util
|
||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
@@ -171,6 +172,53 @@ class EaHook(unittest.TestCase):
|
|||||||
(pfx / store.EA_HARDWARE).write_text(json.dumps(whole))
|
(pfx / store.EA_HARDWARE).write_text(json.dumps(whole))
|
||||||
self.assertEqual(store.ea_hardware(tmp, ''), (whole, 'cached'))
|
self.assertEqual(store.ea_hardware(tmp, ''), (whole, 'cached'))
|
||||||
|
|
||||||
|
def native_session(self, tmp):
|
||||||
|
root = Path(tmp) / 'linuxfs'
|
||||||
|
(root / 'tmp').mkdir(parents=True)
|
||||||
|
compat = root / 'root/compat'
|
||||||
|
(compat / 'pfx').mkdir(parents=True)
|
||||||
|
(compat / 'pfx/system.reg').write_text('')
|
||||||
|
proton = Path(tmp) / 'proton'
|
||||||
|
proton.write_text('')
|
||||||
|
env = patch.dict('os.environ', {'DDNATV_ROOT': str(root), 'DD_STORE_PROTON': str(proton)})
|
||||||
|
return root, compat, str(proton), env, patch.object(tempfile, 'tempdir', str(root / 'tmp'))
|
||||||
|
|
||||||
|
def test_a_native_probe_names_its_files_by_their_guest_paths(self):
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
root, compat, proton, env, tmpdir = self.native_session(tmp)
|
||||||
|
seen = []
|
||||||
|
|
||||||
|
def run(command, **kwargs):
|
||||||
|
bat = command[-1]
|
||||||
|
seen.append(bat)
|
||||||
|
text = (root / bat[3:].replace('\\', '/')).read_text()
|
||||||
|
seen.extend(re.findall(r'"([A-Z]:[^"]*)"', text))
|
||||||
|
return subprocess.CompletedProcess(command, 0)
|
||||||
|
|
||||||
|
with env, tmpdir, patch.object(store.subprocess, 'run', run):
|
||||||
|
self.assertEqual('incomplete', store.ea_hardware(str(compat), proton)[1])
|
||||||
|
self.assertTrue(seen)
|
||||||
|
for path in seen:
|
||||||
|
self.assertTrue(path.startswith('Z:\\tmp\\droiddeck-ea-'), path)
|
||||||
|
|
||||||
|
def test_a_native_registry_import_names_its_file_by_its_guest_path(self):
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
root, compat, proton, env, tmpdir = self.native_session(tmp)
|
||||||
|
sources = []
|
||||||
|
|
||||||
|
def run(command, **kwargs):
|
||||||
|
source = command[4]
|
||||||
|
sources.append(source)
|
||||||
|
self.assertTrue((root / source[3:].replace('\\', '/')).is_file(), source)
|
||||||
|
return subprocess.CompletedProcess(command, 0)
|
||||||
|
|
||||||
|
sidecar = {'id': 'OFB-EAST:1', 'title': 'Game', 'extra': {'contentIds': '1'}}
|
||||||
|
with env, tmpdir, patch.object(store.subprocess, 'run', run):
|
||||||
|
self.assertEqual('written', store.ea_registry(root / 'root/Games/Game', sidecar, str(compat), proton))
|
||||||
|
self.assertEqual(2, len(sources))
|
||||||
|
for source in sources:
|
||||||
|
self.assertTrue(source.startswith('Z:\\tmp\\droiddeck-ea-'), source)
|
||||||
|
|
||||||
def touchup_setup(self, tmp):
|
def touchup_setup(self, tmp):
|
||||||
folder = Path(tmp) / 'game'
|
folder = Path(tmp) / 'game'
|
||||||
(folder / 'Touchup').mkdir(parents=True)
|
(folder / 'Touchup').mkdir(parents=True)
|
||||||
|
|||||||
Reference in new issue
Block a user