tests/floating: Add more edge cases
Browse files at this commitdd1ec83afa40b3c6b17df7fa4a5b7033c50f14abParent: 5ad3d661 changed file +198 -0
- src/tests/floating.rs +198 -0
src/tests/floating.rsmodified+198 -0
| @@ -887,3 +887,201 @@ fn unfullscreen_to_floating_doesnt_send_extra_configure() { | |||
| 887 | @"size: 936 × 1048, bounds: 1920 × 1080, states: [Activated]" | 887 | @"size: 936 × 1048, bounds: 1920 × 1080, states: [Activated]" |
| 888 | ); | 888 | ); |
| 889 | } | 889 | } |
| 890 | + | ||
| 891 | +#[test] | ||
| 892 | +fn unfullscreen_to_same_size_floating() { | ||
| 893 | + let (mut f, id, surface) = set_up(); | ||
| 894 | + | ||
| 895 | + // Make it floating. | ||
| 896 | + f.niri().layout.toggle_window_floating(None); | ||
| 897 | + f.double_roundtrip(id); | ||
| 898 | + | ||
| 899 | + // Change size to the same as fullscreen, make niri remember it. | ||
| 900 | + let window = f.client(id).window(&surface); | ||
| 901 | + window.set_size(1920, 1080); | ||
| 902 | + window.ack_last_and_commit(); | ||
| 903 | + f.double_roundtrip(id); | ||
| 904 | + | ||
| 905 | + let _ = f.client(id).window(&surface).recent_configures(); | ||
| 906 | + | ||
| 907 | + // Fullscreen. | ||
| 908 | + let window = f.client(id).window(&surface); | ||
| 909 | + window.set_fullscreen(None); | ||
| 910 | + f.double_roundtrip(id); | ||
| 911 | + | ||
| 912 | + // The fullscreen configure. | ||
| 913 | + assert_snapshot!( | ||
| 914 | + f.client(id).window(&surface).format_recent_configures(), | ||
| 915 | + @"size: 1920 × 1080, bounds: 1888 × 1048, states: [Activated, Fullscreen]" | ||
| 916 | + ); | ||
| 917 | + | ||
| 918 | + // Unfullscreen into floating. | ||
| 919 | + f.niri().layout.toggle_window_floating(None); | ||
| 920 | + f.double_roundtrip(id); | ||
| 921 | + | ||
| 922 | + // We should see a configure with the same size and no Fullscreen state. | ||
| 923 | + assert_snapshot!( | ||
| 924 | + f.client(id).window(&surface).format_recent_configures(), | ||
| 925 | + @"size: 1920 × 1080, bounds: 1920 × 1080, states: [Activated]" | ||
| 926 | + ); | ||
| 927 | +} | ||
| 928 | + | ||
| 929 | +#[test] | ||
| 930 | +fn unfullscreen_to_same_size_windowed_fullscreen_floating() { | ||
| 931 | + let (mut f, id, surface) = set_up(); | ||
| 932 | + | ||
| 933 | + let mapped = f.niri().layout.windows().next().unwrap().1; | ||
| 934 | + let window_id = mapped.window.clone(); | ||
| 935 | + | ||
| 936 | + // Make it floating. | ||
| 937 | + f.niri().layout.toggle_window_floating(None); | ||
| 938 | + f.double_roundtrip(id); | ||
| 939 | + | ||
| 940 | + // Change size to the same as fullscreen, make niri remember it. | ||
| 941 | + let window = f.client(id).window(&surface); | ||
| 942 | + window.set_size(1920, 1080); | ||
| 943 | + window.ack_last_and_commit(); | ||
| 944 | + f.double_roundtrip(id); | ||
| 945 | + | ||
| 946 | + let _ = f.client(id).window(&surface).recent_configures(); | ||
| 947 | + | ||
| 948 | + // Fullscreen. | ||
| 949 | + let window = f.client(id).window(&surface); | ||
| 950 | + window.set_fullscreen(None); | ||
| 951 | + f.double_roundtrip(id); | ||
| 952 | + | ||
| 953 | + // The fullscreen configure. | ||
| 954 | + assert_snapshot!( | ||
| 955 | + f.client(id).window(&surface).format_recent_configures(), | ||
| 956 | + @"size: 1920 × 1080, bounds: 1888 × 1048, states: [Activated, Fullscreen]" | ||
| 957 | + ); | ||
| 958 | + | ||
| 959 | + // Unfullscreen into windowed-fullscreen floating. | ||
| 960 | + f.niri().layout.toggle_windowed_fullscreen(&window_id); | ||
| 961 | + f.double_roundtrip(id); | ||
| 962 | + | ||
| 963 | + // Should send configure because the bounds have changed. | ||
| 964 | + assert_snapshot!( | ||
| 965 | + f.client(id).window(&surface).format_recent_configures(), | ||
| 966 | + @"size: 1920 × 1080, bounds: 1920 × 1080, states: [Activated, Fullscreen]" | ||
| 967 | + ); | ||
| 968 | +} | ||
| 969 | + | ||
| 970 | +#[test] | ||
| 971 | +fn unfullscreen_to_same_size_same_bounds_floating() { | ||
| 972 | + let config = r##" | ||
| 973 | +layout { | ||
| 974 | + gaps 0 | ||
| 975 | +} | ||
| 976 | +"##; | ||
| 977 | + let config = Config::parse_mem(config).unwrap(); | ||
| 978 | + let (mut f, id, surface) = set_up_with_config(config); | ||
| 979 | + | ||
| 980 | + // Make it floating. | ||
| 981 | + f.niri().layout.toggle_window_floating(None); | ||
| 982 | + f.double_roundtrip(id); | ||
| 983 | + | ||
| 984 | + // Change size to the same as fullscreen, make niri remember it. | ||
| 985 | + let window = f.client(id).window(&surface); | ||
| 986 | + window.set_size(1920, 1080); | ||
| 987 | + window.ack_last_and_commit(); | ||
| 988 | + f.double_roundtrip(id); | ||
| 989 | + | ||
| 990 | + let _ = f.client(id).window(&surface).recent_configures(); | ||
| 991 | + | ||
| 992 | + // Fullscreen. | ||
| 993 | + let window = f.client(id).window(&surface); | ||
| 994 | + window.set_fullscreen(None); | ||
| 995 | + f.double_roundtrip(id); | ||
| 996 | + | ||
| 997 | + // The fullscreen configure. | ||
| 998 | + assert_snapshot!( | ||
| 999 | + f.client(id).window(&surface).format_recent_configures(), | ||
| 1000 | + @"size: 1920 × 1080, bounds: 1920 × 1080, states: [Activated, Fullscreen]" | ||
| 1001 | + ); | ||
| 1002 | + | ||
| 1003 | + // Unfullscreen into floating. | ||
| 1004 | + f.niri().layout.toggle_window_floating(None); | ||
| 1005 | + f.double_roundtrip(id); | ||
| 1006 | + | ||
| 1007 | + // We should see a configure with the same size and no Fullscreen state. | ||
| 1008 | + assert_snapshot!( | ||
| 1009 | + f.client(id).window(&surface).format_recent_configures(), | ||
| 1010 | + @"size: 1920 × 1080, bounds: 1920 × 1080, states: [Activated]" | ||
| 1011 | + ); | ||
| 1012 | +} | ||
| 1013 | + | ||
| 1014 | +#[test] | ||
| 1015 | +fn repeated_size_request() { | ||
| 1016 | + let (mut f, id, surface) = set_up(); | ||
| 1017 | + let _ = f.client(id).window(&surface).recent_configures(); | ||
| 1018 | + | ||
| 1019 | + // Make it floating. | ||
| 1020 | + f.niri().layout.toggle_window_floating(None); | ||
| 1021 | + f.double_roundtrip(id); | ||
| 1022 | + | ||
| 1023 | + // The floating configure. | ||
| 1024 | + assert_snapshot!( | ||
| 1025 | + f.client(id).window(&surface).format_recent_configures(), | ||
| 1026 | + @"size: 936 × 1048, bounds: 1920 × 1080, states: [Activated]" | ||
| 1027 | + ); | ||
| 1028 | + | ||
| 1029 | + // Request a different width (200x100). | ||
| 1030 | + f.niri() | ||
| 1031 | + .layout | ||
| 1032 | + .set_window_width(None, SizeChange::SetFixed(200)); | ||
| 1033 | + f.niri() | ||
| 1034 | + .layout | ||
| 1035 | + .set_window_height(None, SizeChange::SetFixed(100)); | ||
| 1036 | + f.double_roundtrip(id); | ||
| 1037 | + | ||
| 1038 | + // The 200x100 request. | ||
| 1039 | + assert_snapshot!( | ||
| 1040 | + f.client(id).window(&surface).format_recent_configures(), | ||
| 1041 | + @"size: 200 × 100, bounds: 1920 × 1080, states: [Activated]" | ||
| 1042 | + ); | ||
| 1043 | + | ||
| 1044 | + // Request a size change to the same size as we have just requested. | ||
| 1045 | + f.niri().layout.set_column_width(SizeChange::SetFixed(200)); | ||
| 1046 | + f.double_roundtrip(id); | ||
| 1047 | + | ||
| 1048 | + // Should request nothing as this is a repeated same-size request in floating and the surface | ||
| 1049 | + // hasn't committed to it yet. | ||
| 1050 | + assert_snapshot!( | ||
| 1051 | + f.client(id).window(&surface).format_recent_configures(), | ||
| 1052 | + @"" | ||
| 1053 | + ); | ||
| 1054 | + | ||
| 1055 | + // Ack but don't commit yet. | ||
| 1056 | + let window = f.client(id).window(&surface); | ||
| 1057 | + window.ack_last(); | ||
| 1058 | + f.double_roundtrip(id); | ||
| 1059 | + | ||
| 1060 | + // Request a size change to the same size as we have just requested. | ||
| 1061 | + f.niri().layout.set_column_width(SizeChange::SetFixed(200)); | ||
| 1062 | + f.double_roundtrip(id); | ||
| 1063 | + | ||
| 1064 | + // Should request nothing as this is a repeated same-size request in floating and the surface | ||
| 1065 | + // hasn't committed to it yet. | ||
| 1066 | + assert_snapshot!( | ||
| 1067 | + f.client(id).window(&surface).format_recent_configures(), | ||
| 1068 | + @"" | ||
| 1069 | + ); | ||
| 1070 | + | ||
| 1071 | + // Commit. | ||
| 1072 | + let window = f.client(id).window(&surface); | ||
| 1073 | + window.commit(); | ||
| 1074 | + f.double_roundtrip(id); | ||
| 1075 | + | ||
| 1076 | + // Request the size change again. | ||
| 1077 | + f.niri().layout.set_column_width(SizeChange::SetFixed(200)); | ||
| 1078 | + f.double_roundtrip(id); | ||
| 1079 | + | ||
| 1080 | + // This should send a new configure since the window had committed. | ||
| 1081 | + // | ||
| 1082 | + // FIXME: doesn't request that currently. | ||
| 1083 | + assert_snapshot!( | ||
| 1084 | + f.client(id).window(&surface).format_recent_configures(), | ||
| 1085 | + @"" | ||
| 1086 | + ); | ||
| 1087 | +} | ||