[gtk: 1/2] Fix gestures test



commit 7d23b6dad506ee19f4e37d6d3ccb50e8e915e059
Author: Alexander Larsson <alexl redhat com>
Date:   Mon Feb 10 16:24:03 2020 +0100

    Fix gestures test
    
    This tests was testing gestures by faking an event in the
    middle of a window that has a hbox with an expanding image in it.
    For me (and I guess this depends on all sorts of issues like whether
    CSD is enabled, font sizes, etc) the hbox ended up centered horizontally
    but not vertically (probably because of csd at the top), so no events
    ever hit the inner widgets.
    
    This is fixed by emitting the events at allocation.x/y of the
    hbox, which should contain both the hbox and the image (as it expands).

 testsuite/gtk/gestures.c | 79 +++++++++++++++++++++---------------------------
 1 file changed, 35 insertions(+), 44 deletions(-)
---
diff --git a/testsuite/gtk/gestures.c b/testsuite/gtk/gestures.c
index deb4f3b21c..6b2c649d1a 100644
--- a/testsuite/gtk/gestures.c
+++ b/testsuite/gtk/gestures.c
@@ -437,9 +437,9 @@ test_phases (void)
   add_gesture (B, "b3", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
   add_gesture (C, "c3", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
 
-  gtk_widget_get_allocation (A, &allocation);
+  gtk_widget_get_allocation (B, &allocation);
 
-  point_update (&mouse_state, A, allocation.width / 2, allocation.height / 2);
+  point_update (&mouse_state, A, allocation.x, allocation.y);
   point_press (&mouse_state, A, 1);
 
   g_assert_cmpstr (str->str, ==,
@@ -493,9 +493,9 @@ test_mixed (void)
   add_gesture (B, "b3", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
   add_gesture (C, "c3", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
 
-  gtk_widget_get_allocation (A, &allocation);
+  gtk_widget_get_allocation (B, &allocation);
 
-  point_update (&mouse_state, A, allocation.width / 2, allocation.height / 2);
+  point_update (&mouse_state, A, allocation.x, allocation.y);
   point_press (&mouse_state, A, 1);
 
   g_assert_cmpstr (str->str, ==,
@@ -550,9 +550,9 @@ test_early_exit (void)
   add_gesture (B, "b3", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
   add_gesture (C, "c3", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
 
-  gtk_widget_get_allocation (A, &allocation);
+  gtk_widget_get_allocation (B, &allocation);
 
-  point_update (&mouse_state, A, allocation.width / 2, allocation.height / 2);
+  point_update (&mouse_state, A, allocation.x, allocation.y);
   point_press (&mouse_state, A, 1);
 
   g_assert_cmpstr (str->str, ==,
@@ -601,9 +601,9 @@ test_claim_capture (void)
   add_gesture (B, "b3", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
   add_gesture (C, "c3", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
 
-  gtk_widget_get_allocation (A, &allocation);
+  gtk_widget_get_allocation (B, &allocation);
 
-  point_update (&mouse_state, A, allocation.width / 2, allocation.height / 2);
+  point_update (&mouse_state, A, allocation.x, allocation.y);
   point_press (&mouse_state, A, 1);
 
   g_assert_cmpstr (str->str, ==,
@@ -648,8 +648,8 @@ test_claim_target (void)
   add_gesture (B, "b3", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
   add_gesture (C, "c3", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
 
-  gtk_widget_get_allocation (A, &allocation);
-  point_update (&mouse_state, A, allocation.width / 2, allocation.height / 2);
+  gtk_widget_get_allocation (B, &allocation);
+  point_update (&mouse_state, A, allocation.x, allocation.y);
   point_press (&mouse_state, A, 1);
 
   g_assert_cmpstr (str->str, ==,
@@ -695,8 +695,8 @@ test_claim_bubble (void)
   add_gesture (B, "b3", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_CLAIMED);
   add_gesture (C, "c3", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
 
-  gtk_widget_get_allocation (A, &allocation);
-  point_update (&mouse_state, A, allocation.width / 2, allocation.height / 2);
+  gtk_widget_get_allocation (B, &allocation);
+  point_update (&mouse_state, A, allocation.x, allocation.y);
   point_press (&mouse_state, A, 1);
 
   g_assert_cmpstr (str->str, ==,
@@ -749,8 +749,8 @@ test_early_claim_capture (void)
   add_gesture (B, "b3", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
   add_gesture (C, "c3", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
 
-  gtk_widget_get_allocation (A, &allocation);
-  point_update (&mouse_state, A, allocation.width / 2, allocation.height / 2);
+  gtk_widget_get_allocation (B, &allocation);
+  point_update (&mouse_state, A, allocation.x, allocation.y);
   point_press (&mouse_state, A, 1);
 
   g_assert_cmpstr (str->str, ==,
@@ -806,8 +806,8 @@ test_late_claim_capture (void)
   add_gesture (B, "b3", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
   add_gesture (C, "c3", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
 
-  gtk_widget_get_allocation (A, &allocation);
-  point_update (&mouse_state, A, allocation.width / 2, allocation.height / 2);
+  gtk_widget_get_allocation (B, &allocation);
+  point_update (&mouse_state, A, allocation.x, allocation.y);
   point_press (&mouse_state, A, 1);
 
   g_assert_cmpstr (str->str, ==,
@@ -867,10 +867,8 @@ test_group (void)
   add_gesture (B, "b3", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
   add_gesture (C, "c4", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
 
-  gtk_widget_get_allocation (A, &allocation);
-
-  gtk_widget_get_allocation (A, &allocation);
-  point_update (&mouse_state, A, allocation.width / 2, allocation.height / 2);
+  gtk_widget_get_allocation (B, &allocation);
+  point_update (&mouse_state, A, allocation.x, allocation.y);
   point_press (&mouse_state, A, 1);
 
   g_assert_cmpstr (str->str, ==,
@@ -920,8 +918,8 @@ test_gestures_outside_grab (void)
   add_gesture (B, "b2", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
   add_gesture (A, "a2", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
 
-  gtk_widget_get_allocation (A, &allocation);
-  point_update (&mouse_state, A, allocation.width / 2, allocation.height / 2);
+  gtk_widget_get_allocation (B, &allocation);
+  point_update (&mouse_state, A, allocation.x, allocation.y);
   point_press (&mouse_state, A, 1);
 
   g_assert_cmpstr (str->str, ==,
@@ -977,8 +975,8 @@ test_gestures_inside_grab (void)
   add_gesture (B, "b2", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
   add_gesture (A, "a2", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_NONE);
 
-  gtk_widget_get_allocation (A, &allocation);
-  point_update (&mouse_state, A, allocation.width / 2, allocation.height / 2);
+  gtk_widget_get_allocation (B, &allocation);
+  point_update (&mouse_state, A, allocation.x, allocation.y);
   point_press (&mouse_state, A, 1);
 
   g_assert_cmpstr (str->str, ==,
@@ -996,8 +994,7 @@ test_gestures_inside_grab (void)
 
   /* Update with the grab under effect */
   g_string_erase (str, 0, str->len);
-  point_update (&mouse_state, A, (allocation.width / 2),
-                (allocation.height / 2));
+  point_update (&mouse_state, A, allocation.x, allocation.y);
   g_assert_cmpstr (str->str, ==,
                    "b1 updated, "
                    "c1 updated, "
@@ -1034,10 +1031,10 @@ test_multitouch_on_single (void)
   add_gesture (A, "a1", GTK_PHASE_CAPTURE, str, GTK_EVENT_SEQUENCE_NONE);
   add_gesture (B, "b1", GTK_PHASE_CAPTURE, str, GTK_EVENT_SEQUENCE_CLAIMED);
 
-  gtk_widget_get_allocation (A, &allocation);
+  gtk_widget_get_allocation (B, &allocation);
 
   /* First touch down */
-  point_update (&touch_state[0], A, allocation.width / 2, allocation.height / 2);
+  point_update (&touch_state[0], A, allocation.x, allocation.y);
   point_press (&touch_state[0], A, 1);
 
   g_assert_cmpstr (str->str, ==,
@@ -1047,8 +1044,7 @@ test_multitouch_on_single (void)
 
   /* Second touch down */
   g_string_erase (str, 0, str->len);
-  point_update (&touch_state[1], A, (allocation.width / 2),
-                (allocation.height / 2));
+  point_update (&touch_state[1], A, allocation.x, allocation.y);
   point_press (&touch_state[1], A, 1);
 
   g_assert_cmpstr (str->str, ==,
@@ -1084,17 +1080,16 @@ test_multitouch_activation (void)
   str = g_string_new ("");
 
   add_mt_gesture (C, "c1", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_CLAIMED);
-  gtk_widget_get_allocation (A, &allocation);
+  gtk_widget_get_allocation (B, &allocation);
 
   /* First touch down */
-  point_update (&touch_state[0], A, allocation.width / 2, allocation.height / 2);
+  point_update (&touch_state[0], A, allocation.x, allocation.y);
   point_press (&touch_state[0], A, 1);
 
   g_assert_cmpstr (str->str, ==, "");
 
   /* Second touch down */
-  point_update (&touch_state[1], A, (allocation.width / 2),
-                (allocation.height / 2));
+  point_update (&touch_state[1], A, allocation.x, allocation.y);
   point_press (&touch_state[1], A, 1);
 
   g_assert_cmpstr (str->str, ==,
@@ -1111,8 +1106,7 @@ test_multitouch_activation (void)
 
   /* A third touch down triggering again action */
   g_string_erase (str, 0, str->len);
-  point_update (&touch_state[2], A, (allocation.width / 2),
-                (allocation.height / 2));
+  point_update (&touch_state[2], A, allocation.x, allocation.y);
   point_press (&touch_state[2], A, 1);
 
   g_assert_cmpstr (str->str, ==,
@@ -1163,10 +1157,10 @@ test_multitouch_interaction (void)
 
   g = add_gesture (A, "a1", GTK_PHASE_CAPTURE, str, GTK_EVENT_SEQUENCE_CLAIMED);
   add_mt_gesture (C, "c1", GTK_PHASE_BUBBLE, str, GTK_EVENT_SEQUENCE_CLAIMED);
-  gtk_widget_get_allocation (A, &allocation);
+  gtk_widget_get_allocation (B, &allocation);
 
   /* First touch down, a1 claims the sequence */
-  point_update (&touch_state[0], A, allocation.width / 2, allocation.height / 2);
+  point_update (&touch_state[0], A, allocation.x, allocation.y);
   point_press (&touch_state[0], A, 1);
 
   g_assert_cmpstr (str->str, ==,
@@ -1175,8 +1169,7 @@ test_multitouch_interaction (void)
 
   /* Second touch down, a1 denies and c1 takes over */
   g_string_erase (str, 0, str->len);
-  point_update (&touch_state[1], A, (allocation.width / 2),
-                (allocation.height / 2));
+  point_update (&touch_state[1], A, allocation.x, allocation.y);
   point_press (&touch_state[1], A, 1);
 
   /* Denying sequences in touch-excess situation is a responsibility of the caller */
@@ -1191,8 +1184,7 @@ test_multitouch_interaction (void)
 
   /* Move first point, only c1 should update */
   g_string_erase (str, 0, str->len);
-  point_update (&touch_state[0], A, (allocation.width / 2),
-                (allocation.height / 2));
+  point_update (&touch_state[0], A, allocation.x, allocation.y);
 
   g_assert_cmpstr (str->str, ==,
                    "c1 updated");
@@ -1206,8 +1198,7 @@ test_multitouch_interaction (void)
 
   /* A third touch down triggering again action on c1 */
   g_string_erase (str, 0, str->len);
-  point_update (&touch_state[2], A, (allocation.width / 2),
-                (allocation.height / 2));
+  point_update (&touch_state[2], A, allocation.x, allocation.y);
   point_press (&touch_state[2], A, 1);
 
   g_assert_cmpstr (str->str, ==,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]