⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 264647 in webkit


Ignore:
Timestamp:
Jul 21, 2020, 1:08:18 AM (6 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Prepare unit tests for GTK4
​https://bugs.webkit.org/show_bug.cgi?id=214251

Reviewed by Adrian Perez de Castro.

Source/WebKit:

Make it possible to test input methods.

  • UIProcess/API/glib/InputMethodFilter.h:
  • UIProcess/API/gtk/InputMethodFilterGtk.cpp:

(WebKit::InputMethodFilter::filterKeyEvent): Added to receive the key event properties instead of the GdkEvent.

  • UIProcess/API/gtk/WebKitWebViewBase.cpp:

(webkitWebViewBaseSynthesizeMouseEvent): Create a GdkEvent for right clicks since it's needed by GTK3 API.
(webkitWebViewBaseSynthesizeKeyEvent): Send key press and release events to the IM filter.

Tools:

In GTK4 there isn't GTK_WINDOW_POPUP and we can't create GdkEvents, so we need to use toplevel windows
everywhere and use the new internal api to synthesize events.

  • TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp:

(testContextMenuDownloadActions):
(testBlobDownload):

  • TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp:
  • TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp:

(testOptionMenuSimple):
(testOptionMenuGroups):
(testOptionMenuActivate):
(testOptionMenuSelect):

  • TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp:

(testWebViewCreateNavigationData):
(testWebViewJavaScriptDialogs):
(testWebViewOpenWindowNoDefaultSize):
(testWebViewMouseTarget):
(testWebViewGeolocationPermissionRequests):
(testWebViewUserMediaEnumerateDevicesPermissionCheck):
(testWebViewUserMediaPermissionRequests):
(testWebViewAudioOnlyUserMediaPermissionRequests):
(testWebViewPointerLockPermissionRequest):
(testWebViewFileChooserRequest):
(testWebViewColorChooserRequest):

  • TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp:

(testWebExtensionInputElementIsUserEdited):
(testInstallMissingPluginsPermissionRequest):

  • TestWebKitAPI/Tests/WebKitGLib/TestWebKitFindController.cpp:

(testFindControllerHide):

  • TestWebKitAPI/Tests/WebKitGLib/TestWebKitPolicyClient.cpp:

(testAutoplayPolicy):

  • TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:

(testWebViewFullScreen):
(testWebViewSubmitForm):
(testWebViewSnapshot):
(testWebViewIsPlayingAudio):
(testWebViewPreferredSize):

  • TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp:

(testContextMenuDefaultMenu):
(testPopupEventSignal):
(testContextMenuKey):
(testContextMenuPopulateMenu):
(testContextMenuCustomMenu):
(testContextMenuSubMenu):
(testContextMenuDismissed):
(testContextMenuWebExtensionMenu):
(testContextMenuWebExtensionNode):
(testContextMenuLiveStream):
(beforeAll):

  • TestWebKitAPI/Tests/WebKitGtk/TestDOMDOMWindow.cpp:

(signalsNotifyCallback):

  • TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp:

(testInspectorDefault):
(testInspectorManualAttachDetach):
(testInspectorCustomContainerDestroyed):

  • TestWebKitAPI/Tests/WebKitGtk/TestInspectorServer.cpp:

(testInspectorServerPageList):

  • TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp:

(testPrintCustomWidget):

  • TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp:
  • TestWebKitAPI/glib/WebKitGLib/WebViewTest.h:
  • TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp:

(WebViewTest::quitMainLoopAfterProcessingPendingEvents):
(WebViewTest::showInWindow):
(WebViewTest::mouseMoveTo):
(WebViewTest::clickMouseButton):
(WebViewTest::keyStroke):

  • TestWebKitAPI/glib/WebKitGLib/wpe/WebViewTestWPE.cpp:

(WebViewTest::showInWindow):

  • TestWebKitAPI/gtk/PlatformWebViewGtk.cpp:

(TestWebKitAPI::toWebKitGLibAPI):
(TestWebKitAPI::PlatformWebView::simulateSpacebarKeyPress):
(TestWebKitAPI::PlatformWebView::simulateAltKeyPress):
(TestWebKitAPI::PlatformWebView::simulateRightClick):
(TestWebKitAPI::PlatformWebView::simulateMouseMove):

Location:
trunk
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r264637 r264647  
     12020-07-21  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Prepare unit tests for GTK4
     4        https://bugs.webkit.org/show_bug.cgi?id=214251
     5
     6        Reviewed by Adrian Perez de Castro.
     7
     8        Make it possible to test input methods.
     9
     10        * UIProcess/API/glib/InputMethodFilter.h:
     11        * UIProcess/API/gtk/InputMethodFilterGtk.cpp:
     12        (WebKit::InputMethodFilter::filterKeyEvent): Added to receive the key event properties instead of the GdkEvent.
     13        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
     14        (webkitWebViewBaseSynthesizeMouseEvent): Create a GdkEvent for right clicks since it's needed by GTK3 API.
     15        (webkitWebViewBaseSynthesizeKeyEvent): Send key press and release events to the IM filter.
     16
    1172020-07-20  Megan Gardner  <megan_gardner@apple.com>
    218
  • trunk/Source/WebKit/UIProcess/API/glib/InputMethodFilter.h

    r260752 r264647  
    6868    FilterResult filterKeyEvent(PlatformEventKey*);
    6969
     70#if PLATFORM(GTK)
     71    FilterResult filterKeyEvent(unsigned type, unsigned keyval, unsigned keycode, unsigned modifiers);
     72#endif
     73
    7074    void notifyFocusedIn();
    7175    void notifyFocusedOut();
  • trunk/Source/WebKit/UIProcess/API/gtk/InputMethodFilterGtk.cpp

    r260752 r264647  
    2222
    2323#include "WebKitInputMethodContextPrivate.h"
     24#include <WebCore/GUniquePtrGtk.h>
    2425#include <WebCore/IntRect.h>
    2526#include <gdk/gdk.h>
    … …  
    4243}
    4344
     45InputMethodFilter::FilterResult InputMethodFilter::filterKeyEvent(unsigned type, unsigned keyval, unsigned keycode, unsigned modifiers)
     46{
     47    if (!isEnabled() || !m_context)
     48        return { };
     49
     50#if !USE(GTK4)
     51    auto* webView = webkitInputMethodContextGetWebView(m_context.get());
     52    ASSERT(webView);
     53
     54    GUniquePtr<GdkEvent> event(gdk_event_new(static_cast<GdkEventType>(type)));
     55    event->key.window = gtk_widget_get_window(GTK_WIDGET(webView));
     56    g_object_ref(event->key.window);
     57    event->key.time = GDK_CURRENT_TIME;
     58    event->key.keyval = keyval;
     59    event->key.hardware_keycode = keycode;
     60    event->key.state = modifiers;
     61    gdk_event_set_device(event.get(), gdk_seat_get_keyboard(gdk_display_get_default_seat(gtk_widget_get_display(GTK_WIDGET(webView)))));
     62    return filterKeyEvent(event.get());
     63#else
     64    return { };
     65#endif
     66}
     67
    4468} // namespace WebKit
  • trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp

    r263887 r264647  
    25462546        webEventType = WebEvent::MouseDown;
    25472547        priv->inputMethodFilter.cancelComposition();
     2548#if !USE(GTK4)
     2549        if (webEventButton == WebMouseEvent::RightButton) {
     2550            GUniquePtr<GdkEvent> event(gdk_event_new(GDK_BUTTON_PRESS));
     2551            event->button.window = gtk_widget_get_window(GTK_WIDGET(webViewBase));
     2552            g_object_ref(event->button.window);
     2553            event->button.time = GDK_CURRENT_TIME;
     2554            event->button.x = x;
     2555            event->button.y = y;
     2556            event->button.axes = 0;
     2557            event->button.state = modifiers;
     2558            event->button.button = button;
     2559            event->button.device = gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(GTK_WIDGET(webViewBase))));
     2560            int xRoot, yRoot;
     2561            gdk_window_get_root_coords(event->button.window, x, y, &xRoot, &yRoot);
     2562            event->button.x_root = xRoot;
     2563            event->button.y_root = yRoot;
     2564            priv->contextMenuEvent = WTFMove(event);
     2565        }
     2566#endif
    25482567        gtk_widget_grab_focus(GTK_WIDGET(webViewBase));
    25492568        break;
    … …  
    26042623
    26052624#if !USE(GTK4)
     2625        if (priv->activeContextMenuProxy && keyval == GDK_KEY_Escape) {
     2626            gtk_menu_shell_deactivate(GTK_MENU_SHELL(priv->activeContextMenuProxy->gtkWidget()));
     2627            return;
     2628        }
     2629
    26062630        if (keyval == GDK_KEY_Menu) {
    2607             webkitWebViewBasePopupMenu(GTK_WIDGET(webViewBase));
     2631            GUniquePtr<GdkEvent> event(gdk_event_new(GDK_KEY_PRESS));
     2632            event->key.window = gtk_widget_get_window(GTK_WIDGET(webViewBase));
     2633            g_object_ref(event->key.window);
     2634            event->key.time = GDK_CURRENT_TIME;
     2635            event->key.keyval = keyval;
     2636            event->key.state = modifiers;
     2637            gdk_event_set_device(event.get(), gdk_seat_get_keyboard(gdk_display_get_default_seat(gtk_widget_get_display(GTK_WIDGET(webViewBase)))));
     2638            priv->contextMenuEvent = WTFMove(event);
     2639            priv->pageProxy->handleContextMenuKeyEvent();
    26082640            return;
    26092641        }
    … …  
    26232655
    26242656    if (type != KeyEventType::Release) {
    2625         priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(
    2626             WebEvent::KeyDown,
    2627             PlatformKeyboardEvent::singleCharacterString(keyval),
    2628             PlatformKeyboardEvent::keyValueForGdkKeyCode(keyval),
    2629             PlatformKeyboardEvent::keyCodeForHardwareKeyCode(keycode),
    2630             PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyval),
    2631             PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(keyval),
    2632             static_cast<int>(keyval),
    2633             priv->keyBindingTranslator.commandsForKeyval(keyval, modifiers),
    2634             keyval >= GDK_KEY_KP_Space && keyval <= GDK_KEY_KP_9,
    2635             webEventModifiers));
     2657        auto filterResult = priv->inputMethodFilter.filterKeyEvent(GDK_KEY_PRESS, keyval, keycode, modifiers);
     2658        if (!filterResult.handled) {
     2659            priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(
     2660                WebEvent::KeyDown,
     2661                filterResult.keyText.isNull() ? PlatformKeyboardEvent::singleCharacterString(keyval) : filterResult.keyText,
     2662                PlatformKeyboardEvent::keyValueForGdkKeyCode(keyval),
     2663                PlatformKeyboardEvent::keyCodeForHardwareKeyCode(keycode),
     2664                PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyval),
     2665                PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(keyval),
     2666                static_cast<int>(keyval),
     2667                priv->keyBindingTranslator.commandsForKeyval(keyval, modifiers),
     2668                keyval >= GDK_KEY_KP_Space && keyval <= GDK_KEY_KP_9,
     2669                webEventModifiers));
     2670        }
    26362671    }
    26372672
    26382673    if (type != KeyEventType::Press) {
    2639         priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(
    2640             WebEvent::KeyUp,
    2641             PlatformKeyboardEvent::singleCharacterString(keyval),
    2642             PlatformKeyboardEvent::keyValueForGdkKeyCode(keyval),
    2643             PlatformKeyboardEvent::keyCodeForHardwareKeyCode(keycode),
    2644             PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyval),
    2645             PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(keyval),
    2646             static_cast<int>(keyval),
    2647             { },
    2648             keyval >= GDK_KEY_KP_Space && keyval <= GDK_KEY_KP_9,
    2649             webEventModifiers));
     2674        if (!priv->inputMethodFilter.filterKeyEvent(GDK_KEY_RELEASE, keyval, keycode, modifiers).handled) {
     2675            priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(
     2676                WebEvent::KeyUp,
     2677                PlatformKeyboardEvent::singleCharacterString(keyval),
     2678                PlatformKeyboardEvent::keyValueForGdkKeyCode(keyval),
     2679                PlatformKeyboardEvent::keyCodeForHardwareKeyCode(keycode),
     2680                PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyval),
     2681                PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(keyval),
     2682                static_cast<int>(keyval),
     2683                { },
     2684                keyval >= GDK_KEY_KP_Space && keyval <= GDK_KEY_KP_9,
     2685                webEventModifiers));
     2686        }
    26502687    }
    26512688}
  • trunk/Tools/ChangeLog

    r264626 r264647  
     12020-07-21  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Prepare unit tests for GTK4
     4        https://bugs.webkit.org/show_bug.cgi?id=214251
     5
     6        Reviewed by Adrian Perez de Castro.
     7
     8        In GTK4 there isn't GTK_WINDOW_POPUP and we can't create GdkEvents, so we need to use toplevel windows
     9        everywhere and use the new internal api to synthesize events.
     10
     11        * TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp:
     12        (testContextMenuDownloadActions):
     13        (testBlobDownload):
     14        * TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp:
     15        * TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp:
     16        (testOptionMenuSimple):
     17        (testOptionMenuGroups):
     18        (testOptionMenuActivate):
     19        (testOptionMenuSelect):
     20        * TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp:
     21        (testWebViewCreateNavigationData):
     22        (testWebViewJavaScriptDialogs):
     23        (testWebViewOpenWindowNoDefaultSize):
     24        (testWebViewMouseTarget):
     25        (testWebViewGeolocationPermissionRequests):
     26        (testWebViewUserMediaEnumerateDevicesPermissionCheck):
     27        (testWebViewUserMediaPermissionRequests):
     28        (testWebViewAudioOnlyUserMediaPermissionRequests):
     29        (testWebViewPointerLockPermissionRequest):
     30        (testWebViewFileChooserRequest):
     31        (testWebViewColorChooserRequest):
     32        * TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp:
     33        (testWebExtensionInputElementIsUserEdited):
     34        (testInstallMissingPluginsPermissionRequest):
     35        * TestWebKitAPI/Tests/WebKitGLib/TestWebKitFindController.cpp:
     36        (testFindControllerHide):
     37        * TestWebKitAPI/Tests/WebKitGLib/TestWebKitPolicyClient.cpp:
     38        (testAutoplayPolicy):
     39        * TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:
     40        (testWebViewFullScreen):
     41        (testWebViewSubmitForm):
     42        (testWebViewSnapshot):
     43        (testWebViewIsPlayingAudio):
     44        (testWebViewPreferredSize):
     45        * TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp:
     46        (testContextMenuDefaultMenu):
     47        (testPopupEventSignal):
     48        (testContextMenuKey):
     49        (testContextMenuPopulateMenu):
     50        (testContextMenuCustomMenu):
     51        (testContextMenuSubMenu):
     52        (testContextMenuDismissed):
     53        (testContextMenuWebExtensionMenu):
     54        (testContextMenuWebExtensionNode):
     55        (testContextMenuLiveStream):
     56        (beforeAll):
     57        * TestWebKitAPI/Tests/WebKitGtk/TestDOMDOMWindow.cpp:
     58        (signalsNotifyCallback):
     59        * TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp:
     60        (testInspectorDefault):
     61        (testInspectorManualAttachDetach):
     62        (testInspectorCustomContainerDestroyed):
     63        * TestWebKitAPI/Tests/WebKitGtk/TestInspectorServer.cpp:
     64        (testInspectorServerPageList):
     65        * TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp:
     66        (testPrintCustomWidget):
     67        * TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp:
     68        * TestWebKitAPI/glib/WebKitGLib/WebViewTest.h:
     69        * TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp:
     70        (WebViewTest::quitMainLoopAfterProcessingPendingEvents):
     71        (WebViewTest::showInWindow):
     72        (WebViewTest::mouseMoveTo):
     73        (WebViewTest::clickMouseButton):
     74        (WebViewTest::keyStroke):
     75        * TestWebKitAPI/glib/WebKitGLib/wpe/WebViewTestWPE.cpp:
     76        (WebViewTest::showInWindow):
     77        * TestWebKitAPI/gtk/PlatformWebViewGtk.cpp:
     78        (TestWebKitAPI::toWebKitGLibAPI):
     79        (TestWebKitAPI::PlatformWebView::simulateSpacebarKeyPress):
     80        (TestWebKitAPI::PlatformWebView::simulateAltKeyPress):
     81        (TestWebKitAPI::PlatformWebView::simulateRightClick):
     82        (TestWebKitAPI::PlatformWebView::simulateMouseMove):
     83
    1842020-07-20  Aakash Jain  <aakash_jain@apple.com>
    285
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp

    r258698 r264647  
    560560    }
    561561
     562#if PLATFORM(GTK)
     563    static gboolean contextMenuCallback(WebKitWebView* webView, WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult* hitTestResult, WebViewDownloadTest* test)
     564    {
     565        g_assert_true(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult));
     566        GList* items = webkit_context_menu_get_items(contextMenu);
     567        for (GList* l = items; l; l = g_list_next(l)) {
     568            g_assert_true(WEBKIT_IS_CONTEXT_MENU_ITEM(l->data));
     569            auto* item = WEBKIT_CONTEXT_MENU_ITEM(l->data);
     570            if (webkit_context_menu_item_get_stock_action(item) == WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_LINK_TO_DISK) {
     571                test->m_contextMenuDownloadItem = item;
     572                break;
     573            }
     574        }
     575        test->quitMainLoop();
     576        return FALSE;
     577    }
     578
     579    WebKitContextMenuItem* showContextMenuAndGetDownloadItem(int x, int y)
     580    {
     581        m_contextMenuDownloadItem = nullptr;
     582        auto id = g_signal_connect(m_webView, "context-menu", G_CALLBACK(contextMenuCallback), this);
     583        RunLoop::main().dispatch([this, x, y] {
     584            clickMouseButton(x, y, 3);
     585        });
     586        g_main_loop_run(m_mainLoop);
     587        g_signal_handler_disconnect(m_webView, id);
     588        return m_contextMenuDownloadItem.get();
     589    }
     590#endif
     591
    562592    GRefPtr<WebKitDownload> m_download;
    563593    bool m_shouldDelayDecideDestination { false };
     594#if PLATFORM(GTK)
     595    GRefPtr<WebKitContextMenuItem> m_contextMenuDownloadItem;
     596#endif
    564597};
    565598
    … …  
    690723
    691724#if PLATFORM(GTK)
    692 static gboolean contextMenuCallback(WebKitWebView* webView, WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult* hitTestResult, WebViewDownloadTest* test)
    693 {
    694     g_assert_true(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult));
    695     g_assert_true(webkit_hit_test_result_context_is_link(hitTestResult));
    696     GList* items = webkit_context_menu_get_items(contextMenu);
    697     GRefPtr<WebKitContextMenuItem> contextMenuItem;
    698     for (GList* l = items; l; l = g_list_next(l)) {
    699         g_assert_true(WEBKIT_IS_CONTEXT_MENU_ITEM(l->data));
    700         auto* item = WEBKIT_CONTEXT_MENU_ITEM(l->data);
    701         if (webkit_context_menu_item_get_stock_action(item) == WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_LINK_TO_DISK) {
    702             contextMenuItem = item;
    703             break;
    704         }
    705     }
    706     g_assert_nonnull(contextMenuItem.get());
    707     webkit_context_menu_remove_all(contextMenu);
    708     webkit_context_menu_append(contextMenu, contextMenuItem.get());
    709     test->quitMainLoop();
    710     return FALSE;
    711 }
    712 
    713725static void testContextMenuDownloadActions(WebViewDownloadTest* test, gconstpointer)
    714726{
    715     test->showInWindowAndWaitUntilMapped();
     727    test->showInWindow();
    716728
    717729    static const char* linkHTMLFormat = "<html><body><a style='position:absolute; left:1; top:1' href='%s'>Download Me</a></body></html>";
    … …  
    720732    test->waitUntilLoadFinished();
    721733
    722     g_signal_connect(test->m_webView, "context-menu", G_CALLBACK(contextMenuCallback), test);
    723     g_idle_add([](gpointer userData) -> gboolean {
    724         auto* test = static_cast<WebViewDownloadTest*>(userData);
    725         test->clickMouseButton(1, 1, 3);
    726         return FALSE;
    727     }, test);
    728     g_main_loop_run(test->m_mainLoop);
    729 
    730     g_idle_add([](gpointer userData) -> gboolean {
    731         auto* test = static_cast<WebViewDownloadTest*>(userData);
    732         // Select and activate the context menu action.
    733         test->keyStroke(GDK_KEY_Down);
    734         test->keyStroke(GDK_KEY_Return);
    735         return FALSE;
    736     }, test);
     734    auto* item = test->showContextMenuAndGetDownloadItem(1, 1);
     735    g_assert(WEBKIT_IS_CONTEXT_MENU_ITEM(item));
     736    g_action_activate(webkit_context_menu_item_get_gaction(item), nullptr);
    737737    test->waitUntilDownloadStarted();
    738738
    … …  
    756756static void testBlobDownload(WebViewDownloadTest* test, gconstpointer)
    757757{
    758     test->showInWindowAndWaitUntilMapped();
     758    test->showInWindow();
    759759
    760760    static const char* linkBlobHTML =
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp

    r258131 r264647  
    251251        : m_context(adoptGRef(static_cast<WebKitInputMethodContextMock*>(g_object_new(webkit_input_method_context_mock_get_type(), nullptr))))
    252252    {
     253        WebViewTest::showInWindow();
    253254#if PLATFORM(GTK)
    254         WebViewTest::showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
    255255        auto* defaultContext = webkit_web_view_get_input_method_context(m_webView);
    256256        g_assert_true(WEBKIT_IS_INPUT_METHOD_CONTEXT(defaultContext));
    257257        assertObjectIsDeletedWhenTestFinishes(G_OBJECT(defaultContext));
    258258#elif PLATFORM(WPE)
    259         WebViewTest::showInWindow();
    260259        g_assert_null(webkit_web_view_get_input_method_context(m_webView));
    261260#endif
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp

    r254828 r264647  
    123123        "    <option disabled>Baz</option>"
    124124        "  </select></body></html>";
    125     test->showInWindowAndWaitUntilMapped();
     125    test->showInWindow();
    126126    test->loadHtml(html, nullptr);
    127127    test->waitUntilLoadFinished();
    … …  
    172172        "    <option>Tail</option>"
    173173        "  </select></body></html>";
    174     test->showInWindowAndWaitUntilMapped();
     174    test->showInWindow();
    175175    test->loadHtml(html, nullptr);
    176176    test->waitUntilLoadFinished();
    … …  
    246246        "    <option>Baz</option>"
    247247        "  </select></body></html>";
    248     test->showInWindowAndWaitUntilMapped();
     248    test->showInWindow();
    249249    test->loadHtml(html, nullptr);
    250250    test->waitUntilLoadFinished();
    … …  
    276276        "    <option>Baz</option>"
    277277        "  </select></body></html>";
    278     test->showInWindowAndWaitUntilMapped();
     278    test->showInWindow();
    279279    test->loadHtml(html, nullptr);
    280280    test->waitUntilLoadFinished();
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp

    r261473 r264647  
    482482static void testWebViewCreateNavigationData(CreateNavigationDataTest* test, gconstpointer)
    483483{
    484 #if PLATFORM(GTK)
    485     test->showInWindowAndWaitUntilMapped();
    486 #endif
    487 
     484    test->showInWindow();
    488485    test->loadHTML(
    489486        "<html><body>"
    … …  
    591588static void testWebViewJavaScriptDialogs(UIClientTest* test, gconstpointer)
    592589{
    593 #if PLATFORM(GTK)
    594     test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
    595 #endif
     590    test->showInWindow();
    596591
    597592    static const char* htmlOnLoadFormat = "<html><body onLoad=\"%s\"></body></html>";
    … …  
    722717    // on the create signal, then new windows open with the size of the previous window.
    723718    cairo_rectangle_int_t expectedGeometry = { 0, 0, 527, 671 };
    724     test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL, expectedGeometry.width, expectedGeometry.height);
     719    test->showInWindow(expectedGeometry.width, expectedGeometry.height);
    725720    test->setExpectedWindowProperties(UIClientTest::WindowProperties(&expectedGeometry, false, false, false, false, false, true, false));
    726721    test->loadHtml("<html><body onLoad=\"window.open('', '', 'left=0,top=0,location=no,menubar=no,status=no,toolbar=no,scrollbars=no').close();\"></body></html>", nullptr);
    … …  
    732727static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
    733728{
    734     test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
     729    test->showInWindow();
    735730
    736731    const char* linksHoveredHTML =
    … …  
    851846    // Make warnings non-fatal for this test to make it pass.
    852847    Test::removeLogFatalFlag(G_LOG_LEVEL_WARNING);
    853 #if PLATFORM(GTK)
    854     test->showInWindowAndWaitUntilMapped();
    855 #endif
     848    test->showInWindow();
    856849    static const char* geolocationRequestHTML =
    857850        "<html>"
    … …  
    899892    webkit_settings_set_enable_mock_capture_devices(settings, TRUE);
    900893
    901 #if PLATFORM(GTK)
    902     test->showInWindowAndWaitUntilMapped();
    903 #endif
     894    test->showInWindow();
    904895    static const char* userMediaRequestHTML =
    905896        "<html>"
    … …  
    944935    webkitSettingsSetMediaCaptureRequiresSecureConnection(settings, FALSE);
    945936
    946 #if PLATFORM(GTK)
    947     test->showInWindowAndWaitUntilMapped();
    948 #endif
     937    test->showInWindow();
    949938    static const char* userMediaRequestHTML = "<html>"
    950939        "  <script>"
    … …  
    986975    webkitSettingsSetMediaCaptureRequiresSecureConnection(settings, FALSE);
    987976
    988 #if PLATFORM(GTK)
    989     test->showInWindowAndWaitUntilMapped();
    990 #endif
     977    test->showInWindow();
    991978    static const char* userMediaRequestHTML = "<html>"
    992979        "  <script>"
    … …  
    10191006static void testWebViewPointerLockPermissionRequest(UIClientTest* test, gconstpointer)
    10201007{
    1021 #if PLATFORM(GTK)
    1022     test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
    1023 #endif
    1024 
     1008    test->showInWindow();
    10251009    static const char* pointerLockRequestHTML =
    10261010        "<html>"
    … …  
    10901074static void testWebViewFileChooserRequest(FileChooserTest* test, gconstpointer)
    10911075{
    1092 #if PLATFORM(GTK)
    1093     test->showInWindowAndWaitUntilMapped();
    1094 #endif
     1076    test->showInWindow();
    10951077    static const char* fileChooserHTMLFormat = "<html><body><input style='position:absolute;left:0;top:0;margin:0;padding:0' type='file' %s/></body></html>";
    10961078
    … …  
    12411223{
    12421224    static const char* colorChooserHTMLFormat = "<html><body><input style='position:absolute;left:1;top:1;margin:0;padding:0;width:45;height:25' type='color' %s/></body></html>";
    1243     test->showInWindowAndWaitUntilMapped();
     1225    test->showInWindow();
    12441226
    12451227    GUniquePtr<char> defaultColorHTML(g_strdup_printf(colorChooserHTMLFormat, ""));
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp

    r251181 r264647  
    7474static void testWebExtensionInputElementIsUserEdited(WebViewTest* test, gconstpointer)
    7575{
    76     test->showInWindowAndWaitUntilMapped();
     76    test->showInWindow();
    7777    test->loadHtml("<html><body id='body'><input id='input'></input><textarea id='textarea'></textarea></body></html>", nullptr);
    7878    test->waitUntilLoadFinished();
    … …  
    263263        nullptr, G_DBUS_CALL_FLAGS_NONE, -1, nullptr, nullptr));
    264264
    265     test->showInWindowAndWaitUntilMapped();
     265    test->showInWindow();
    266266
    267267    gulong permissionRequestSignalID = g_signal_connect(test->m_webView, "permission-request", G_CALLBACK(permissionRequestCallback), test);
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitFindController.cpp

    r239772 r264647  
    266266    test->waitUntilLoadFinished();
    267267
    268     test->showInWindowAndWaitUntilMapped();
     268    test->showInWindow();
    269269
    270270    cairo_surface_t* originalSurface = cairo_surface_reference(
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitPolicyClient.cpp

    r263095 r264647  
    312312static void testAutoplayPolicy(PolicyClientTest* test, gconstpointer)
    313313{
    314 #if PLATFORM(GTK)
    315314    // The web view must be realized for the video to start playback.
    316     test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
    317 #endif
     315    test->showInWindow();
    318316
    319317    test->m_policyDecisionTypeFilter = WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION;
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp

    r263095 r264647  
    465465static void testWebViewFullScreen(FullScreenClientTest* test, gconstpointer)
    466466{
    467 #if PLATFORM(GTK)
    468     test->showInWindowAndWaitUntilMapped();
    469 #endif
     467    test->showInWindow();
    470468    test->loadHtml("<html><body>FullScreen test</body></html>", 0);
    471469    test->waitUntilLoadFinished();
    … …  
    571569static void testWebViewSubmitForm(FormClientTest* test, gconstpointer)
    572570{
    573     test->showInWindowAndWaitUntilMapped();
     571    test->showInWindow();
    574572
    575573    const char* formHTML =
    … …  
    822820
    823821    // Show the WebView in a popup widow of 50x50 and try again with WEBKIT_SNAPSHOT_REGION_VISIBLE.
    824     test->showInWindowAndWaitUntilMapped(GTK_WINDOW_POPUP, 50, 50);
     822    test->showInWindow(50, 50);
    825823    surface1 = cairo_surface_reference(test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE));
    826824    g_assert_nonnull(surface1);
    … …  
    11071105static void testWebViewIsPlayingAudio(IsPlayingAudioWebViewTest* test, gconstpointer)
    11081106{
    1109 #if PLATFORM(GTK)
    11101107    // The web view must be realized for the video to start playback and
    11111108    // trigger changes in WebKitWebView::is-playing-audio.
    1112     test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
    1113 #endif
     1109    test->showInWindow();
    11141110
    11151111    // Initially, web views should always report no audio being played.
    … …  
    11971193    test->loadHtml("<html style='width: 325px; height: 615px'></html>", nullptr);
    11981194    test->waitUntilLoadFinished();
    1199     test->showInWindowAndWaitUntilMapped();
     1195    test->showInWindow();
    12001196    GtkRequisition minimunSize, naturalSize;
    12011197    gtk_widget_get_preferred_size(GTK_WIDGET(test->m_webView), &minimunSize, &naturalSize);
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp

    r261800 r264647  
    531531static void testContextMenuDefaultMenu(ContextMenuDefaultTest* test, gconstpointer)
    532532{
    533     test->showInWindowAndWaitUntilMapped();
    534 
     533    test->showInWindow();
    535534    prepareContextMenuTestView(test);
    536535
    … …  
    579578static void testPopupEventSignal(ContextMenuDefaultTest* test, gconstpointer)
    580579{
    581     test->showInWindowAndWaitUntilMapped();
    582 
     580    test->showInWindow();
    583581    prepareContextMenuTestView(test);
    584582
    … …  
    589587static void testContextMenuKey(ContextMenuDefaultTest* test, gconstpointer)
    590588{
    591     test->showInWindowAndWaitUntilMapped();
    592 
     589    test->showInWindow();
    593590    prepareContextMenuTestView(test);
    594591
    … …  
    747744static void testContextMenuPopulateMenu(ContextMenuCustomTest* test, gconstpointer)
    748745{
    749     test->showInWindowAndWaitUntilMapped();
    750 
     746    test->showInWindow();
    751747    test->loadHtml("<html><body>WebKitGTK Context menu tests</body></html>", "file:///");
    752748    test->waitUntilLoadFinished();
    … …  
    870866static void testContextMenuCustomMenu(ContextMenuCustomFullTest* test, gconstpointer)
    871867{
    872     test->showInWindowAndWaitUntilMapped();
    873 
     868    test->showInWindow();
    874869    test->loadHtml("<html><body>WebKitGTK Context menu tests</body></html>", "file:///");
    875870    test->waitUntilLoadFinished();
    876871
    877     test->showContextMenuAndWaitUntilFinished();
    878 }
    879 
    880 class ContextMenuDisabledTest: public ContextMenuTest {
    881 public:
    882     MAKE_GLIB_TEST_FIXTURE(ContextMenuDisabledTest);
    883 
    884     enum DisableMode {
    885         IgnoreClicks,
    886         IgnoreDefaultMenu
    887     };
    888 
    889     static gboolean buttonPressEventCallback(GtkWidget*, GdkEvent* event, ContextMenuDisabledTest* test)
    890     {
    891         if (event->button.button != 3)
    892             return FALSE;
    893         return test->rightButtonPressed();
    894     }
    895 
    896     ContextMenuDisabledTest()
    897         : m_disableMode(IgnoreClicks)
    898     {
    899         g_signal_connect(m_webView, "button-press-event", G_CALLBACK(buttonPressEventCallback), this);
    900     }
    901 
    902     bool contextMenu(WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult*)
    903     {
    904         if (m_disableMode == IgnoreClicks)
    905             g_assert_not_reached();
    906         else
    907             quitMainLoop();
    908 
    909         return true;
    910     }
    911 
    912     bool rightButtonPressed()
    913     {
    914         if (m_disableMode == IgnoreClicks) {
    915             quitMainLoopAfterProcessingPendingEvents();
    916             return true;
    917         }
    918         return false;
    919     }
    920 
    921     DisableMode m_disableMode;
    922 };
    923 
    924 static void testContextMenuDisableMenu(ContextMenuDisabledTest* test, gconstpointer)
    925 {
    926     test->showInWindowAndWaitUntilMapped();
    927 
    928     test->loadHtml("<html><body>WebKitGTK Context menu tests</body></html>", "file:///");
    929     test->waitUntilLoadFinished();
    930 
    931     test->m_disableMode = ContextMenuDisabledTest::IgnoreDefaultMenu;
    932     test->showContextMenuAndWaitUntilFinished();
    933 
    934     test->m_disableMode = ContextMenuDisabledTest::IgnoreClicks;
    935872    test->showContextMenuAndWaitUntilFinished();
    936873}
    … …  
    977914static void testContextMenuSubMenu(ContextMenuSubmenuTest* test, gconstpointer)
    978915{
    979     test->showInWindowAndWaitUntilMapped();
    980 
     916    test->showInWindow();
    981917    test->loadHtml("<html><body>WebKitGTK Context menu tests</body></html>", "file:///");
    982918    test->waitUntilLoadFinished();
    … …  
    1018954static void testContextMenuDismissed(ContextMenuDismissedTest* test, gconstpointer)
    1019955{
    1020     test->showInWindowAndWaitUntilMapped();
    1021 
     956    test->showInWindow();
    1022957    test->loadHtml("<html><body>WebKitGTK Context menu tests</body></html>", "file:///");
    1023958    test->waitUntilLoadFinished();
    … …  
    10681003static void testContextMenuWebExtensionMenu(ContextMenuWebExtensionTest* test, gconstpointer)
    10691004{
    1070     test->showInWindowAndWaitUntilMapped();
     1005    test->showInWindow();
    10711006    test->loadHtml("<html><body>WebKitGTK Context menu tests<br>"
    10721007        "<a style='position:absolute; left:1; top:10' href='http://www.webkitgtk.org'>WebKitGTK Website</a></body></html>",
    … …  
    11581093static void testContextMenuWebExtensionNode(ContextMenuWebExtensionNodeTest* test, gconstpointer)
    11591094{
    1160     test->showInWindowAndWaitUntilMapped();
     1095    test->showInWindow();
    11611096    test->loadHtml("<html><body><p style='position:absolute; left:1; top:1'>WebKitGTK Context menu tests</p><br>"
    11621097        "<a style='position:absolute; left:1; top:100' href='http://www.webkitgtk.org'>WebKitGTK Website</a></body></html>",
    … …  
    12281163static void testContextMenuLiveStream(ContextMenuDefaultTest* test, gconstpointer)
    12291164{
    1230     test->showInWindowAndWaitUntilMapped();
    1231 
     1165    test->showInWindow();
    12321166    test->loadURI(kServer->getURIForPath("/live-stream").data());
    12331167    test->waitUntilLoadFinished();
    … …  
    12481182    ContextMenuCustomTest::add("WebKitWebView", "populate-menu", testContextMenuPopulateMenu);
    12491183    ContextMenuCustomFullTest::add("WebKitWebView", "custom-menu", testContextMenuCustomMenu);
    1250     ContextMenuDisabledTest::add("WebKitWebView", "disable-menu", testContextMenuDisableMenu);
    12511184    ContextMenuSubmenuTest::add("WebKitWebView", "submenu", testContextMenuSubMenu);
    12521185    ContextMenuDismissedTest::add("WebKitWebView", "menu-dismissed", testContextMenuDismissed);
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestDOMDOMWindow.cpp

    r239772 r264647  
    4848    if (g_str_equal(key, "loaded")) {
    4949        status.loaded = TRUE;
    50         status.test->showInWindowAndWaitUntilMapped();
     50        status.test->showInWindow();
    5151
    5252        // Click in a known location where the text is
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp

    r246790 r264647  
    168168static void testInspectorDefault(InspectorTest* test, gconstpointer)
    169169{
    170     test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
     170    test->showInWindow();
    171171    test->resizeView(200, 200);
    172172    test->loadHtml("<html><body><p>WebKitGTK Inspector test</p></body></html>", 0);
    … …  
    299299static void testInspectorManualAttachDetach(CustomInspectorTest* test, gconstpointer)
    300300{
    301     test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
     301    test->showInWindow();
    302302    test->resizeView(200, 200);
    303303    test->loadHtml("<html><body><p>WebKitGTK Inspector test</p></body></html>", 0);
    … …  
    341341static void testInspectorCustomContainerDestroyed(CustomInspectorTest* test, gconstpointer)
    342342{
    343     test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
     343    test->showInWindow();
    344344    test->resizeView(200, 200);
    345345    test->loadHtml("<html><body><p>WebKitGTK Inspector test</p></body></html>", 0);
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestInspectorServer.cpp

    r264390 r264647  
    139139    GUniqueOutPtr<GError> error;
    140140
    141     test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
     141    test->showInWindow();
    142142    g_assert_true(test->getPageList());
    143143
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp

    r258698 r264647  
    422422static void testPrintCustomWidget(PrintCustomWidgetTest* test, gconstpointer)
    423423{
    424     test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL, 0, 0);
    425 
     424    test->showInWindow();
    426425    test->loadHtml("<html><body>Text</body></html>", 0);
    427426    test->waitUntilLoadFinished();
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp

    r261855 r264647  
    3535        , m_editorState(nullptr)
    3636    {
    37         showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
     37        showInWindow();
    3838        loadURI("about:blank");
    3939        waitUntilLoadFinished();
  • trunk/Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.h

    r263095 r264647  
    6666    void keyStroke(unsigned keyVal, unsigned keyModifiers = 0);
    6767
     68    void showInWindow(int width = 0, int height = 0);
     69
    6870#if PLATFORM(GTK)
    69     void showInWindow(GtkWindowType = GTK_WINDOW_POPUP);
    70     void showInWindowAndWaitUntilMapped(GtkWindowType = GTK_WINDOW_POPUP, int width = 0, int height = 0);
    7171    void emitPopupMenuSignal();
    72 #endif
    73 
    74 #if PLATFORM(WPE)
    75     void showInWindowAndWaitUntilMapped() { showInWindow(); };
    76     void showInWindow();
    7772#endif
    7873
    … …  
    120115    GtkWidget* m_parentWindow { nullptr };
    121116#endif
    122 
    123 private:
    124 #if PLATFORM(GTK)
    125     void doMouseButtonEvent(GdkEventType, int, int, unsigned, unsigned);
    126 #endif
    127117};
  • trunk/Tools/TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp

    r260255 r264647  
    2222#include "WebViewTest.h"
    2323
     24#include "WebKitWebViewBaseInternal.h"
    2425#include <WebCore/GUniquePtrGtk.h>
    2526#include <WebCore/GtkVersioning.h>
    … …  
    4142void WebViewTest::quitMainLoopAfterProcessingPendingEvents()
    4243{
    43     while (gtk_events_pending())
    44         gtk_main_iteration();
     44    while (g_main_context_pending(nullptr))
     45        g_main_context_iteration(nullptr, TRUE);
    4546    quitMainLoop();
    4647}
    … …  
    6263}
    6364
    64 static gboolean parentWindowMapped(GtkWidget* widget, GdkEvent*, WebViewTest* test)
    65 {
    66     g_signal_handlers_disconnect_by_func(widget, reinterpret_cast<void*>(parentWindowMapped), test);
    67     g_main_loop_quit(test->m_mainLoop);
    68 
    69     return FALSE;
    70 }
    71 
    72 void WebViewTest::showInWindow(GtkWindowType windowType)
     65void WebViewTest::showInWindow(int width, int height)
    7366{
    7467    g_assert_null(m_parentWindow);
    75     m_parentWindow = gtk_window_new(windowType);
     68    m_parentWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     69    if (width && height)
     70        gtk_window_set_default_size(GTK_WINDOW(m_parentWindow), width, height);
    7671    gtk_container_add(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView));
    7772    gtk_widget_show(GTK_WIDGET(m_webView));
    7873    gtk_widget_show(m_parentWindow);
    79 }
    8074
    81 void WebViewTest::showInWindowAndWaitUntilMapped(GtkWindowType windowType, int width, int height)
    82 {
    83     g_assert_null(m_parentWindow);
    84     m_parentWindow = gtk_window_new(windowType);
    85     if (width && height)
    86         gtk_window_resize(GTK_WINDOW(m_parentWindow), width, height);
    87     gtk_container_add(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView));
    88     gtk_widget_show(GTK_WIDGET(m_webView));
    89 
    90     g_signal_connect(m_parentWindow, "map-event", G_CALLBACK(parentWindowMapped), this);
    91     gtk_widget_show(m_parentWindow);
    92     g_main_loop_run(m_mainLoop);
     75    while (g_main_context_pending(nullptr))
     76        g_main_context_iteration(nullptr, TRUE);
    9377}
    9478
    … …  
    9680{
    9781    g_assert_nonnull(m_parentWindow);
    98     GtkWidget* viewWidget = GTK_WIDGET(m_webView);
    99     g_assert_true(gtk_widget_get_realized(viewWidget));
    100 
    101     GUniquePtr<GdkEvent> event(gdk_event_new(GDK_MOTION_NOTIFY));
    102     event->motion.x = x;
    103     event->motion.y = y;
    104 
    105     event->motion.time = GDK_CURRENT_TIME;
    106     event->motion.window = gtk_widget_get_window(viewWidget);
    107     g_object_ref(event->motion.window);
    108     event->motion.device = gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(viewWidget)));
    109     event->motion.state = mouseModifiers;
    110     event->motion.axes = 0;
    111 
    112     int xRoot, yRoot;
    113     gdk_window_get_root_coords(gtk_widget_get_window(viewWidget), x, y, &xRoot, &yRoot);
    114     event->motion.x_root = xRoot;
    115     event->motion.y_root = yRoot;
    116     gtk_main_do_event(event.get());
     82    webkitWebViewBaseSynthesizeMouseEvent(WEBKIT_WEB_VIEW_BASE(m_webView), MouseEventType::Motion, 0, 0, x, y, mouseModifiers, 0);
    11783}
    11884
    11985void WebViewTest::clickMouseButton(int x, int y, unsigned button, unsigned mouseModifiers)
    12086{
    121     doMouseButtonEvent(GDK_BUTTON_PRESS, x, y, button, mouseModifiers);
    122     doMouseButtonEvent(GDK_BUTTON_RELEASE, x, y, button, mouseModifiers);
     87    webkitWebViewBaseSynthesizeMouseEvent(WEBKIT_WEB_VIEW_BASE(m_webView), MouseEventType::Press, button, 1 << (8 + button - 1), x, y, mouseModifiers, 1);
     88    webkitWebViewBaseSynthesizeMouseEvent(WEBKIT_WEB_VIEW_BASE(m_webView), MouseEventType::Release, button, 0, x, y, mouseModifiers, 0);
    12389}
    12490
    … …  
    135101{
    136102    g_assert_nonnull(m_parentWindow);
    137     GtkWidget* viewWidget = GTK_WIDGET(m_webView);
    138     g_assert_true(gtk_widget_get_realized(viewWidget));
    139 
    140     GUniquePtr<GdkEvent> event(gdk_event_new(GDK_KEY_PRESS));
    141     event->key.keyval = keyVal;
    142 
    143     event->key.time = GDK_CURRENT_TIME;
    144     event->key.window = gtk_widget_get_window(viewWidget);
    145     g_object_ref(event->key.window);
    146     GdkDisplay* display = gtk_widget_get_display(viewWidget);
    147     gdk_event_set_device(event.get(), gdk_seat_get_pointer(gdk_display_get_default_seat(display)));
    148     event->key.state = keyModifiers;
    149 
    150     // When synthesizing an event, an invalid hardware_keycode value can cause it to be badly processed by GTK+.
    151     GUniqueOutPtr<GdkKeymapKey> keys;
    152     int keysCount;
    153     if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_for_display(display), keyVal, &keys.outPtr(), &keysCount) && keysCount)
    154         event->key.hardware_keycode = keys.get()[0].keycode;
    155 
    156     gtk_main_do_event(event.get());
    157     event->key.type = GDK_KEY_RELEASE;
    158     gtk_main_do_event(event.get());
     103    webkitWebViewBaseSynthesizeKeyEvent(WEBKIT_WEB_VIEW_BASE(m_webView), KeyEventType::Insert, keyVal, keyModifiers, ShouldTranslateKeyboardState::No);
    159104}
    160 
    161 void WebViewTest::doMouseButtonEvent(GdkEventType eventType, int x, int y, unsigned button, unsigned mouseModifiers)
    162 {
    163     g_assert_nonnull(m_parentWindow);
    164     GtkWidget* viewWidget = GTK_WIDGET(m_webView);
    165     g_assert_true(gtk_widget_get_realized(viewWidget));
    166 
    167     GUniquePtr<GdkEvent> event(gdk_event_new(eventType));
    168     event->button.window = gtk_widget_get_window(viewWidget);
    169     g_object_ref(event->button.window);
    170 
    171     event->button.time = GDK_CURRENT_TIME;
    172     event->button.x = x;
    173     event->button.y = y;
    174     event->button.axes = 0;
    175     event->button.state = mouseModifiers;
    176     event->button.button = button;
    177 
    178     event->button.device = gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(viewWidget)));
    179 
    180     int xRoot, yRoot;
    181     gdk_window_get_root_coords(gtk_widget_get_window(viewWidget), x, y, &xRoot, &yRoot);
    182     event->button.x_root = xRoot;
    183     event->button.y_root = yRoot;
    184     gtk_main_do_event(event.get());
    185 }
  • trunk/Tools/TestWebKitAPI/glib/WebKitGLib/wpe/WebViewTestWPE.cpp

    r253749 r264647  
    4242}
    4343
    44 void WebViewTest::showInWindow()
     44void WebViewTest::showInWindow(int, int)
    4545{
    4646    auto* backend = webkit_web_view_backend_get_wpe_backend(webkit_web_view_get_backend(m_webView));
  • trunk/Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp

    r260255 r264647  
    2727#include "PlatformWebView.h"
    2828
     29#include "WebKitWebViewBaseInternal.h"
    2930#include <WebCore/GUniquePtrGtk.h>
    3031#include <WebCore/GtkVersioning.h>
    … …  
    8485}
    8586
    86 static void doKeyStroke(GtkWidget* viewWidget, unsigned int keyVal)
     87static inline WebKitWebViewBase* toWebKitGLibAPI(PlatformWKView view)
    8788{
    88     GUniquePtr<GdkEvent> event(gdk_event_new(GDK_KEY_PRESS));
    89     event->key.keyval = keyVal;
    90     event->key.time = GDK_CURRENT_TIME;
    91     event->key.state = 0;
    92     event->key.window = gtk_widget_get_window(viewWidget);
    93     g_object_ref(event->key.window);
    94     GdkDisplay* display = gtk_widget_get_display(viewWidget);
    95     gdk_event_set_device(event.get(), gdk_seat_get_pointer(gdk_display_get_default_seat(display)));
    96 
    97     // When synthesizing an event, an invalid hardware_keycode value can cause it to be badly processed by GTK+.
    98     GUniqueOutPtr<GdkKeymapKey> keys;
    99     int keysCount;
    100     if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_for_display(display), keyVal, &keys.outPtr(), &keysCount) && keysCount)
    101         event->key.hardware_keycode = keys.get()[0].keycode;
    102 
    103     gtk_main_do_event(event.get());
    104     event->key.type = GDK_KEY_RELEASE;
    105     gtk_main_do_event(event.get());
     89    return const_cast<WebKitWebViewBase*>(reinterpret_cast<const WebKitWebViewBase*>(view));
    10690}
    10791
    … …  
    11195    if (!gtk_widget_get_realized(viewWidget))
    11296        gtk_widget_show(m_window);
    113     doKeyStroke(viewWidget, GDK_KEY_KP_Space);
     97    webkitWebViewBaseSynthesizeKeyEvent(toWebKitGLibAPI(m_view), KeyEventType::Insert, GDK_KEY_KP_Space, 0, ShouldTranslateKeyboardState::No);
    11498}
    11599
    … …  
    119103    if (!gtk_widget_get_realized(viewWidget))
    120104        gtk_widget_show(m_window);
    121     doKeyStroke(viewWidget, GDK_KEY_Alt_L);
    122 }
    123 
    124 static void doMouseButtonEvent(GtkWidget* viewWidget, GdkEventType eventType, int x, int y, unsigned int button)
    125 {
    126     GUniquePtr<GdkEvent> event(gdk_event_new(eventType));
    127     event->button.x = x;
    128     event->button.y = y;
    129     event->button.button = button;
    130     event->button.time = GDK_CURRENT_TIME;
    131     event->button.axes = 0;
    132     event->button.state = 0;
    133     event->button.window = gtk_widget_get_window(viewWidget);
    134     g_object_ref(event->button.window);
    135     event->button.device = gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(viewWidget)));
    136 
    137     int xRoot, yRoot;
    138     gdk_window_get_root_coords(gtk_widget_get_window(viewWidget), x, y, &xRoot, &yRoot);
    139     event->button.x_root = xRoot;
    140     event->button.y_root = yRoot;
    141     gtk_main_do_event(event.get());
     105    webkitWebViewBaseSynthesizeKeyEvent(toWebKitGLibAPI(m_view), KeyEventType::Insert, GDK_KEY_Alt_L, 0, ShouldTranslateKeyboardState::No);
    142106}
    143107
    … …  
    147111    if (!gtk_widget_get_realized(viewWidget))
    148112        gtk_widget_show(m_window);
    149     doMouseButtonEvent(viewWidget, GDK_BUTTON_PRESS, x, y, 3);
    150     doMouseButtonEvent(viewWidget, GDK_BUTTON_RELEASE, x, y, 3);
     113    webkitWebViewBaseSynthesizeMouseEvent(toWebKitGLibAPI(m_view), MouseEventType::Press, 3, 0, x, y, 0, 1);
     114    webkitWebViewBaseSynthesizeMouseEvent(toWebKitGLibAPI(m_view), MouseEventType::Release, 3, 0, x, y, 0, 0);
    151115}
    152116
    153117void PlatformWebView::simulateMouseMove(unsigned x, unsigned y, WKEventModifiers)
    154118{
    155     GUniquePtr<GdkEvent> event(gdk_event_new(GDK_MOTION_NOTIFY));
    156     event->motion.x = x;
    157     event->motion.y = y;
    158     event->motion.time = GDK_CURRENT_TIME;
    159     event->motion.state = 0;
    160     event->motion.axes = 0;
    161 
    162     GtkWidget* viewWidget = GTK_WIDGET(m_view);
    163     if (!gtk_widget_get_realized(viewWidget))
    164         gtk_widget_show(m_window);
    165     event->motion.window = gtk_widget_get_window(viewWidget);
    166     g_object_ref(event->motion.window);
    167     event->motion.device = gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(viewWidget)));
    168 
    169     int xRoot, yRoot;
    170     gdk_window_get_root_coords(gtk_widget_get_window(viewWidget), x, y, &xRoot, &yRoot);
    171     event->motion.x_root = xRoot;
    172     event->motion.y_root = yRoot;
    173     gtk_main_do_event(event.get());
     119    webkitWebViewBaseSynthesizeMouseEvent(toWebKitGLibAPI(m_view), MouseEventType::Motion, 0, 0, x, y, 0, 0);
    174120}
    175121
Note: See TracChangeset for help on using the changeset viewer.