From 868a618878f8ab13967e100c76dc04ca100e7882 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Thu, 26 Jun 2025 12:07:02 +0200 Subject: [PATCH] sw java a11y test: Avoid disposing object still being tested With upcoming Change-Id: I2b75ccd3eed57f276feab303d63038299ceb90d7 Author: Michael Weghorn Date: Wed Jun 25 12:51:52 2025 +0200 sw a11y: Let SwAccessibleContext subclass OAccessible , the SwAccessibleTextGraphicObject java a11y test was seen failing when running the JunitTest_sw_unoapi_1 test suite as can be seen in the CI log [1] (relevant part below). This is because with the above-mentioned commit in place, the XAccessible::getAccessibleContext implementation for SwAccessibleContext and subclasses throws a DisposedException if the object has already been disposed, while that was not the case previously. That seems fair, however. The problem in the SwAccessibleTextGraphicObject test is that the XAccessibleEventListener tests resulted in the object getting disposed, and the already disposed object would then be used in the following test of the XAccessible interface. Stop changing view zoom settings to trigger accessible events, which was the trigger for disposing the object, as Writer only exposes objects visible on screen as part of its a11y hierarchy. Backtrace of how the object was previously disposed: 1 comphelper::OAccessible::disposing OAccessible.cxx 55 0x7ff4676d54d1 2 cppu::WeakComponentImplHelperBase::dispose implbase.cxx 104 0x7ff46713dbf0 3 cppu::PartialWeakComponentImplHelper::dispose compbase.hxx 90 0x7ff43608ccd5 4 SwAccessibleContext::Dispose acccontext.cxx 956 0x7ff43609a284 5 SwAccessibleFrameBase::Dispose accframebase.cxx 230 0x7ff4360b40a3 6 SwAccessibleNoTextFrame::Dispose accnotextframe.cxx 128 0x7ff436111b23 7 SwAccessibleContext::ScrolledOut acccontext.cxx 311 0x7ff436095972 8 SwAccessibleContext::ChildrenScrolled acccontext.cxx 169 0x7ff43609508b 9 SwAccessibleContext::ChildrenScrolled acccontext.cxx 228 0x7ff43609540d 10 SwAccessibleContext::Scrolled acccontext.cxx 237 0x7ff4360954fb 11 SwAccessibleDocumentBase::SetVisArea accdoc.cxx 88 0x7ff4360a326a 12 SwAccessibleMap::GetDocumentView_ accmap.cxx 1638 0x7ff4360c9762 13 SwAccessibleMap::GetDocumentView accmap.cxx 1646 0x7ff4360ca24b 14 SwViewShellImp::UpdateAccessible viewimp.cxx 369 0x7ff437315e08 15 SwViewShell::VisPortChgd viewsh.cxx 1466 0x7ff4373224fd 16 SwCursorShell::VisPortChgd crsrsh.cxx 1850 0x7ff43626b931 17 SwView::SetVisArea viewport.cxx 249 0x7ff437a8f5ab 18 SwView::CalcVisArea viewport.cxx 818 0x7ff437a92efa 19 SwView::SetZoom_ viewmdi.cxx 205 0x7ff437a8bcaa 20 SwView::SetZoom viewmdi.cxx 74 0x7ff437a8ac70 21 SwXViewSettings::_postSetValues unomod.cxx 765 0x7ff437afe542 22 comphelper::ChainablePropertySet::setPropertyValue ChainablePropertySet.cxx 66 0x7ff46780a6fe 23 gcc3::callVirtualMethod callvirtualmethod.cxx 87 0x7ff4578ee2cd 24 cpp_call uno2cpp.cxx 229 0x7ff4578ed03b 25 unoInterfaceProxyDispatch uno2cpp.cxx 409 0x7ff4578ec806 26 binaryurp::IncomingRequest::execute_throw incomingrequest.cxx 236 0x7ff456cd0a9c 27 binaryurp::IncomingRequest::execute incomingrequest.cxx 79 0x7ff456ccf060 28 request reader.cxx 86 0x7ff456cf9ae3 29 cppu_threadpool::JobQueue::enter jobqueue.cxx 100 0x7ff46897e96e 30 cppu_threadpool::ORequestThread::run thread.cxx 165 0x7ff46898585c 31 threadFunc thread.hxx 189 0x7ff468989d3e 32 osl_thread_start_Impl thread.cxx 237 0x7ff4694774ab 33 start_thread pthread_create.c 448 0x7ff468e9cb7b 34 clone clone.S 100 0x7ff468f1a5f0 Instead, change the graphic object's title/name to trigger an AccessibleEventId::NameChanged event instead, see the SfxHintId::SwTitleChanged case in AccessibleNoTextFrame::Notify. Relevant part of output for failed test without this change in place: *************************************************** Creating: sw.SwAccessibleTextGraphicObject LOG> Log started 26.05.2025 - 01:14:13 LOG> creating a text document LOG> inserting graphic LOG> ImplementationName Unknown, does not implement XServiceInfo Environment created LOG> Log started 26.05.2025 - 01:14:14 checking: [sw.SwAccessibleTextGraphicObject::com::sun::star::accessibility::XAccessibleEventBroadcaster] is iface: [com.sun.star.accessibility.XAccessibleEventBroadcaster] testcode: [ifc.accessibility._XAccessibleEventBroadcaster] LOG> Execute: addEventListener() LOG> adding listener LOG> fire event LOG> Listener, Event : 10 EventID: 10 LOG> Listener, Event : 10 EventID: 10 LOG> Listener, Event : 10 EventID: 10 LOG> Listener, Event : 4 EventID: 4 Method addEventListener() finished with state OK LOG> addEventListener(): COMPLETED.OK LOG> Execute: removeEventListener() LOG> starting required method: addEventListener() LOG> remove listener LOG> fire event LOG> listener wasn't called -- OK Method removeEventListener() finished with state OK LOG> removeEventListener(): COMPLETED.OK ***** State for sw.SwAccessibleTextGraphicObject::com::sun::star::accessibility::XAccessibleEventBroadcaster ****** Whole interface: COMPLETED.OK ******************************************************************************************************************* LOG> Log started 26.05.2025 - 01:14:14 checking: [sw.SwAccessibleTextGraphicObject::com::sun::star::accessibility::XAccessible] is iface: [com.sun.star.accessibility.XAccessible] testcode: [ifc.accessibility._XAccessible] LOG> Execute: getAccessibleContext() com.sun.star.lang.DisposedException: at /home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_clang_dbgutil_64/comphelper/source/misc/OAccessible.cxx:140 at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:158) at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:122) at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:312) at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:281) at com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:81) at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:619) at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:145) at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:129) at jdk.proxy2/jdk.proxy2.$Proxy39.getAccessibleContext(Unknown Source) at ifc.accessibility._XAccessible._getAccessibleContext(_XAccessible.java:44) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:569) at lib.MultiMethodTest.invokeTestMethod(MultiMethodTest.java:386) at lib.MultiMethodTest.callMethod(MultiMethodTest.java:364) at lib.MultiMethodTest.executeMethod(MultiMethodTest.java:352) at lib.MultiMethodTest.run(MultiMethodTest.java:216) at base.java_fat.executeInterfaceTest(java_fat.java:445) at base.java_fat.executeTest(java_fat.java:185) at org.openoffice.Runner.run(Runner.java:175) at org.openoffice.test.UnoApiTest.test(UnoApiTest.java:41) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:569) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:52) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runners.Suite.runChild(Suite.java:128) at org.junit.runners.Suite.runChild(Suite.java:27) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at org.junit.runner.JUnitCore.run(JUnitCore.java:115) at org.junit.runner.JUnitCore.runMain(JUnitCore.java:77) at org.junit.runner.JUnitCore.main(JUnitCore.java:36) LOG> getAccessibleContext(): at /home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_clang_dbgutil_64/comphelper/source/misc/OAccessible.cxx:140.FAILED ***** State for sw.SwAccessibleTextGraphicObject::com::sun::star::accessibility::XAccessible ****** [sw.SwAccessibleTextGraphicObject::com::sun::star::accessibility::XAccessible::getAccessibleContext()] is testcode: [getAccessibleContext()] - at /home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_clang_dbgutil_64/comphelper/source/misc/OAccessible.cxx:140.FAILED Whole interface: COMPLETED.FAILED [1] https://ci.libreoffice.org/job/gerrit_linux_clang_dbgutil/185066/console Change-Id: I6ed2f1c32517b60aa981de60aa4df4abc41cc0b0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187036 Reviewed-by: Michael Weghorn Tested-by: Jenkins --- .../mod/_sw/SwAccessibleTextGraphicObject.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleTextGraphicObject.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleTextGraphicObject.java index 0467a44554cc..ff4a87b13da4 100644 --- a/qadevOOo/tests/java/mod/_sw/SwAccessibleTextGraphicObject.java +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleTextGraphicObject.java @@ -38,6 +38,7 @@ import com.sun.star.text.XText; import com.sun.star.text.XTextContent; import com.sun.star.text.XTextCursor; import com.sun.star.text.XTextDocument; +import com.sun.star.uno.AnyConverter; import com.sun.star.uno.UnoRuntime; import com.sun.star.view.XViewSettingsSupplier; @@ -92,20 +93,17 @@ public class SwAccessibleTextGraphicObject extends TestCase { TestEnvironment tEnv = new TestEnvironment(xGraphicAcc); - XController xController = xTextDoc.getCurrentController(); - XViewSettingsSupplier xViewSetSup = UnoRuntime.queryInterface(XViewSettingsSupplier.class, - xController); - - final XPropertySet PropSet = xViewSetSup.getViewSettings(); + final XPropertySet propSet = UnoRuntime.queryInterface(XPropertySet.class, oGraphObj); tEnv.addObjRelation("EventProducer", new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { public void fireEvent() { try { - //change zoom value to 20% - PropSet.setPropertyValue("ZoomValue", Short.valueOf("20")); - //and back to 100% - PropSet.setPropertyValue("ZoomValue", Short.valueOf("100")); + // temporarily set a different object name/title + String title = AnyConverter.toString(propSet.getPropertyValue("Title")); + propSet.setPropertyValue("Title", "New Title"); + // set back original value + propSet.setPropertyValue("Title", title); } catch ( com.sun.star.lang.WrappedTargetException e ) { } catch ( com.sun.star.lang.IllegalArgumentException e ) {