[GTK] Several InputMethodFilter tests are failing and crashing
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Aug 2017 14:10:21 +0000 (14:10 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Aug 2017 14:10:21 +0000 (14:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=176158

Reviewed by Carlos Alberto Lopez Perez.

Source/WebKit:

* UIProcess/gtk/InputMethodFilter.cpp:
(WebKit::InputMethodFilter::confirmCurrentComposition): Return early in testing mode because the page is not available.
(WebKit::InputMethodFilter::logHandleKeyboardEventWithCompositionResultsForTesting): Use hexadecimal numbers for
logging key codes.

Tools:

This started to happen after the GTK+ upgrade from 3.16 to 3.22 in the internal jhbuild. Now, GtkIMContext
doesn't emit the preedit signals when using the compose key (GDK_KEY_Multi_key). The composition results are
committed directly when they are ready. The test InputMethodFilterComposeKey was failing because it expected
preedit events that no longer happen. Tests InputMethodFilterContextFocusOutDuringOngoingComposition and
InputMethodFilterContextMouseClickDuringOngoingComposition were crashing because InputMethodFilter::confirmCurrentComposition()
accessed the WebPageProxy unconditionally, that is not available in testing mode. I wonder how this ever
worked. Other tests results have also been updated because logHandleKeyboardEventWithCompositionResultsForTesting()
now uses hexadecimal numbers for the key codes, for consistency with all other event logs.

* TestWebKitAPI/Tests/WebKit/gtk/InputMethodFilter.cpp:
(TestWebKitAPI::TestInputMethodFilter::TestInputMethodFilter):
(TestWebKitAPI::TEST):
(TestWebKitAPI::verifyCanceledComposition): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221420 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/gtk/InputMethodFilter.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit/gtk/InputMethodFilter.cpp

index 01346e5..481b0ac 100644 (file)
@@ -1,5 +1,17 @@
 2017-08-31  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        [GTK] Several InputMethodFilter tests are failing and crashing
+        https://bugs.webkit.org/show_bug.cgi?id=176158
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        * UIProcess/gtk/InputMethodFilter.cpp:
+        (WebKit::InputMethodFilter::confirmCurrentComposition): Return early in testing mode because the page is not available.
+        (WebKit::InputMethodFilter::logHandleKeyboardEventWithCompositionResultsForTesting): Use hexadecimal numbers for
+        logging key codes.
+
+2017-08-31  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         [GTK][Wayland] Crash when gdk_keymap_get_entries_for_keyval returns TRUE but n_keys=0
         https://bugs.webkit.org/show_bug.cgi?id=176154
 
index 6ceb0c1..24ee1e9 100644 (file)
@@ -312,6 +312,14 @@ void InputMethodFilter::confirmCurrentComposition()
 {
     if (!m_composingTextCurrently)
         return;
+
+#if ENABLE(API_TESTS)
+    if (m_testingMode) {
+        m_composingTextCurrently = false;
+        return;
+    }
+#endif
+
     m_page->confirmComposition(String(), -1, 0);
     m_composingTextCurrently = false;
 }
@@ -431,7 +439,7 @@ void InputMethodFilter::logHandleKeyboardEventWithCompositionResultsForTesting(G
 {
     const char* eventType = event->type == GDK_KEY_RELEASE ? "release" : "press";
     const char* fakedString = faked == EventFaked ? " (faked)" : "";
-    m_events.append(String::format("sendKeyEventWithCompositionResults type=%s keycode=%u%s", eventType, event->keyval, fakedString));
+    m_events.append(String::format("sendKeyEventWithCompositionResults type=%s keycode=%x%s", eventType, event->keyval, fakedString));
 
     if (resultsToSend & Composition && !m_confirmedComposition.isNull())
         logConfirmCompositionForTesting();
index 030adb2..376ed09 100644 (file)
@@ -1,5 +1,26 @@
 2017-08-31  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        [GTK] Several InputMethodFilter tests are failing and crashing
+        https://bugs.webkit.org/show_bug.cgi?id=176158
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        This started to happen after the GTK+ upgrade from 3.16 to 3.22 in the internal jhbuild. Now, GtkIMContext
+        doesn't emit the preedit signals when using the compose key (GDK_KEY_Multi_key). The composition results are
+        committed directly when they are ready. The test InputMethodFilterComposeKey was failing because it expected
+        preedit events that no longer happen. Tests InputMethodFilterContextFocusOutDuringOngoingComposition and
+        InputMethodFilterContextMouseClickDuringOngoingComposition were crashing because InputMethodFilter::confirmCurrentComposition()
+        accessed the WebPageProxy unconditionally, that is not available in testing mode. I wonder how this ever
+        worked. Other tests results have also been updated because logHandleKeyboardEventWithCompositionResultsForTesting()
+        now uses hexadecimal numbers for the key codes, for consistency with all other event logs.
+
+        * TestWebKitAPI/Tests/WebKit/gtk/InputMethodFilter.cpp:
+        (TestWebKitAPI::TestInputMethodFilter::TestInputMethodFilter):
+        (TestWebKitAPI::TEST):
+        (TestWebKitAPI::verifyCanceledComposition): Deleted.
+
+2017-08-31  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         [GTK][Wayland] Crash when gdk_keymap_get_entries_for_keyval returns TRUE but n_keys=0
         https://bugs.webkit.org/show_bug.cgi?id=176154
 
index 2de790f..979df01 100644 (file)
@@ -128,19 +128,19 @@ TEST(WebKit2, InputMethodFilterUnicodeSequence)
     ASSERT_EQ(21, events.size());
     ASSERT_EQ(String("sendSimpleKeyEvent type=press keycode=ffe3"), events[0]);
     ASSERT_EQ(String("sendSimpleKeyEvent type=press keycode=ffe1"), events[1]);
-    ASSERT_EQ(String("sendKeyEventWithCompositionResults type=press keycode=85"), events[2]);
+    ASSERT_EQ(String("sendKeyEventWithCompositionResults type=press keycode=55"), events[2]);
     ASSERT_EQ(String("setPreedit text='u' cursorOffset=1"), events[3]);
     ASSERT_EQ(String("sendSimpleKeyEvent type=release keycode=55"), events[4]);
-    ASSERT_EQ(String("sendKeyEventWithCompositionResults type=press keycode=48"), events[5]);
+    ASSERT_EQ(String("sendKeyEventWithCompositionResults type=press keycode=30"), events[5]);
     ASSERT_EQ(String("setPreedit text='u0' cursorOffset=2"), events[6]);
     ASSERT_EQ(String("sendSimpleKeyEvent type=release keycode=30"), events[7]);
-    ASSERT_EQ(String("sendKeyEventWithCompositionResults type=press keycode=48"), events[8]);
+    ASSERT_EQ(String("sendKeyEventWithCompositionResults type=press keycode=30"), events[8]);
     ASSERT_EQ(String("setPreedit text='u00' cursorOffset=3"), events[9]);
     ASSERT_EQ(String("sendSimpleKeyEvent type=release keycode=30"), events[10]);
-    ASSERT_EQ(String("sendKeyEventWithCompositionResults type=press keycode=70"), events[11]);
+    ASSERT_EQ(String("sendKeyEventWithCompositionResults type=press keycode=46"), events[11]);
     ASSERT_EQ(String("setPreedit text='u00F' cursorOffset=4"), events[12]);
     ASSERT_EQ(String("sendSimpleKeyEvent type=release keycode=46"), events[13]);
-    ASSERT_EQ(String("sendKeyEventWithCompositionResults type=press keycode=52"), events[14]);
+    ASSERT_EQ(String("sendKeyEventWithCompositionResults type=press keycode=34"), events[14]);
     ASSERT_EQ(String("setPreedit text='u00F4' cursorOffset=5"), events[15]);
     ASSERT_EQ(String("sendSimpleKeyEvent type=release keycode=34"), events[16]);
     ASSERT_EQ(String("confirmComposition 'ô'"), events[17]);
@@ -158,12 +158,10 @@ TEST(WebKit2, InputMethodFilterComposeKey)
     inputMethodFilter.sendPressAndReleaseKeyEventPairToFilter(GDK_KEY_o);
 
     const Vector<String>& events = inputMethodFilter.events();
-    ASSERT_EQ(5, events.size());
-    ASSERT_EQ(String("sendKeyEventWithCompositionResults type=press keycode=39"), events[0]);
-    ASSERT_EQ(String("setPreedit text='' cursorOffset=0"), events[1]);
-    ASSERT_EQ(String("sendSimpleKeyEvent type=release keycode=27"), events[2]);
-    ASSERT_EQ(String("sendSimpleKeyEvent type=press keycode=6f text='ó'"), events[3]);
-    ASSERT_EQ(String("sendSimpleKeyEvent type=release keycode=6f"), events[4]);
+    ASSERT_EQ(3, events.size());
+    ASSERT_EQ(String("sendKeyEventWithCompositionResults type=press keycode=6f"), events[0]);
+    ASSERT_EQ(String("confirmComposition 'ó'"), events[1]);
+    ASSERT_EQ(String("sendSimpleKeyEvent type=release keycode=6f"), events[2]);
 }
 
 typedef void (*GetPreeditStringCallback) (GtkIMContext*, gchar**, PangoAttrList**, int*);
@@ -191,10 +189,10 @@ TEST(WebKit2, InputMethodFilterContextEventsWithoutKeyEvents)
 
     const Vector<String>& events = inputMethodFilter.events();
     ASSERT_EQ(6, events.size());
-    ASSERT_EQ(String("sendKeyEventWithCompositionResults type=press keycode=16777215 (faked)"), events[0]);
+    ASSERT_EQ(String("sendKeyEventWithCompositionResults type=press keycode=ffffff (faked)"), events[0]);
     ASSERT_EQ(String("setPreedit text='preedit of doom, bringer of cheese' cursorOffset=3"), events[1]);
     ASSERT_EQ(String("sendSimpleKeyEvent type=release keycode=ffffff (faked)"), events[2]);
-    ASSERT_EQ(String("sendKeyEventWithCompositionResults type=press keycode=16777215 (faked)"), events[3]);
+    ASSERT_EQ(String("sendKeyEventWithCompositionResults type=press keycode=ffffff (faked)"), events[3]);
     ASSERT_EQ(String("confirmComposition 'commit text'"), events[4]);
     ASSERT_EQ(String("sendSimpleKeyEvent type=release keycode=ffffff (faked)"), events[5]);
 }
@@ -206,15 +204,6 @@ static void temporaryResetOverride(GtkIMContext*)
     gSawContextReset = true;
 }
 
-static void verifyCanceledComposition(const Vector<String>& events)
-{
-    ASSERT_EQ(3, events.size());
-    ASSERT_EQ(String("sendKeyEventWithCompositionResults type=press keycode=39"), events[0]);
-    ASSERT_EQ(String("setPreedit text='' cursorOffset=0"), events[1]);
-    ASSERT_EQ(String("sendSimpleKeyEvent type=release keycode=27"), events[2]);
-    ASSERT(gSawContextReset);
-}
-
 TEST(WebKit2, InputMethodFilterContextFocusOutDuringOngoingComposition)
 {
     TestInputMethodFilter inputMethodFilter;
@@ -229,8 +218,7 @@ TEST(WebKit2, InputMethodFilterContextFocusOutDuringOngoingComposition)
     inputMethodFilter.sendPressAndReleaseKeyEventPairToFilter(GDK_KEY_Multi_key);
     inputMethodFilter.sendPressAndReleaseKeyEventPairToFilter(GDK_KEY_apostrophe);
     inputMethodFilter.notifyFocusedOut();
-
-    verifyCanceledComposition(inputMethodFilter.events());
+    ASSERT_TRUE(gSawContextReset);
 
     contextClass->reset = previousCallback;
 }
@@ -249,8 +237,7 @@ TEST(WebKit2, InputMethodFilterContextMouseClickDuringOngoingComposition)
     inputMethodFilter.sendPressAndReleaseKeyEventPairToFilter(GDK_KEY_Multi_key);
     inputMethodFilter.sendPressAndReleaseKeyEventPairToFilter(GDK_KEY_apostrophe);
     inputMethodFilter.notifyMouseButtonPress();
-
-    verifyCanceledComposition(inputMethodFilter.events());
+    ASSERT_TRUE(gSawContextReset);
 
     contextClass->reset = previousCallback;
 }