Skip to content

Commit

Permalink
tests: test mixed-dpi configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
amezin committed Nov 30, 2022
1 parent 67a199f commit 071d7c3
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Service]
Environment="MUTTER_DEBUG_NUM_DUMMY_MONITORS=2"
Environment="[email protected]"
Environment="MUTTER_DEBUG_DUMMY_MONITOR_SCALES=2,1"
23 changes: 21 additions & 2 deletions test/extension/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,18 @@ function wait_move_resize(
});
}

function is_mixed_dpi() {
let scales = [];

for (let i = 0; i < global.display.get_n_monitors(); i++) {
const scale = global.display.get_monitor_scale(i);
if (!scales.includes(scale))
scales.push(scale);
}

return scales.length > 1;
}

async function test_show(
window_size,
window_maximize,
Expand Down Expand Up @@ -636,19 +648,26 @@ async function test_show(
const settings_maximize = settings.get_boolean('window-maximize');
const should_maximize =
window_maximize === WindowMaximizeMode.EARLY || (window_size === 1.0 && settings_maximize);
const mixed_dpi_penalty = is_mixed_dpi() ? 2 : 0;

await wait_move_resize(
window_size,
should_maximize,
window_pos,
monitor_index,
prev_maximize === should_maximize ? 0 : 1
(prev_maximize === should_maximize ? 0 : 1) + mixed_dpi_penalty
);

verify_window_geometry(window_size, should_maximize, window_pos, monitor_index);

if (window_maximize === WindowMaximizeMode.LATE) {
const geometry_wait = wait_move_resize(window_size, true, window_pos, monitor_index, 1);
const geometry_wait = wait_move_resize(
window_size,
true,
window_pos,
monitor_index,
1 + mixed_dpi_penalty
);

await set_settings_boolean('window-maximize', true);

Expand Down
43 changes: 43 additions & 0 deletions test/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ def test_show_v(
window_maximize,
window_pos,
monitor_config,
shell_version,
screenshot
):
with screenshot:
Expand All @@ -350,6 +351,7 @@ def test_show_h(
window_maximize,
window_pos,
monitor_config,
shell_version,
screenshot
):
with screenshot:
Expand Down Expand Up @@ -556,6 +558,47 @@ def mount_configs(cls):
]


class TestWaylandMixedDPI(DualMonitorTests, SmallScreenMixin):
GNOME_SHELL_SESSION_NAME = 'gnome-wayland-nested'

@classmethod
def mount_configs(cls):
return super().mount_configs() + [
'/etc/systemd/user/[email protected]/mutter-mixed-dpi.conf'
]

@functools.wraps(CommonTests.test_show_v)
def test_show_v(self, *args, shell_version, **kwargs):
if shell_version < (42, 0):
pytest.skip('Mixed DPI is not supported before GNOME Shell 42')

super().test_show_v(*args, shell_version=shell_version, **kwargs)

@pytest.mark.skip
def test_show_h(self, monitor_config):
pass

@pytest.mark.skip
def test_resize_xte(self, monitor_config):
pass

@pytest.mark.skip
def test_change_position(self, monitor_config):
pass

@pytest.mark.skip
def test_unmaximize(self, monitor_config):
pass

@pytest.mark.skip
def test_unmaximize_correct_size(self, monitor_config):
pass

@pytest.mark.skip
def test_unmaximize_on_size_change(self, monitor_config):
pass


def wait_action_in_group(group, action):
with glib_util.SignalWait(group, f'action-added::{action}') as w:
while not group.has_action(action):
Expand Down

0 comments on commit 071d7c3

Please sign in to comment.