Changeset 265080 in webkit


Ignore:
Timestamp:
Jul 30, 2020 1:53:28 AM (4 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK4] Enable API tests
https://bugs.webkit.org/show_bug.cgi?id=214344

Reviewed by Adrian Perez de Castro.

.:

Build API tests for GTK4 too.

  • Source/cmake/OptionsGTK.cmake:

Source/WebKit:

Use a custom KeyEvent struct to pass to the IM filter as a fake GdkEvent to be able to test input methods with
GTK4.

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

(WebKit::InputMethodFilter::platformEventKeyIsKeyPress const):
(WebKit::InputMethodFilter::filterKeyEvent):

  • UIProcess/API/gtk/WebKitWebViewBaseInternal.h:
  • UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp:

(WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::start):
(WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::stop):

Tools:

Port API tests to GTK4. Context menu and option menu tests are still disabled for GTK4 because we plan to change
the API for GTK4 in those cases.

  • TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp:

(beforeAll):

  • TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp:

(webkitInputMethodContextMockFilterKeyEvent):

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

(beforeAll):

  • TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp:

(checkMimeTypeForFilter):

  • TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp:

(testWebExtensionInputElementIsUserEdited):

  • TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp:

(testWebKitSettings):

  • TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:
  • TestWebKitAPI/Tests/WebKitGtk/AccessibilityTestServer.cpp:
  • TestWebKitAPI/Tests/WebKitGtk/InspectorTestServer.cpp:

(main):

  • TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp:

(testContextMenuPopulateMenu):
(beforeAll):

  • TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp:
  • TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp:
  • TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp:

(Clipboard::Clipboard):
(Clipboard::clear):
(Clipboard::containsText const):
(Clipboard::waitForText):
(Clipboard::readText):
(testWebViewEditorCutCopyPasteNonEditable):
(testWebViewEditorCutCopyPasteEditable):
(testWebViewEditorSelectAllNonEditable):
(testWebViewEditorSelectAllEditable):
(loadContentsAndTryToCutSelection):

  • TestWebKitAPI/glib/WebKitGLib/TestMain.h:

(Test::Test):

  • TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp:

(WebViewTest::platformDestroy):
(WebViewTest::showInWindow):

  • TestWebKitAPI/gtk/PlatformUtilitiesGtk.cpp:

(TestWebKitAPI::Util::isKeyDown):

  • TestWebKitAPI/gtk/PlatformWebViewGtk.cpp:

(TestWebKitAPI::PlatformWebView::~PlatformWebView):
(TestWebKitAPI::PlatformWebView::initialize):

Location:
trunk
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r265041 r265080  
     12020-07-15  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK4] Enable API tests
     4        https://bugs.webkit.org/show_bug.cgi?id=214344
     5
     6        Reviewed by Adrian Perez de Castro.
     7
     8        Build API tests for GTK4 too.
     9
     10        * Source/cmake/OptionsGTK.cmake:
     11
    1122020-07-29  Adrian Perez de Castro  <aperez@igalia.com>
    213
  • trunk/Source/WebKit/ChangeLog

    r265079 r265080  
     12020-07-15  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK4] Enable API tests
     4        https://bugs.webkit.org/show_bug.cgi?id=214344
     5
     6        Reviewed by Adrian Perez de Castro.
     7
     8        Use a custom KeyEvent struct to pass to the IM filter as a fake GdkEvent to be able to test input methods with
     9        GTK4.
     10
     11        * UIProcess/API/glib/InputMethodFilter.h:
     12        * UIProcess/API/gtk/InputMethodFilterGtk.cpp:
     13        (WebKit::InputMethodFilter::platformEventKeyIsKeyPress const):
     14        (WebKit::InputMethodFilter::filterKeyEvent):
     15        * UIProcess/API/gtk/WebKitWebViewBaseInternal.h:
     16        * UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp:
     17        (WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::start):
     18        (WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::stop):
     19
    1202020-07-30  Brady Eidson  <beidson@apple.com>
    221
  • trunk/Source/WebKit/UIProcess/API/glib/InputMethodFilter.h

    r264647 r265080  
    113113        bool isActive { false };
    114114        bool preeditChanged { false };
     115#if PLATFORM(GTK) && USE(GTK4)
     116        bool isFakeKeyEventForTesting { false };
     117#endif
    115118    } m_filteringContext;
    116119
  • trunk/Source/WebKit/UIProcess/API/gtk/InputMethodFilterGtk.cpp

    r264647 r265080  
    2121#include "InputMethodFilter.h"
    2222
     23#include "WebKitInputMethodContextImplGtk.h"
    2324#include "WebKitInputMethodContextPrivate.h"
     25#include "WebKitWebViewBaseInternal.h"
    2426#include <WebCore/GUniquePtrGtk.h>
    2527#include <WebCore/IntRect.h>
    2628#include <gdk/gdk.h>
     29#include <wtf/SetForScope.h>
    2730
    2831namespace WebKit {
     
    4043bool InputMethodFilter::platformEventKeyIsKeyPress(PlatformEventKey* event) const
    4144{
     45#if USE(GTK4)
     46    if (UNLIKELY(m_filteringContext.isFakeKeyEventForTesting))
     47        return reinterpret_cast<KeyEvent*>(event)->type == GDK_KEY_PRESS;
     48#endif
    4249    return gdk_event_get_event_type(event) == GDK_KEY_PRESS;
    4350}
     
    4855        return { };
    4956
    50 #if !USE(GTK4)
     57#if USE(GTK4)
     58    if (WEBKIT_IS_INPUT_METHOD_CONTEXT_IMPL_GTK(m_context.get()))
     59        return { };
     60
     61    // In GTK4 we can't create GdkEvents, so here we create a custom KeyEvent struct that is passed
     62    // as a GdkEvent to the filter. This is only called from tests, and tests know they are receiving
     63    // a KeyEvent struct instead of an actual GdkEvent.
     64    SetForScope<bool> isFakeKeyEventForTesting(m_filteringContext.isFakeKeyEventForTesting, true);
     65    KeyEvent event { type, keyval, modifiers };
     66    return filterKeyEvent(reinterpret_cast<GdkEvent*>(&event));
     67#else
    5168    auto* webView = webkitInputMethodContextGetWebView(m_context.get());
    5269    ASSERT(webView);
     
    6178    gdk_event_set_device(event.get(), gdk_seat_get_keyboard(gdk_display_get_default_seat(gtk_widget_get_display(GTK_WIDGET(webView)))));
    6279    return filterKeyEvent(event.get());
    63 #else
    64     return { };
    6580#endif
    6681}
  • trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBaseInternal.h

    r262343 r265080  
    2828typedef struct _WebKitWebViewBase WebKitWebViewBase;
    2929
     30struct KeyEvent {
     31    unsigned type { 0 };
     32    unsigned keyval { 0 };
     33    unsigned modifiers { 0 };
     34};
     35
    3036enum class MouseEventType { Press, Release, Motion };
    3137void webkitWebViewBaseSynthesizeMouseEvent(WebKitWebViewBase*, MouseEventType type, unsigned button, unsigned short buttons, int x, int y, unsigned modifiers, int clickCount);
  • trunk/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp

    r255518 r265080  
    412412#if PLATFORM(GTK)
    413413    gtk_widget_queue_draw(m_webPage.viewWidget());
     414#if USE(GTK4)
     415    m_timer.startOneShot(16_ms);
     416#else
    414417    g_signal_connect_swapped(m_webPage.viewWidget(), "draw", reinterpret_cast<GCallback>(webViewDrawCallback), this);
    415418    m_timer.startOneShot(100_ms);
     419#endif
    416420#else
    417421    m_timer.startOneShot(0_s);
     
    422426{
    423427    m_timer.stop();
    424 #if PLATFORM(GTK)
     428#if PLATFORM(GTK) && !USE(GTK4)
    425429    g_signal_handlers_disconnect_by_func(m_webPage.viewWidget(), reinterpret_cast<gpointer>(webViewDrawCallback), this);
    426430#endif
  • trunk/Source/cmake/OptionsGTK.cmake

    r265032 r265080  
    121121if (DEVELOPER_MODE)
    122122    WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MINIBROWSER PUBLIC ON)
    123     if (USE_GTK4)
    124         WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_API_TESTS PRIVATE OFF)
    125     else ()
    126         WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_API_TESTS PRIVATE ON)
    127     endif ()
     123    WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_API_TESTS PRIVATE ON)
    128124else ()
    129125    WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MINIBROWSER PUBLIC OFF)
  • trunk/Tools/ChangeLog

    r265079 r265080  
     12020-07-15  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK4] Enable API tests
     4        https://bugs.webkit.org/show_bug.cgi?id=214344
     5
     6        Reviewed by Adrian Perez de Castro.
     7
     8        Port API tests to GTK4. Context menu and option menu tests are still disabled for GTK4 because we plan to change
     9        the API for GTK4 in those cases.
     10
     11        * TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp:
     12        (beforeAll):
     13        * TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp:
     14        (webkitInputMethodContextMockFilterKeyEvent):
     15        * TestWebKitAPI/Tests/WebKitGLib/TestMultiprocess.cpp:
     16        * TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp:
     17        (beforeAll):
     18        * TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp:
     19        (checkMimeTypeForFilter):
     20        * TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp:
     21        (testWebExtensionInputElementIsUserEdited):
     22        * TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp:
     23        (testWebKitSettings):
     24        * TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:
     25        * TestWebKitAPI/Tests/WebKitGtk/AccessibilityTestServer.cpp:
     26        * TestWebKitAPI/Tests/WebKitGtk/InspectorTestServer.cpp:
     27        (main):
     28        * TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp:
     29        (testContextMenuPopulateMenu):
     30        (beforeAll):
     31        * TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp:
     32        * TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp:
     33        * TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp:
     34        (Clipboard::Clipboard):
     35        (Clipboard::clear):
     36        (Clipboard::containsText const):
     37        (Clipboard::waitForText):
     38        (Clipboard::readText):
     39        (testWebViewEditorCutCopyPasteNonEditable):
     40        (testWebViewEditorCutCopyPasteEditable):
     41        (testWebViewEditorSelectAllNonEditable):
     42        (testWebViewEditorSelectAllEditable):
     43        (loadContentsAndTryToCutSelection):
     44        * TestWebKitAPI/glib/WebKitGLib/TestMain.h:
     45        (Test::Test):
     46        * TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp:
     47        (WebViewTest::platformDestroy):
     48        (WebViewTest::showInWindow):
     49        * TestWebKitAPI/gtk/PlatformUtilitiesGtk.cpp:
     50        (TestWebKitAPI::Util::isKeyDown):
     51        * TestWebKitAPI/gtk/PlatformWebViewGtk.cpp:
     52        (TestWebKitAPI::PlatformWebView::~PlatformWebView):
     53        (TestWebKitAPI::PlatformWebView::initialize):
     54
    1552020-07-30  Brady Eidson  <beidson@apple.com>
    256
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp

    r264647 r265080  
    808808    // FIXME: Implement keyStroke in WPE.
    809809#if PLATFORM(GTK)
     810#if !USE(GTK4)
     811    // FIXME: Rework context menu API in GTK4 to not expose GdkEvent.
    810812    WebViewDownloadTest::add("Downloads", "contex-menu-download-actions", testContextMenuDownloadActions);
     813#endif
    811814    // FIXME: Implement mouse click in WPE.
    812815    WebViewDownloadTest::add("Downloads", "blob-download", testBlobDownload);
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp

    r264647 r265080  
    2525
    2626#if PLATFORM(GTK)
     27#include <WebCore/GtkVersioning.h>
     28#if USE(GTK4)
     29#include "WebKitWebViewBaseInternal.h"
     30using PlatformEventKey = GdkEvent;
     31#else
    2732using PlatformEventKey = GdkEventKey;
     33#endif
    2834#define KEY(x) GDK_KEY_##x
    2935#define CONTROL_MASK GDK_CONTROL_MASK
     
    9399
    94100#if PLATFORM(GTK)
     101#if USE(GTK4)
     102    auto* event = reinterpret_cast<KeyEvent*>(keyEvent);
     103    unsigned keyval = event->keyval;
     104    auto state = static_cast<GdkModifierType>(event->modifiers);
     105    bool isKeyPress = event->type == GDK_KEY_PRESS;
     106#else
    95107    GdkModifierType state;
    96108    guint keyval;
     
    98110        return FALSE;
    99111    bool isKeyPress = gdk_event_get_event_type(reinterpret_cast<GdkEvent*>(keyEvent)) == GDK_KEY_PRESS;
     112#endif
    100113    gunichar character = gdk_keyval_to_unicode(keyval);
    101114#elif PLATFORM(WPE)
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestMultiprocess.cpp

    r249759 r265080  
    100100        g_assert_nonnull(connection);
    101101        g_signal_connect_swapped(connection, "closed", G_CALLBACK(g_main_loop_quit), m_mainLoop);
     102#if USE(GTK4)
     103        g_object_run_dispose(G_OBJECT(m_webViews[index].get()));
     104#else
    102105        gtk_widget_destroy(GTK_WIDGET(m_webViews[index].get()));
     106#endif
    103107        g_main_loop_run(m_mainLoop);
    104108    }
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp

    r264647 r265080  
    305305void beforeAll()
    306306{
     307#if !PLATFORM(GTK) || !USE(GTK4)
     308    // FIXME: Rework option menu API in GTK4 to not expose GdkEvent.
    307309    OptionMenuTest::add("WebKitWebView", "option-menu-simple", testOptionMenuSimple);
    308310    OptionMenuTest::add("WebKitWebView", "option-menu-groups", testOptionMenuGroups);
    309311    OptionMenuTest::add("WebKitWebView", "option-menu-activate", testOptionMenuActivate);
    310312    OptionMenuTest::add("WebKitWebView", "option-menu-select", testOptionMenuSelect);
     313#endif
    311314}
    312315
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp

    r264647 r265080  
    318318    {
    319319        m_shouldCreateWebViewsInNewWindowsAutomatically = true;
    320         m_DefaultGeometryNewWindows.width = width;
    321         m_DefaultGeometryNewWindows.height = height;
     320        m_defaultGeometryNewWindows.width = width;
     321        m_defaultGeometryNewWindows.height = height;
    322322    }
    323323#endif
     
    339339        keyStroke(GDK_KEY_a);
    340340        keyStroke(GDK_KEY_b);
    341         while (gtk_events_pending())
    342             gtk_main_iteration();
     341        while (g_main_context_pending(nullptr))
     342            g_main_context_iteration(nullptr, TRUE);
    343343#endif
    344344    }
     
    368368        if (m_shouldCreateWebViewsInNewWindowsAutomatically) {
    369369            g_assert_null(m_parentWindow);
     370#if USE(GTK4)
     371            m_parentWindow = gtk_window_new();
     372            gtk_window_set_child(GTK_WINDOW(m_parentWindow), GTK_WIDGET(newWebView));
     373#else
    370374            m_parentWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    371             gtk_window_set_default_size(GTK_WINDOW(m_parentWindow), m_DefaultGeometryNewWindows.width, m_DefaultGeometryNewWindows.height);
    372375            gtk_container_add(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(newWebView));
    373376            gtk_widget_show(GTK_WIDGET(newWebView));
     377#endif
     378            gtk_window_set_default_size(GTK_WINDOW(m_parentWindow), m_defaultGeometryNewWindows.width, m_defaultGeometryNewWindows.height);
    374379            gtk_widget_show(m_parentWindow);
    375380        }
     
    417422#if PLATFORM(GTK)
    418423    bool m_shouldCreateWebViewsInNewWindowsAutomatically { false };
    419     cairo_rectangle_int_t m_DefaultGeometryNewWindows;
     424    cairo_rectangle_int_t m_defaultGeometryNewWindows;
    420425#endif
    421426};
     
    522527static gboolean checkMimeTypeForFilter(GtkFileFilter* filter, const gchar* mimeType)
    523528{
     529#if USE(GTK4)
     530    GRefPtr<GFileInfo> filterInfo = adoptGRef(g_file_info_new());
     531    g_file_info_set_content_type(filterInfo.get(), mimeType);
     532    return gtk_filter_match(GTK_FILTER(filter), filterInfo.get());
     533#else
    524534    GtkFileFilterInfo filterInfo;
    525535    filterInfo.contains = GTK_FILE_FILTER_MIME_TYPE;
    526536    filterInfo.mime_type = mimeType;
    527537    return gtk_file_filter_filter(filter, &filterInfo);
     538#endif
    528539}
    529540#endif
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp

    r264647 r265080  
    8484    test->runJavaScriptAndWaitUntilFinished("document.getElementById('input').focus()", nullptr);
    8585    test->keyStroke(GDK_KEY_a);
    86     while (gtk_events_pending())
    87         gtk_main_iteration();
     86    while (g_main_context_pending(nullptr))
     87        g_main_context_iteration(nullptr, TRUE);
    8888    GUniquePtr<char> resultString;
    8989    do {
     
    9696    test->runJavaScriptAndWaitUntilFinished("document.getElementById('textarea').focus()", nullptr);
    9797    test->keyStroke(GDK_KEY_b);
    98     while (gtk_events_pending())
    99         gtk_main_iteration();
     98    while (g_main_context_pending(nullptr))
     99        g_main_context_iteration(nullptr, TRUE);
    100100    do {
    101101        auto* result = test->runJavaScriptAndWaitUntilFinished("document.getElementById('textarea').value", nullptr);
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp

    r261986 r265080  
    350350
    351351#if PLATFORM(GTK)
     352#if !USE(GTK4)
    352353    // Ondemand is the default hardware acceleration policy.
    353354    g_assert_cmpuint(webkit_settings_get_hardware_acceleration_policy(settings), ==, WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND);
     
    358359    webkit_settings_set_hardware_acceleration_policy(settings, WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND);
    359360    g_assert_cmpuint(webkit_settings_get_hardware_acceleration_policy(settings), ==, WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND);
     361#endif
    360362
    361363    // Back-forward navigation gesture is disabled by default
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp

    r264647 r265080  
    445445    static gboolean leaveFullScreenIdle(FullScreenClientTest* test)
    446446    {
    447         // FIXME: Implement key strokes in WPE
    448447#if PLATFORM(GTK)
    449448        test->keyStroke(GDK_KEY_Escape);
     449#else
     450        test->keyStroke(WPE_KEY_Escape);
    450451#endif
    451452        return FALSE;
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/AccessibilityTestServer.cpp

    r260132 r265080  
    2222#include <WebCore/GtkVersioning.h>
    2323#include <webkit2/webkit2.h>
     24#include <wtf/glib/GRefPtr.h>
    2425
    2526static const char introspectionXML[] =
     
    7172
    7273    GtkWidget* webView = webkit_web_view_new();
    73 
     74#if USE(GTK4)
     75    GtkWidget* window = gtk_window_new();
     76    gtk_window_set_child(GTK_WINDOW(window), GTK_WIDGET(webView));
     77#else
    7478    GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    7579    g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), nullptr);
    7680    gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(webView));
    77     gtk_widget_show_all(window);
     81    gtk_widget_show(GTK_WIDGET(webView));
     82#endif
     83    gtk_widget_show(window);
    7884
    7985    g_dbus_connection_new_for_address(argv[1], G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, nullptr, nullptr,
     
    8995        }, webView);
    9096
     97#if USE(GTK4)
     98    GRefPtr<GMainLoop> loop = adoptGRef(g_main_loop_new(nullptr, TRUE));
     99    g_main_loop_run(loop.get());
     100#else
    91101    gtk_main();
     102#endif
    92103}
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/InspectorTestServer.cpp

    r260132 r265080  
    2727#include <WebCore/GtkVersioning.h>
    2828#include <webkit2/webkit2.h>
     29#include <wtf/glib/GRefPtr.h>
    2930
    3031int main(int argc, char** argv)
     
    4142        "http://127.0.0.1:2999/");
    4243
     44#if USE(GTK4)
     45    GtkWidget* window = gtk_window_new();
     46    gtk_window_set_child(GTK_WINDOW(window), GTK_WIDGET(webView));
     47    gtk_widget_show(window);
     48
     49    GRefPtr<GMainLoop> loop = adoptGRef(g_main_loop_new(nullptr, TRUE));
     50    g_main_loop_run(loop.get());
     51#else
    4352    GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    4453    gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(webView));
     
    4857
    4958    gtk_main();
     59#endif
    5060}
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp

    r264647 r265080  
    2727static WebKitTestServer* kServer;
    2828
    29 #if USE(GTK4)
    30 struct LookupWidgetsData {
    31     void (*walkChildren)(GtkContainer*, GtkCallback, void*);
    32     Function<bool(GtkWidget*)> predicate;
    33     Vector<GtkWidget*> result;
    34 };
    35 
    36 static void lookupWidgetsWalkChild(GtkWidget* child, void* userdata)
    37 {
    38     auto& data = *reinterpret_cast<LookupWidgetsData*>(userdata);
    39     if (data.predicate(child))
    40         data.result.append(child);
    41     else if (GTK_IS_CONTAINER(child))
    42         data.walkChildren(GTK_CONTAINER(child), lookupWidgetsWalkChild, userdata);
    43 }
    44 
    45 static Vector<GtkWidget*> lookupWidgets(GtkWidget* widget, Function<bool(GtkWidget*)>&& predicate, bool internal = false)
    46 {
    47     LookupWidgetsData data = {internal ? gtk_container_forall : gtk_container_foreach, WTFMove(predicate)};
    48     lookupWidgetsWalkChild(widget, &data);
    49     return WTFMove(data.result);
    50 }
    51 #endif // USE(GTK4)
    52 
    5329class ContextMenuTest: public WebViewTest {
    5430public:
     
    6238    {
    6339        g_assert_nonnull(event);
     40#if !USE(GTK4)
    6441        g_assert_cmpint(event->type, ==, m_expectedEventType);
    6542
     
    8057            g_assert_not_reached();
    8158        }
     59#endif
    8260    }
    8361
     
    127105
    128106#if USE(GTK4)
    129             // Popovers are internal to the GtkContainer where the webview resides,
    130             // gtk_container_forall() is the only way to enumerate internal children.
    131             GtkPopover *popover = nullptr;
    132             gtk_container_forall(GTK_CONTAINER(iter->data),
    133                 [](GtkWidget* child, void* data) {
    134                     auto** popover = reinterpret_cast<GtkPopover**>(data);
    135                     if (GTK_IS_POPOVER_MENU(child) && !*popover)
    136                         *popover = GTK_POPOVER(child);
    137                 }, &popover);
    138 
    139             if (popover && gtk_popover_get_relative_to(popover) == GTK_WIDGET(m_webView))
    140                 return popover;
     107            return nullptr;
    141108#else
    142109            GtkWidget* child = gtk_bin_get_child(GTK_BIN(iter->data));
     
    177144        assertObjectIsDeletedWhenTestFinishes(G_OBJECT(item));
    178145
     146#if !USE(GTK4)
    179147        G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
    180148        GtkAction* action = webkit_context_menu_item_get_action(item);
    181149        g_assert_true(GTK_IS_ACTION(action));
    182150        G_GNUC_END_IGNORE_DEPRECATIONS;
     151#endif
    183152
    184153        GAction* gAction = webkit_context_menu_item_get_gaction(item);
     
    200169        assertObjectIsDeletedWhenTestFinishes(G_OBJECT(item));
    201170
     171#if !USE(GTK4)
    202172        G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
    203173        GtkAction* action = webkit_context_menu_item_get_action(item);
    204174        g_assert_true(GTK_IS_ACTION(action));
     175#endif
    205176
    206177        GAction* gAction = webkit_context_menu_item_get_gaction(item);
    207178        g_assert_true(G_IS_ACTION(gAction));
     179#if !USE(GTK4)
    208180        g_assert_cmpstr(gtk_action_get_name(action), ==, g_action_get_name(gAction));
    209181        g_assert_cmpint(gtk_action_get_sensitive(action), ==, g_action_get_enabled(gAction));
     
    218190        g_assert_cmpstr(gtk_action_get_label(action), ==, label);
    219191        G_GNUC_END_IGNORE_DEPRECATIONS;
     192#endif
    220193
    221194        checkActionState(gAction, state);
     
    232205        assertObjectIsDeletedWhenTestFinishes(G_OBJECT(item));
    233206
     207#if !USE(GTK4)
    234208        G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
    235209        GtkAction* action = webkit_context_menu_item_get_action(item);
     
    237211        g_assert_cmpstr(gtk_action_get_label(action), ==, label);
    238212        G_GNUC_END_IGNORE_DEPRECATIONS;
     213#endif
    239214
    240215        GAction* gAction = webkit_context_menu_item_get_gaction(item);
     
    302277    void showContextMenuTriggeredByPopupEventAndWaitUntilFinished()
    303278    {
     279#if !USE(GTK4)
    304280        m_expectedEventType = GDK_NOTHING;
     281#endif
    305282        g_idle_add(reinterpret_cast<GSourceFunc>(emitPopupMenuSignalIdleCallback), this);
    306283        g_main_loop_run(m_mainLoop);
     
    601578    {
    602579        // Append our custom item to the default menu.
     580#if !USE(GTK4)
    603581        G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
    604582        if (m_action)
     
    607585            webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_from_gaction(m_gAction.get(), m_gActionTitle.data(), m_expectedTarget.get()));
    608586        G_GNUC_END_IGNORE_DEPRECATIONS;
     587#endif
    609588        quitMainLoop();
    610589
     
    615594    GtkButton* getMenuItem(GtkWidget* popover, const gchar* itemLabel)
    616595    {
    617         auto items = lookupWidgets(popover,
    618             [itemLabel](GtkWidget* widget) {
    619                 if (!GTK_IS_BUTTON(widget))
    620                     return false;
    621                 const char* label = gtk_button_get_label(GTK_BUTTON(widget));
    622                 if (!label) {
    623                     const auto labels = lookupWidgets(GTK_WIDGET(widget),
    624                         [](GtkWidget* child) { return GTK_IS_LABEL(child); });
    625                     g_assert_cmpuint(1, ==, labels.size());
    626                     label = gtk_label_get_label(GTK_LABEL(labels[0]));
    627                 }
    628                 return GTK_IS_BUTTON(widget) && g_strcmp0(label, itemLabel) == 0;
    629             }, true);
    630 
    631         g_assert_cmpuint(items.size(), >, 0);
    632         return items.size() ? GTK_BUTTON(items[0]) : nullptr;
     596        return nullptr;
    633597    }
    634598#else
     
    652616        auto* item = getMenuItem(menu, m_itemToActivateLabel);
    653617#if USE(GTK4)
    654         // GTK4 uses a popover, which contains buttons.
    655         gtk_button_clicked(item);
     618
    656619#else
    657620        // GTK3 uses a menu, which contains menu items.
     
    701664    {
    702665        test->m_toggled = true;
    703 
    704 #if USE(GTK4)
    705         // For toggle actions the popover menu is NOT dismissed automatically, as to show visual feedback to the user
    706         // (i.e. the check marker). Dismiss it here to trigger contextMenuDismissedCallback() and continue the test.
    707         gtk_popover_popdown(test->getPopoverMenu());
    708 #endif // USE(GTK4)
    709666    }
    710667
     
    714671        m_gAction = nullptr;
    715672        m_expectedTarget = nullptr;
     673#if !USE(GTK4)
    716674        G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
    717675        if (GTK_IS_TOGGLE_ACTION(action))
     
    720678            g_signal_connect_swapped(action, "activate", G_CALLBACK(actionActivatedCallback), this);
    721679        G_GNUC_END_IGNORE_DEPRECATIONS;
     680#endif
    722681    }
    723682
     
    748707    test->waitUntilLoadFinished();
    749708
     709#if !USE(GTK4)
    750710    G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
    751711    // Create a custom menu item.
     
    765725    g_assert_true(test->m_toggled);
    766726    G_GNUC_END_IGNORE_DEPRECATIONS;
     727#endif
    767728
    768729    // Create a custom menu item using GAction.
     
    806767
    807768        // Add custom actions.
     769#if !USE(GTK4)
    808770        G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
    809771        GRefPtr<GtkAction> action = adoptGRef(gtk_action_new("WebKitGTKCustomAction", "Custom _Action", nullptr, nullptr));
     
    814776        webkit_context_menu_append(contextMenu, webkit_context_menu_item_new(toggleAction.get()));
    815777        webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator());
     778#endif
    816779        GRefPtr<GAction> gAction = adoptGRef(G_ACTION(g_simple_action_new("WebKitGTKCustomGAction", nullptr)));
    817780        g_simple_action_set_enabled(G_SIMPLE_ACTION(gAction.get()), FALSE);
     
    11761139    kServer->run(serverCallback);
    11771140
     1141#if !USE(GTK4)
     1142    // FIXME: Rework context menu API in GTK4 to not expose GdkEvent.
    11781143    ContextMenuDefaultTest::add("WebKitWebView", "default-menu", testContextMenuDefaultMenu);
    11791144    ContextMenuDefaultTest::add("WebKitWebView", "context-menu-key", testContextMenuKey);
     
    11861151    ContextMenuWebExtensionTest::add("WebKitWebPage", "context-menu", testContextMenuWebExtensionMenu);
    11871152    ContextMenuWebExtensionNodeTest::add("WebKitWebPage", "context-menu-node", testContextMenuWebExtensionNode);
     1153#endif
    11881154}
    11891155
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp

    r264647 r265080  
    227227    ~CustomInspectorTest()
    228228    {
     229#if USE(GTK4)
     230        if (m_inspectorWindow)
     231            gtk_window_destroy(GTK_WINDOW(m_inspectorWindow));
     232#else
    229233        if (m_inspectorWindow)
    230234            gtk_widget_destroy(m_inspectorWindow);
     235#endif
    231236    }
    232237
     
    234239    {
    235240        g_assert_null(m_inspectorWindow);
    236         m_inspectorWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    237241        WebKitWebViewBase* inspectorView = webkit_web_inspector_get_web_view(m_inspector);
    238242        g_assert_nonnull(inspectorView);
     243#if USE(GTK4)
     244        m_inspectorWindow = gtk_window_new();
     245        gtk_window_set_child(GTK_WINDOW(m_inspectorWindow), GTK_WIDGET(inspectorView));
     246#else
     247        m_inspectorWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    239248        gtk_container_add(GTK_CONTAINER(m_inspectorWindow), GTK_WIDGET(inspectorView));
    240         gtk_widget_show_all(m_inspectorWindow);
     249        gtk_widget_show(GTK_WIDGET(inspectorView));
     250#endif
     251        gtk_widget_show(m_inspectorWindow);
    241252
    242253        return InspectorTest::openWindow();
     
    245256    void closed()
    246257    {
    247         if (m_inspectorWindow) {
    248             gtk_widget_destroy(m_inspectorWindow);
    249             m_inspectorWindow = 0;
    250         }
     258#if USE(GTK4)
     259        g_clear_pointer(&m_inspectorWindow, gtk_window_destroy);
     260#else
     261        g_clear_pointer(&m_inspectorWindow, gtk_widget_destroy);
     262#endif
    251263
    252264        return InspectorTest::closed();
     
    257269        GRefPtr<WebKitWebViewBase> inspectorView = webkit_web_inspector_get_web_view(m_inspector);
    258270        if (m_inspectorWindow) {
     271#if USE(GTK4)
     272            gtk_window_set_child(GTK_WINDOW(m_inspectorWindow), nullptr);
     273            gtk_window_destroy(GTK_WINDOW(m_inspectorWindow));
     274#else
    259275            gtk_container_remove(GTK_CONTAINER(m_inspectorWindow), GTK_WIDGET(inspectorView.get()));
    260276            gtk_widget_destroy(m_inspectorWindow);
    261             m_inspectorWindow = 0;
     277#endif
     278            m_inspectorWindow = nullptr;
    262279        }
    263280
    264281        GtkWidget* pane;
     282#if USE(GTK4)
     283        if (gtk_window_get_child(GTK_WINDOW(m_parentWindow)) == GTK_WIDGET(m_webView)) {
     284            GRefPtr<WebKitWebView> inspectedView = m_webView;
     285            gtk_window_set_child(GTK_WINDOW(m_parentWindow), nullptr);
     286            pane = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
     287            gtk_paned_set_start_child(GTK_PANED(pane), GTK_WIDGET(m_webView));
     288            gtk_window_set_child(GTK_WINDOW(m_parentWindow), pane);
     289        } else
     290            pane = gtk_window_get_child(GTK_WINDOW(m_parentWindow));
     291        gtk_paned_set_position(GTK_PANED(pane), webkit_web_inspector_get_attached_height(m_inspector));
     292        gtk_paned_set_end_child(GTK_PANED(pane), GTK_WIDGET(inspectorView.get()));
     293#else
    265294        if (gtk_bin_get_child(GTK_BIN(m_parentWindow)) == GTK_WIDGET(m_webView)) {
    266295            GRefPtr<WebKitWebView> inspectedView = m_webView;
     
    274303        gtk_paned_set_position(GTK_PANED(pane), webkit_web_inspector_get_attached_height(m_inspector));
    275304        gtk_paned_add2(GTK_PANED(pane), GTK_WIDGET(inspectorView.get()));
     305#endif
    276306
    277307        return InspectorTest::attach();
     
    281311    {
    282312        GRefPtr<WebKitWebViewBase> inspectorView = webkit_web_inspector_get_web_view(m_inspector);
     313#if USE(GTK4)
     314        GtkWidget* pane = gtk_window_get_child(GTK_WINDOW(m_parentWindow));
     315        g_assert_true(GTK_IS_PANED(pane));
     316        gtk_paned_set_end_child(GTK_PANED(pane), nullptr);
     317#else
    283318        GtkWidget* pane = gtk_bin_get_child(GTK_BIN(m_parentWindow));
    284319        g_assert_true(GTK_IS_PANED(pane));
    285320        gtk_container_remove(GTK_CONTAINER(pane), GTK_WIDGET(inspectorView.get()));
     321#endif
    286322        return InspectorTest::detach();
    287323    }
     
    290326    {
    291327        g_assert_nonnull(m_inspectorWindow);
    292         gtk_widget_destroy(m_inspectorWindow);
    293         m_inspectorWindow = 0;
     328#if USE(GTK4)
     329        g_clear_pointer(&m_inspectorWindow, gtk_window_destroy);
     330#else
     331        g_clear_pointer(&m_inspectorWindow, gtk_widget_destroy);
     332#endif
    294333    }
    295334
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp

    r264647 r265080  
    2020#include "config.h"
    2121#include "WebViewTest.h"
     22#include <WebCore/GtkVersioning.h>
    2223#include <glib/gstdio.h>
    2324#include <wtf/glib/GRefPtr.h>
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp

    r264647 r265080  
    2222#include <wtf/glib/GRefPtr.h>
    2323
     24class Clipboard {
     25public:
     26    Clipboard(GMainLoop* loop)
     27        : m_mainLoop(loop)
     28#if USE(GTK4)
     29        , m_clipboard(gdk_display_get_clipboard(gdk_display_get_default()))
     30#else
     31        , m_clipboard(gtk_clipboard_get_for_display(gdk_display_get_default(), GDK_SELECTION_CLIPBOARD))
     32#endif
     33    {
     34    }
     35
     36    void clear()
     37    {
     38#if USE(GTK4)
     39        g_assert_true(gdk_clipboard_set_content(m_clipboard, nullptr));
     40#else
     41        gtk_clipboard_clear(m_clipboard);
     42#endif
     43        m_text = nullptr;
     44    }
     45
     46    bool containsText() const
     47    {
     48#if USE(GTK4)
     49        return gdk_content_formats_contain_gtype(gdk_clipboard_get_formats(m_clipboard), G_TYPE_STRING);
     50#else
     51        return gtk_clipboard_wait_is_text_available(m_clipboard);
     52#endif
     53    }
     54
     55    bool waitForText()
     56    {
     57        // There's no way to know when the selection has been written to
     58        // the clipboard, so use a timeout source to query the clipboard.
     59        static const unsigned kClipboardWaitTimeout = 50;
     60        static const unsigned kClipboardWaitMaxTries = 2;
     61        m_triesCount = 0;
     62        g_timeout_add(kClipboardWaitTimeout, [](gpointer userData) -> gboolean {
     63            auto* clipboard = static_cast<Clipboard*>(userData);
     64            clipboard->m_triesCount++;
     65            if (clipboard->containsText() || clipboard->m_triesCount > kClipboardWaitMaxTries) {
     66                g_main_loop_quit(clipboard->m_mainLoop);
     67                return FALSE;
     68            }
     69            return TRUE;
     70        }, this);
     71        g_main_loop_run(m_mainLoop);
     72        return containsText();
     73    }
     74
     75    const char* readText()
     76    {
     77        m_text = nullptr;
     78        if (waitForText()) {
     79#if USE(GTK4)
     80            gdk_clipboard_read_text_async(m_clipboard, nullptr, [](GObject* gdkClipboard, GAsyncResult* result, gpointer userData) {
     81                auto* clipboard = static_cast<Clipboard*>(userData);
     82                clipboard->m_text.reset(gdk_clipboard_read_text_finish(GDK_CLIPBOARD(gdkClipboard), result, nullptr));
     83                g_main_loop_quit(clipboard->m_mainLoop);
     84            }, this);
     85            g_main_loop_run(m_mainLoop);
     86#else
     87            m_text.reset(gtk_clipboard_wait_for_text(m_clipboard));
     88#endif
     89        }
     90        return m_text.get();
     91    }
     92
     93private:
     94    GMainLoop* m_mainLoop { nullptr };
     95#if USE(GTK4)
     96    GdkClipboard* m_clipboard { nullptr };
     97#else
     98    GtkClipboard* m_clipboard { nullptr };
     99#endif
     100    GUniquePtr<char> m_text;
     101    unsigned m_triesCount { 0 };
     102};
     103
    24104class EditorTest: public WebViewTest {
    25105public:
    26106    MAKE_GLIB_TEST_FIXTURE(EditorTest);
    27107
    28     static const unsigned kClipboardWaitTimeout = 50;
    29     static const unsigned kClipboardWaitMaxTries = 2;
    30 
    31108    EditorTest()
    32         : m_clipboard(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD))
    33         , m_canExecuteEditingCommand(false)
    34         , m_triesCount(0)
    35         , m_editorState(nullptr)
     109        : m_clipboard(m_mainLoop)
    36110    {
    37111        showInWindow();
     112        m_clipboard.clear();
    38113        loadURI("about:blank");
    39114        waitUntilLoadFinished();
    40         gtk_clipboard_clear(m_clipboard);
     115    }
     116
     117    ~EditorTest()
     118    {
     119        m_clipboard.clear();
    41120    }
    42121
     
    49128    void flushEditorState()
    50129    {
     130#if USE(GTK4)
     131        auto* surface = gtk_native_get_surface(gtk_widget_get_native(GTK_WIDGET(m_webView)));
     132        auto* clock = gdk_surface_get_frame_clock(surface);
     133        auto signalID = g_signal_connect_swapped(clock, "paint", G_CALLBACK(webViewDrawCallback), m_mainLoop);
     134#else
    51135        auto signalID = g_signal_connect_swapped(m_webView, "draw", G_CALLBACK(webViewDrawCallback), m_mainLoop);
     136#endif
    52137        gtk_widget_queue_draw(GTK_WIDGET(m_webView));
    53138        g_main_loop_run(m_mainLoop);
     139#if USE(GTK4)
     140        g_signal_handler_disconnect(clock, signalID);
     141#else
    54142        g_signal_handler_disconnect(m_webView, signalID);
     143#endif
    55144    }
    56145
     
    85174    }
    86175
    87     static gboolean waitForClipboardText(EditorTest* test)
    88     {
    89         test->m_triesCount++;
    90         if (gtk_clipboard_wait_is_text_available(test->m_clipboard) || test->m_triesCount > kClipboardWaitMaxTries) {
    91             g_main_loop_quit(test->m_mainLoop);
    92             return FALSE;
    93         }
    94 
    95         return TRUE;
    96     }
    97 
    98     void copyClipboard()
     176    const char* copyClipboard()
    99177    {
    100178        webkit_web_view_execute_editing_command(m_webView, WEBKIT_EDITING_COMMAND_COPY);
    101         // There's no way to know when the selection has been copied to
    102         // the clipboard, so use a timeout source to query the clipboard.
    103         m_triesCount = 0;
    104         g_timeout_add(kClipboardWaitTimeout, reinterpret_cast<GSourceFunc>(waitForClipboardText), this);
    105         g_main_loop_run(m_mainLoop);
    106     }
    107 
    108     gchar* cutSelection()
     179        return m_clipboard.readText();
     180    }
     181
     182    const char* cutSelection()
    109183    {
    110184        g_assert_true(canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT));
     
    113187
    114188        webkit_web_view_execute_editing_command(m_webView, WEBKIT_EDITING_COMMAND_CUT);
    115         // There's no way to know when the selection has been cut to
    116         // the clipboard, so use a timeout source to query the clipboard.
    117         m_triesCount = 0;
    118         g_timeout_add(kClipboardWaitTimeout, reinterpret_cast<GSourceFunc>(waitForClipboardText), this);
    119         g_main_loop_run(m_mainLoop);
    120 
    121         return gtk_clipboard_wait_for_text(m_clipboard);
     189        return m_clipboard.readText();
    122190    }
    123191
     
    150218    }
    151219
    152     GtkClipboard* m_clipboard;
    153     bool m_canExecuteEditingCommand;
    154     size_t m_triesCount;
    155     WebKitEditorState* m_editorState;
     220    Clipboard m_clipboard;
     221    bool m_canExecuteEditingCommand { false };
     222    WebKitEditorState* m_editorState { nullptr };
    156223};
    157224
     
    183250    g_assert_false(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE_AS_PLAIN_TEXT));
    184251
    185     test->copyClipboard();
    186     GUniquePtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard));
    187     g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull");
     252    g_assert_cmpstr(test->copyClipboard(), ==, "make Jack a dull");
    188253}
    189254
     
    211276    g_assert_true(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE_AS_PLAIN_TEXT));
    212277
    213     test->copyClipboard();
    214     GUniquePtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard));
    215     g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull");
     278    g_assert_cmpstr(test->copyClipboard(), ==, "make Jack a dull");
    216279}
    217280
     
    227290    g_assert_true(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL));
    228291
    229     test->copyClipboard();
    230     GUniquePtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard));
    231 
    232292    // Initially only the subspan is selected.
    233     g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull");
     293    g_assert_cmpstr(test->copyClipboard(), ==, "make Jack a dull");
    234294
    235295    webkit_web_view_execute_editing_command(test->m_webView, WEBKIT_EDITING_COMMAND_SELECT_ALL);
    236     test->copyClipboard();
    237     clipboardText.reset(gtk_clipboard_wait_for_text(test->m_clipboard));
    238 
    239296    // The mainspan should be selected after calling SELECT_ALL.
    240     g_assert_cmpstr(clipboardText.get(), ==, "All work and no play make Jack a dull boy.");
     297    g_assert_cmpstr(test->copyClipboard(), ==, "All work and no play make Jack a dull boy.");
    241298}
    242299
     
    256313    g_assert_true(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL));
    257314
    258     test->copyClipboard();
    259     GUniquePtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard));
    260 
    261315    // Initially only the subspan is selected.
    262     g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull");
     316    g_assert_cmpstr(test->copyClipboard(), ==, "make Jack a dull");
    263317
    264318    webkit_web_view_execute_editing_command(test->m_webView, WEBKIT_EDITING_COMMAND_SELECT_ALL);
    265     test->copyClipboard();
    266     clipboardText.reset(gtk_clipboard_wait_for_text(test->m_clipboard));
    267 
    268319    // The mainspan should be selected after calling SELECT_ALL.
    269     g_assert_cmpstr(clipboardText.get(), ==, "All work and no play make Jack a dull boy.");
     320    g_assert_cmpstr(test->copyClipboard(), ==, "All work and no play make Jack a dull boy.");
    270321}
    271322
     
    287338
    288339    // Cut the selection to the clipboard to see if the view is indeed editable.
    289     GUniquePtr<char> clipboardText(test->cutSelection());
    290     g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull");
     340    g_assert_cmpstr(test->cutSelection(), ==, "make Jack a dull");
    291341
    292342    // Reset the editable for next test.
  • trunk/Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.h

    r263386 r265080  
    139139#if PLATFORM(GTK)
    140140            "process-swap-on-cross-site-navigation-enabled", TRUE,
     141#if !USE(GTK4)
    141142            "use-system-appearance-for-scrollbars", FALSE,
     143#endif
    142144#endif
    143145            nullptr)));
  • trunk/Tools/TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp

    r264647 r265080  
    2929void WebViewTest::platformDestroy()
    3030{
     31#if USE(GTK4)
     32    if (m_parentWindow)
     33        gtk_window_destroy(GTK_WINDOW(m_parentWindow));
     34#else
    3135    if (m_parentWindow)
    3236        gtk_widget_destroy(m_parentWindow);
     37#endif
    3338}
    3439
     
    6671{
    6772    g_assert_null(m_parentWindow);
     73#if USE(GTK4)
     74    m_parentWindow = gtk_window_new();
     75    gtk_window_set_child(GTK_WINDOW(m_parentWindow), GTK_WIDGET(m_webView));
     76#else
    6877    m_parentWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     78    gtk_container_add(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView));
     79    gtk_widget_show(GTK_WIDGET(m_webView));
     80#endif
     81
    6982    if (width && height)
    7083        gtk_window_set_default_size(GTK_WINDOW(m_parentWindow), width, height);
    71     gtk_container_add(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView));
    72     gtk_widget_show(GTK_WIDGET(m_webView));
     84
    7385    gtk_widget_show(m_parentWindow);
    7486
  • trunk/Tools/TestWebKitAPI/gtk/PlatformUtilitiesGtk.cpp

    r222962 r265080  
    6969bool isKeyDown(WKNativeEventPtr event)
    7070{
    71     return event->type == GDK_KEY_PRESS;
     71    return gdk_event_get_event_type(const_cast<GdkEvent*>(event)) == GDK_KEY_PRESS;
    7272}
    7373
  • trunk/Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp

    r264647 r265080  
    6363PlatformWebView::~PlatformWebView()
    6464{
     65#if USE(GTK4)
     66    gtk_window_destroy(GTK_WINDOW(m_window));
     67#else
    6568    gtk_widget_destroy(m_window);
     69#endif
    6670}
    6771
    6872void PlatformWebView::initialize(WKPageConfigurationRef configuration)
    6973{
     74    m_view = WKViewCreate(configuration);
     75#if USE(GTK4)
     76    m_window = gtk_window_new();
     77    gtk_window_set_child(GTK_WINDOW(m_window), GTK_WIDGET(m_view));
     78#else
    7079    m_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    71     m_view = WKViewCreate(configuration);
    7280    gtk_container_add(GTK_CONTAINER(m_window), GTK_WIDGET(m_view));
    7381    gtk_widget_show(GTK_WIDGET(m_view));
     82#endif
    7483    gtk_widget_show(m_window);
    7584}
Note: See TracChangeset for help on using the changeset viewer.