forge
Explore
Log in

Don't you dare go Hollow

Add unfullscreen view offset restoration tests

Browse files at this commit

c9c28aa4970ed5f9b808a6b989eb6db9de7ef76bIvan MolodetskikhParent: 5357db3
src/layout/tests/fullscreen.rsmodified+146 -0
@@ -1,3 +1,5 @@
1+use insta::assert_snapshot;
2+
13 use super::*;
24
35 #[test]
@@ -395,3 +397,147 @@ fn unfullscreen_view_offset_not_reset_during_ongoing_gesture() {
395397
396398 check_ops(&ops);
397399 }
400+
401+#[test]
402+fn unfullscreen_preserves_view_pos() {
403+ let ops = [
404+ Op::AddOutput(1),
405+ Op::AddWindow {
406+ params: TestWindowParams::new(1),
407+ },
408+ Op::AddWindow {
409+ params: TestWindowParams::new(2),
410+ },
411+ ];
412+
413+ let mut layout = check_ops(&ops);
414+
415+ // View pos is looking at the first window.
416+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"-16");
417+
418+ let ops = [
419+ Op::FullscreenWindow(2),
420+ Op::Communicate(2),
421+ Op::CompleteAnimations,
422+ ];
423+ check_ops_on_layout(&mut layout, &ops);
424+
425+ // View pos = width of first window + gap.
426+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"116");
427+
428+ let ops = [
429+ Op::FullscreenWindow(2),
430+ Op::Communicate(2),
431+ Op::CompleteAnimations,
432+ ];
433+ check_ops_on_layout(&mut layout, &ops);
434+
435+ // View pos is back to showing the first window.
436+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"-16");
437+}
438+
439+#[test]
440+fn unfullscreen_of_tabbed_preserves_view_pos() {
441+ let ops = [
442+ Op::AddOutput(1),
443+ Op::AddWindow {
444+ params: TestWindowParams::new(1),
445+ },
446+ Op::AddWindow {
447+ params: TestWindowParams::new(2),
448+ },
449+ Op::AddWindow {
450+ params: TestWindowParams::new(3),
451+ },
452+ Op::ConsumeOrExpelWindowLeft { id: None },
453+ Op::SetColumnDisplay(ColumnDisplay::Tabbed),
454+ // Get view pos back on the first window.
455+ Op::FocusColumnLeft,
456+ Op::FocusColumnRight,
457+ ];
458+
459+ let mut layout = check_ops(&ops);
460+
461+ // View pos is looking at the first window.
462+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"-16");
463+
464+ let ops = [
465+ Op::FullscreenWindow(2),
466+ Op::Communicate(2),
467+ Op::Communicate(3),
468+ Op::CompleteAnimations,
469+ ];
470+ check_ops_on_layout(&mut layout, &ops);
471+
472+ // View pos = width of first window + gap.
473+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"116");
474+
475+ let ops = [
476+ Op::FullscreenWindow(3),
477+ Op::Communicate(3),
478+ Op::CompleteAnimations,
479+ ];
480+ check_ops_on_layout(&mut layout, &ops);
481+
482+ // View pos is still on the second column because the second tile hasn't unfullscreened yet.
483+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"116");
484+
485+ let ops = [Op::Communicate(2), Op::CompleteAnimations];
486+ check_ops_on_layout(&mut layout, &ops);
487+
488+ // View pos is back to showing the first window.
489+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"-16");
490+}
491+
492+#[test]
493+fn unfullscreen_of_tabbed_via_change_to_normal_preserves_view_pos() {
494+ let ops = [
495+ Op::AddOutput(1),
496+ Op::AddWindow {
497+ params: TestWindowParams::new(1),
498+ },
499+ Op::AddWindow {
500+ params: TestWindowParams::new(2),
501+ },
502+ Op::AddWindow {
503+ params: TestWindowParams::new(3),
504+ },
505+ Op::ConsumeOrExpelWindowLeft { id: None },
506+ Op::SetColumnDisplay(ColumnDisplay::Tabbed),
507+ // Get view pos back on the first window.
508+ Op::FocusColumnLeft,
509+ Op::FocusColumnRight,
510+ ];
511+
512+ let mut layout = check_ops(&ops);
513+
514+ // View pos is looking at the first window.
515+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"-16");
516+
517+ let ops = [
518+ Op::FullscreenWindow(2),
519+ Op::Communicate(2),
520+ Op::Communicate(3),
521+ Op::CompleteAnimations,
522+ ];
523+ check_ops_on_layout(&mut layout, &ops);
524+
525+ // View pos = width of first window + gap.
526+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"116");
527+
528+ let ops = [
529+ Op::SetColumnDisplay(ColumnDisplay::Normal),
530+ Op::Communicate(3),
531+ Op::CompleteAnimations,
532+ ];
533+ check_ops_on_layout(&mut layout, &ops);
534+
535+ // View pos is still on the second column because the second tile hasn't unfullscreened yet.
536+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"116");
537+
538+ let ops = [Op::Communicate(2), Op::CompleteAnimations];
539+ check_ops_on_layout(&mut layout, &ops);
540+
541+ // View pos is back to showing the first window.
542+ assert_snapshot!(layout.active_workspace().unwrap().scrolling().view_pos(), @"-16");
543+}