Changeset 280966 in webkit
- Timestamp:
- Aug 12, 2021, 6:53:44 AM (5 years ago)
- Location:
- trunk/Tools
- Files:
-
- 1 deleted
- 4 edited
-
ChangeLog (modified) (1 diff)
-
TestWebKitAPI/Tests/WebKitGtk/AccessibilityTestServer.cpp (deleted)
-
TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp (modified) (7 diffs)
-
TestWebKitAPI/glib/PlatformGTK.cmake (modified) (1 diff)
-
TestWebKitAPI/glib/WebKitGLib/TestMain.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r280965 r280966 1 2021-08-12 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Simplify TestWebKitAccessibility 4 https://bugs.webkit.org/show_bug.cgi?id=229032 5 6 Reviewed by Michael Catanzaro. 7 8 We don't really need to have a different process to test a11y. We can remove AccessibilityTestServer and use the 9 same test executable. That way we don't need to spawn a process and use DBus for the communication. 10 11 * TestWebKitAPI/Tests/WebKitGtk/AccessibilityTestServer.cpp: Removed. 12 * TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp: 13 (AccessibilityTest::findTestApplication): Find the accessible application corresponding to the test executable. 14 (AccessibilityTest::waitUntilChildrenRemoved): Use the WebViewTest main loop. 15 (testAtspiBasicHierarchy): Use WebViewTest::loadHtml. 16 * TestWebKitAPI/glib/PlatformGTK.cmake: 17 * TestWebKitAPI/glib/WebKitGLib/TestMain.cpp: 18 (main): Set the program name to the executable name. It helps to a11y test to find the accessible app. 19 1 20 2021-08-12 Carlos Garcia Campos <cgarcia@igalia.com> 2 21 -
trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp
r249759 r280966 20 20 #include "config.h" 21 21 22 #include " TestMain.h"22 #include "WebViewTest.h" 23 23 24 24 // The libatspi headers don't use G_BEGIN_DECLS … … 27 27 } 28 28 29 class AccessibilityTest : public Test {29 class AccessibilityTest : public WebViewTest { 30 30 public: 31 31 MAKE_GLIB_TEST_FIXTURE(AccessibilityTest); 32 32 33 AccessibilityTest() 34 { 35 GUniquePtr<char> testServerPath(g_build_filename(WEBKIT_EXEC_PATH, "TestWebKitAPI", "WebKit2Gtk", "AccessibilityTestServer", nullptr)); 36 char* args[3]; 37 args[0] = testServerPath.get(); 38 args[1] = const_cast<char*>(g_dbus_server_get_client_address(s_dbusServer.get())); 39 args[2] = nullptr; 40 41 g_assert_true(g_spawn_async(nullptr, args, nullptr, G_SPAWN_DEFAULT, nullptr, nullptr, &m_childProcessID, nullptr)); 42 } 43 44 ~AccessibilityTest() 45 { 46 if (m_childProcessID) { 47 g_spawn_close_pid(m_childProcessID); 48 kill(m_childProcessID, SIGTERM); 49 } 50 } 51 52 void loadHTMLAndWaitUntilFinished(const char* html, const char* baseURI) 53 { 54 ensureProxy(); 55 56 GUniqueOutPtr<GError> error; 57 GRefPtr<GVariant> result = adoptGRef(g_dbus_proxy_call_sync(m_proxy.get(), "LoadHTML", 58 g_variant_new("(ss)", html, baseURI ? baseURI : ""), G_DBUS_CALL_FLAGS_NONE, -1, nullptr, &error.outPtr())); 59 g_assert_no_error(error.get()); 60 } 61 62 GRefPtr<AtspiAccessible> findTestServerApplication() 33 GRefPtr<AtspiAccessible> findTestApplication() 63 34 { 64 35 // Only one desktop is supported by ATSPI at the moment. 65 36 GRefPtr<AtspiAccessible> desktop = adoptGRef(atspi_get_desktop(0)); 66 37 38 // We can get warnings from atspi when trying to connect to applications. 39 Test::removeLogFatalFlag(G_LOG_LEVEL_WARNING); 67 40 int childCount = atspi_accessible_get_child_count(desktop.get(), nullptr); 41 Test::addLogFatalFlag(G_LOG_LEVEL_WARNING); 68 42 for (int i = 0; i < childCount; ++i) { 69 43 GRefPtr<AtspiAccessible> current = adoptGRef(atspi_accessible_get_child_at_index(desktop.get(), i, nullptr)); 70 if (!g_strcmp0(atspi_accessible_get_name(current.get(), nullptr), " AccessibilityTestServer"))44 if (!g_strcmp0(atspi_accessible_get_name(current.get(), nullptr), "TestWebKitAccessibility")) 71 45 return current; 72 46 } … … 108 82 auto* test = static_cast<AccessibilityTest*>(userData); 109 83 if (event->source == test->m_eventSource) 110 g_main_loop_quit(test->m_mainLoop .get());84 g_main_loop_quit(test->m_mainLoop); 111 85 }, this, nullptr)); 112 86 atspi_event_listener_register(listener.get(), "object:children-changed:remove", nullptr); 113 g_main_loop_run(m_mainLoop .get());87 g_main_loop_run(m_mainLoop); 114 88 m_eventSource = nullptr; 115 89 } 116 90 117 91 private: 118 void ensureProxy()119 {120 if (m_proxy)121 return;122 123 m_mainLoop = adoptGRef(g_main_loop_new(nullptr, FALSE));124 125 if (s_dbusConnections.isEmpty()) {126 g_idle_add([](gpointer userData) -> gboolean {127 if (s_dbusConnections.isEmpty())128 return TRUE;129 130 g_main_loop_quit(static_cast<GMainLoop*>(userData));131 return FALSE;132 }, m_mainLoop.get());133 g_main_loop_run(m_mainLoop.get());134 }135 136 m_proxy = adoptGRef(g_dbus_proxy_new_sync(s_dbusConnections[0].get(), static_cast<GDBusProxyFlags>(G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS),137 nullptr, nullptr, "/org/webkit/gtk/AccessibilityTest", "org.webkit.gtk.AccessibilityTest", nullptr, nullptr));138 g_assert_true(G_IS_DBUS_PROXY(m_proxy.get()));139 }140 141 GPid m_childProcessID { 0 };142 GRefPtr<GDBusProxy> m_proxy;143 GRefPtr<GMainLoop> m_mainLoop;144 92 AtspiAccessible* m_eventSource { nullptr }; 145 93 }; … … 147 95 static void testAtspiBasicHierarchy(AccessibilityTest* test, gconstpointer) 148 96 { 149 test->loadHTMLAndWaitUntilFinished( 97 test->showInWindow(); 98 test->loadHtml( 150 99 "<html>" 151 100 " <body>" … … 156 105 "</html>", 157 106 nullptr); 107 test->waitUntilLoadFinished(); 158 108 159 auto test ServerApp = test->findTestServerApplication();160 g_assert_true(ATSPI_IS_ACCESSIBLE(test ServerApp.get()));161 GUniquePtr<char> name(atspi_accessible_get_name(test ServerApp.get(), nullptr));162 g_assert_cmpstr(name.get(), ==, " AccessibilityTestServer");163 g_assert_cmpint(atspi_accessible_get_role(test ServerApp.get(), nullptr), ==, ATSPI_ROLE_APPLICATION);109 auto testApp = test->findTestApplication(); 110 g_assert_true(ATSPI_IS_ACCESSIBLE(testApp.get())); 111 GUniquePtr<char> name(atspi_accessible_get_name(testApp.get(), nullptr)); 112 g_assert_cmpstr(name.get(), ==, "TestWebKitAccessibility"); 113 g_assert_cmpint(atspi_accessible_get_role(testApp.get(), nullptr), ==, ATSPI_ROLE_APPLICATION); 164 114 165 auto rootObject = test->findRootObject(test ServerApp.get());115 auto rootObject = test->findRootObject(testApp.get()); 166 116 g_assert_true(ATSPI_IS_ACCESSIBLE(rootObject.get())); 167 117 g_assert_cmpint(atspi_accessible_get_role(rootObject.get(), nullptr), ==, ATSPI_ROLE_FILLER); … … 195 145 g_assert_cmpint(atspi_accessible_get_role(link.get(), nullptr), ==, ATSPI_ROLE_LINK); 196 146 197 test->loadH TMLAndWaitUntilFinished(147 test->loadHtml( 198 148 "<html>" 199 149 " <body>" … … 203 153 "</html>", 204 154 nullptr); 205 206 155 // Check that children-changed::remove is emitted on the root object on navigation, 207 156 // and the a11y hierarchy is updated. 208 157 test->waitUntilChildrenRemoved(rootObject.get()); 209 158 210 documentWeb = test->findDocumentWeb(test ServerApp.get());159 documentWeb = test->findDocumentWeb(testApp.get()); 211 160 g_assert_true(ATSPI_IS_ACCESSIBLE(documentWeb.get())); 212 161 g_assert_cmpint(atspi_accessible_get_role(documentWeb.get(), nullptr), ==, ATSPI_ROLE_DOCUMENT_WEB); -
trunk/Tools/TestWebKitAPI/glib/PlatformGTK.cmake
r276645 r280966 49 49 50 50 if (ATSPI_FOUND) 51 ADD_WK2_TEST(AccessibilityTestServer ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGtk/AccessibilityTestServer.cpp)52 51 ADD_WK2_TEST(TestWebKitAccessibility ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp) 53 52 endif () -
trunk/Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.cpp
r280155 r280966 22 22 23 23 #include <glib/gstdio.h> 24 #include <wtf/glib/GLibUtilities.h> 24 25 25 26 #if PLATFORM(GTK) … … 124 125 g_test_init(&argc, &argv, nullptr); 125 126 #endif 127 g_set_prgname(getCurrentExecutableName().data()); 126 128 g_setenv("WEBKIT_EXEC_PATH", WEBKIT_EXEC_PATH, FALSE); 127 129 g_setenv("WEBKIT_INJECTED_BUNDLE_PATH", WEBKIT_INJECTED_BUNDLE_PATH, FALSE);
Note:
See TracChangeset
for help on using the changeset viewer.