aboutsummaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-09-02 14:16:39 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-09-17 22:04:23 +0300
commitc9c28aa4970ed5f9b808a6b989eb6db9de7ef76b (patch)
treec0fda17e4613e232c54003f4abe52388b9456f31 /src/layout
parent5357db39cde8fc04bcc88042e7b4933a5f1ed483 (diff)
downloadniri-c9c28aa4970ed5f9b808a6b989eb6db9de7ef76b.tar.gz
niri-c9c28aa4970ed5f9b808a6b989eb6db9de7ef76b.tar.bz2
niri-c9c28aa4970ed5f9b808a6b989eb6db9de7ef76b.zip
Add unfullscreen view offset restoration tests
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/tests/fullscreen.rs146
1 files changed, 146 insertions, 0 deletions
diff --git a/src/layout/tests/fullscreen.rs b/src/layout/tests/fullscreen.rs
index 0586bb76..2b15767e 100644
--- a/src/layout/tests/fullscreen.rs
+++ b/src/layout/tests/fullscreen.rs
@@ -1,3 +1,5 @@
+use insta::assert_snapshot;
+
use super::*;
#[test]
@@ -395,3 +397,147 @@ fn unfullscreen_view_offset_not_reset_during_ongoing_gesture() {
check_ops(&ops);
}
+
+#[test]
+fn unfullscreen_preserves_view_pos() {
+ let ops = [
+ Op::AddOutput(1),
+ Op::AddWindow {
+ params: TestWindowParams::new(1),
+ },
+ Op::AddWindow {
+ params: TestWindowParams::new(2),
+ },
+ ];
+
+ let mut layout = check_ops(&ops);
+
+ // View pos is looking at the first window.
+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"-16");
+
+ let ops = [
+ Op::FullscreenWindow(2),
+ Op::Communicate(2),
+ Op::CompleteAnimations,
+ ];
+ check_ops_on_layout(&mut layout, &ops);
+
+ // View pos = width of first window + gap.
+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"116");
+
+ let ops = [
+ Op::FullscreenWindow(2),
+ Op::Communicate(2),
+ Op::CompleteAnimations,
+ ];
+ check_ops_on_layout(&mut layout, &ops);
+
+ // View pos is back to showing the first window.
+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"-16");
+}
+
+#[test]
+fn unfullscreen_of_tabbed_preserves_view_pos() {
+ let ops = [
+ Op::AddOutput(1),
+ Op::AddWindow {
+ params: TestWindowParams::new(1),
+ },
+ Op::AddWindow {
+ params: TestWindowParams::new(2),
+ },
+ Op::AddWindow {
+ params: TestWindowParams::new(3),
+ },
+ Op::ConsumeOrExpelWindowLeft { id: None },
+ Op::SetColumnDisplay(ColumnDisplay::Tabbed),
+ // Get view pos back on the first window.
+ Op::FocusColumnLeft,
+ Op::FocusColumnRight,
+ ];
+
+ let mut layout = check_ops(&ops);
+
+ // View pos is looking at the first window.
+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"-16");
+
+ let ops = [
+ Op::FullscreenWindow(2),
+ Op::Communicate(2),
+ Op::Communicate(3),
+ Op::CompleteAnimations,
+ ];
+ check_ops_on_layout(&mut layout, &ops);
+
+ // View pos = width of first window + gap.
+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"116");
+
+ let ops = [
+ Op::FullscreenWindow(3),
+ Op::Communicate(3),
+ Op::CompleteAnimations,
+ ];
+ check_ops_on_layout(&mut layout, &ops);
+
+ // View pos is still on the second column because the second tile hasn't unfullscreened yet.
+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"116");
+
+ let ops = [Op::Communicate(2), Op::CompleteAnimations];
+ check_ops_on_layout(&mut layout, &ops);
+
+ // View pos is back to showing the first window.
+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"-16");
+}
+
+#[test]
+fn unfullscreen_of_tabbed_via_change_to_normal_preserves_view_pos() {
+ let ops = [
+ Op::AddOutput(1),
+ Op::AddWindow {
+ params: TestWindowParams::new(1),
+ },
+ Op::AddWindow {
+ params: TestWindowParams::new(2),
+ },
+ Op::AddWindow {
+ params: TestWindowParams::new(3),
+ },
+ Op::ConsumeOrExpelWindowLeft { id: None },
+ Op::SetColumnDisplay(ColumnDisplay::Tabbed),
+ // Get view pos back on the first window.
+ Op::FocusColumnLeft,
+ Op::FocusColumnRight,
+ ];
+
+ let mut layout = check_ops(&ops);
+
+ // View pos is looking at the first window.
+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"-16");
+
+ let ops = [
+ Op::FullscreenWindow(2),
+ Op::Communicate(2),
+ Op::Communicate(3),
+ Op::CompleteAnimations,
+ ];
+ check_ops_on_layout(&mut layout, &ops);
+
+ // View pos = width of first window + gap.
+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"116");
+
+ let ops = [
+ Op::SetColumnDisplay(ColumnDisplay::Normal),
+ Op::Communicate(3),
+ Op::CompleteAnimations,
+ ];
+ check_ops_on_layout(&mut layout, &ops);
+
+ // View pos is still on the second column because the second tile hasn't unfullscreened yet.
+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"116");
+
+ let ops = [Op::Communicate(2), Op::CompleteAnimations];
+ check_ops_on_layout(&mut layout, &ops);
+
+ // View pos is back to showing the first window.
+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"-16");
+}