跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

test_control.py

58 行 · 2.6 KB历史下载
1"""Regression checks for the phone window geometry and host mount specification."""
2import json
3import unittest
4from types import SimpleNamespace
5from unittest.mock import Mock
6
7from Xlib import Xutil
8import control
9from view import View, dimensions, fitted_window
10
11
12class PhoneWindowTests(unittest.TestCase):
13 def test_viewport_matches_electron_dpi_even_while_typing(self):
14 for size, expected in [((390, 672), (585, 1008)), ((672, 390), (1008, 585)),
15 ((390, 242), (585, 363))]:
16 self.assertEqual(dimensions(*size), expected)
17
18 def test_only_verified_maximized_window_relaxes_desktop_minimum(self):
19 # A mobile display of 585px starts with the actual Claude Electron
20 # minimum 900x600, which Openbox honors until this hint is lowered.
21 from view import Failure
22 view = View.__new__(View)
23 view.size = (390, 672)
24 view.root = Mock()
25 view.conn = Mock()
26 view.conn.intern_atom.side_effect = lambda name: name
27 view.values = lambda w, k: [12] if w is view.root else [
28 '_NET_WM_STATE_MAXIMIZED_VERT', '_NET_WM_STATE_MAXIMIZED_HORZ']
29 real = Mock()
30 real.get_geometry.return_value = SimpleNamespace(width=900, height=1008)
31 hints = dict(flags=Xutil.PMinSize, min_width=900, min_height=600, win_gravity=10)
32 real.get_wm_normal_hints.return_value = SimpleNamespace(**hints, _data=hints)
33 real.get_wm_transient_for.return_value = None
34 view.window = lambda _: real
35 view.role = lambda _: ''
36 with self.assertRaises(Failure):
37 view.active()
38 real.set_wm_normal_hints.assert_not_called()
39 view.role = lambda _: 'desktop'
40 with self.assertRaises(Failure):
41 view.active()
42 real.set_wm_normal_hints.assert_called_once_with(**{**hints, 'min_width': 585})
43
44 def test_nonmaximized_dialog_uses_matching_picture_and_input_geometry(self):
45 ratio, left, top = fitted_window((390, 672), SimpleNamespace(width=600, height=300))
46 self.assertEqual((150 * ratio + left, 150 * ratio + top), (97.5, 336))
47
48 def test_existing_project_mounts_use_literal_guest_paths_in_transient_unit(self):
49 mounts = ('25 11 0:88 / /opt/QA\\040%h rw - fuse.sshfs :/qa rw\n'
50 '27 11 0:89 / /Users/A\\134B rw - virtiofs data rw\n'
51 '29 11 0:90 / /home rw - ext4 /dev/vda1 rw\n')
52 shares = control.host_shares(mounts)
53 self.assertEqual(shares, ['/Users/A\\B', '/opt/QA %h'])
54 self.assertEqual(json.loads(control.unit_path(shares[1])), '-/opt/QA %h')
55
56
57if __name__ == '__main__':
58 unittest.main()