layout: Add every_op test from starting state
Browse files at this commit23b59b40aac94909d6cab548a422b66a8e06b1acParent: 8491ba51 changed file +119 -2
- src/layout.rs +119 -2
src/layout.rsmodified+119 -2
| @@ -2759,7 +2759,7 @@ mod tests { | ||
| 2759 | 2759 | } |
| 2760 | 2760 | |
| 2761 | 2761 | #[test] |
| 2762 | - fn operations() { | |
| 2762 | + fn operations_dont_panic() { | |
| 2763 | 2763 | let every_op = [ |
| 2764 | 2764 | Op::AddOutput(0), |
| 2765 | 2765 | Op::AddOutput(1), |
| @@ -2809,7 +2809,7 @@ mod tests { | ||
| 2809 | 2809 | for third in every_op { |
| 2810 | 2810 | for second in every_op { |
| 2811 | 2811 | for first in every_op { |
| 2812 | - eprintln!("{first:?}, {second:?}, {third:?}"); | |
| 2812 | + // eprintln!("{first:?}, {second:?}, {third:?}"); | |
| 2813 | 2813 | |
| 2814 | 2814 | let mut layout = Layout::default(); |
| 2815 | 2815 | first.apply(&mut layout); |
| @@ -2823,6 +2823,123 @@ mod tests { | ||
| 2823 | 2823 | } |
| 2824 | 2824 | } |
| 2825 | 2825 | |
| 2826 | + #[test] | |
| 2827 | + fn operations_from_starting_state_dont_panic() { | |
| 2828 | + if std::env::var_os("RUN_SLOW_TESTS").is_none() { | |
| 2829 | + eprintln!("ignoring slow test"); | |
| 2830 | + return; | |
| 2831 | + } | |
| 2832 | + | |
| 2833 | + // Running every op from an empty state doesn't get us to all the interesting states. So, | |
| 2834 | + // also run it from a manually-created starting state with more things going on to exercise | |
| 2835 | + // more code paths. | |
| 2836 | + let setup_ops = [ | |
| 2837 | + Op::AddOutput(1), | |
| 2838 | + Op::AddWindow { | |
| 2839 | + id: 1, | |
| 2840 | + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), | |
| 2841 | + activate: true, | |
| 2842 | + }, | |
| 2843 | + Op::MoveWindowToWorkspaceDown, | |
| 2844 | + Op::AddWindow { | |
| 2845 | + id: 2, | |
| 2846 | + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), | |
| 2847 | + activate: true, | |
| 2848 | + }, | |
| 2849 | + Op::AddWindow { | |
| 2850 | + id: 3, | |
| 2851 | + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), | |
| 2852 | + activate: true, | |
| 2853 | + }, | |
| 2854 | + Op::FocusColumnLeft, | |
| 2855 | + Op::ConsumeWindowIntoColumn, | |
| 2856 | + Op::AddWindow { | |
| 2857 | + id: 4, | |
| 2858 | + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), | |
| 2859 | + activate: true, | |
| 2860 | + }, | |
| 2861 | + Op::AddOutput(2), | |
| 2862 | + Op::AddWindow { | |
| 2863 | + id: 5, | |
| 2864 | + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), | |
| 2865 | + activate: true, | |
| 2866 | + }, | |
| 2867 | + Op::MoveWindowToOutput(2), | |
| 2868 | + Op::FocusOutput(1), | |
| 2869 | + Op::Communicate(1), | |
| 2870 | + Op::Communicate(2), | |
| 2871 | + Op::Communicate(3), | |
| 2872 | + Op::Communicate(4), | |
| 2873 | + Op::Communicate(5), | |
| 2874 | + ]; | |
| 2875 | + | |
| 2876 | + let every_op = [ | |
| 2877 | + Op::AddOutput(0), | |
| 2878 | + Op::AddOutput(1), | |
| 2879 | + Op::AddOutput(2), | |
| 2880 | + Op::RemoveOutput(0), | |
| 2881 | + Op::RemoveOutput(1), | |
| 2882 | + Op::RemoveOutput(2), | |
| 2883 | + Op::FocusOutput(0), | |
| 2884 | + Op::FocusOutput(1), | |
| 2885 | + Op::FocusOutput(2), | |
| 2886 | + Op::AddWindow { | |
| 2887 | + id: 0, | |
| 2888 | + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), | |
| 2889 | + activate: true, | |
| 2890 | + }, | |
| 2891 | + Op::AddWindow { | |
| 2892 | + id: 1, | |
| 2893 | + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), | |
| 2894 | + activate: true, | |
| 2895 | + }, | |
| 2896 | + Op::AddWindow { | |
| 2897 | + id: 2, | |
| 2898 | + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), | |
| 2899 | + activate: true, | |
| 2900 | + }, | |
| 2901 | + Op::CloseWindow(0), | |
| 2902 | + Op::CloseWindow(1), | |
| 2903 | + Op::CloseWindow(2), | |
| 2904 | + Op::FocusColumnLeft, | |
| 2905 | + Op::FocusColumnRight, | |
| 2906 | + Op::MoveColumnLeft, | |
| 2907 | + Op::MoveColumnRight, | |
| 2908 | + Op::ConsumeWindowIntoColumn, | |
| 2909 | + Op::ExpelWindowFromColumn, | |
| 2910 | + Op::FocusWorkspaceDown, | |
| 2911 | + Op::FocusWorkspaceUp, | |
| 2912 | + Op::FocusWorkspace(1), | |
| 2913 | + Op::FocusWorkspace(2), | |
| 2914 | + Op::FocusWorkspace(3), | |
| 2915 | + Op::MoveWindowToWorkspaceDown, | |
| 2916 | + Op::MoveWindowToWorkspaceUp, | |
| 2917 | + Op::MoveWindowToWorkspace(1), | |
| 2918 | + Op::MoveWindowToWorkspace(2), | |
| 2919 | + Op::MoveWindowToWorkspace(3), | |
| 2920 | + ]; | |
| 2921 | + | |
| 2922 | + for third in every_op { | |
| 2923 | + for second in every_op { | |
| 2924 | + for first in every_op { | |
| 2925 | + // eprintln!("{first:?}, {second:?}, {third:?}"); | |
| 2926 | + | |
| 2927 | + let mut layout = Layout::default(); | |
| 2928 | + for op in setup_ops { | |
| 2929 | + op.apply(&mut layout); | |
| 2930 | + } | |
| 2931 | + | |
| 2932 | + first.apply(&mut layout); | |
| 2933 | + layout.verify_invariants(); | |
| 2934 | + second.apply(&mut layout); | |
| 2935 | + layout.verify_invariants(); | |
| 2936 | + third.apply(&mut layout); | |
| 2937 | + layout.verify_invariants(); | |
| 2938 | + } | |
| 2939 | + } | |
| 2940 | + } | |
| 2941 | + } | |
| 2942 | + | |
| 2826 | 2943 | #[test] |
| 2827 | 2944 | fn primary_active_workspace_idx_not_updated_on_output_add() { |
| 2828 | 2945 | let ops = [ |