[Libreoffice-commits] core.git: framework/JunitTest_framework_complex.mk framework/qa

Michael Meeks michael.meeks at collabora.com
Thu Jan 7 09:02:25 PST 2016


 framework/JunitTest_framework_complex.mk              |    6 -
 framework/qa/complex/dispatches/Interceptor.java      |   51 +++++++++++---
 framework/qa/complex/dispatches/checkdispatchapi.java |   64 +++++-------------
 3 files changed, 63 insertions(+), 58 deletions(-)

New commits:
commit 3825c28416a52abbbba2bb8034346b1c3f956da2
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Jan 7 14:23:32 2016 +0000

    framework: restore dispatch API test.
    
    Change-Id: I8a78fee2b43c67feaffb8dbbcd36e96743ca2c9c
    Reviewed-on: https://gerrit.libreoffice.org/21208
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/framework/JunitTest_framework_complex.mk b/framework/JunitTest_framework_complex.mk
index a361053..0090194 100644
--- a/framework/JunitTest_framework_complex.mk
+++ b/framework/JunitTest_framework_complex.mk
@@ -62,21 +62,19 @@ $(eval $(call gb_JunitTest_add_sourcefiles,framework_complex,\
     framework/qa/complex/imageManager/_XUIConfigurationPersistence \
     framework/qa/complex/imageManager/_XUIConfiguration \
     framework/qa/complex/api_internal/CheckAPI \
+	framework/qa/complex/dispatches/checkdispatchapi \
     framework/qa/complex/dispatches/Interceptor \
     framework/qa/complex/ModuleManager/CheckXModuleManager \
 ))
 
-# does not build
-#	framework/qa/complex/dispatches/checkdispatchapi \
-
 $(eval $(call gb_JunitTest_add_classes,framework_complex,\
+    complex.dispatches.checkdispatchapi \
 ))
 # these were disabled in the old build system too, please check
 # carefully before reenabling
 #	complex.ModuleManager.CheckXModuleManager \
     complex.XUserInputInterception.EventTest \
     complex.accelerators.AcceleratorsConfigurationTest \
-    complex.dispatches.checkdispatchapi \
     complex.api_internal.CheckAPI \
     complex.broken_document.LoadDocument \
     complex.desktop.DesktopTerminate \
diff --git a/framework/qa/complex/dispatches/Interceptor.java b/framework/qa/complex/dispatches/Interceptor.java
index 40e8f24..bac4318 100644
--- a/framework/qa/complex/dispatches/Interceptor.java
+++ b/framework/qa/complex/dispatches/Interceptor.java
@@ -1,4 +1,4 @@
-/*
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-/*
  * This file is part of the LibreOffice project.
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -30,11 +30,12 @@ import com.sun.star.frame.XDispatchProviderInterceptor;
 import com.sun.star.frame.XInterceptorInfo;
 import com.sun.star.frame.XStatusListener;
 
-// interfaces
-
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.awt.XDataTransferProviderAccess;
 
 // helper
 import com.sun.star.util.URL;
+import com.sun.star.uno.UnoRuntime;
 
 // __________ Implementation __________
 
@@ -45,8 +46,6 @@ public class Interceptor implements XDispatch,
                                     XDispatchProviderInterceptor,
                                     XInterceptorInfo
 {
-
-
     /** contains the list of interception URL schema's (wildcards are allowed there!)
         supported by this interceptor. It can be set from outside.
         If no external URLs are set, the default "*" is used instead.
@@ -93,7 +92,13 @@ public class Interceptor implements XDispatch,
      */
     private boolean m_bIsRegistered = false;
 
+    /** points to the global uno service manager. */
+    private XMultiServiceFactory m_xMSF = null;
 
+    public Interceptor(XMultiServiceFactory xMSF)
+    {
+        m_xMSF = xMSF;
+    }
 
 
     /** XInterceptorInfo */
@@ -140,8 +145,6 @@ public class Interceptor implements XDispatch,
         m_xSlave = xSlave;
     }
 
-
-
     /** XDispatchProviderInterceptor */
     public synchronized void setMasterDispatchProvider(XDispatchProvider xMaster)
     {
@@ -149,16 +152,42 @@ public class Interceptor implements XDispatch,
         m_xMaster = xMaster;
     }
 
+    private XDataTransferProviderAccess m_xToolkit = null;
 
+    /** A beautiful method whose only purpose is to take and release a
+     * solar mutex. If this hangs - you can see a beautiful deadlock
+     * when you attach your debugger to the main process.
+     */
+    public void checkNoSolarMutexHeld()
+    {
+/*      disabled until the bugs here are fixed.
+
+        try
+        {
+            if (m_xToolkit == null)
+                m_xToolkit = UnoRuntime.queryInterface(
+                    XDataTransferProviderAccess.class,
+                    m_xMSF.createInstance("com.sun.star.awt.Toolkit"));
+
+            // A Method notable only for taking the solar mutex.
+            m_xToolkit.getDragSource( null );
+        } catch (java.lang.Throwable ex) {
+                System.out.println("Failed to createa and invoke toolkit method " + ex.toString());
+        } */
+    }
 
     /** XDispatchProvider
      */
-    public synchronized XDispatch queryDispatch(URL aURL            ,
-                                                                   String                sTargetFrameName,
-                                                                   int                   nSearchFlags    )
+    public synchronized XDispatch queryDispatch(URL    aURL,
+                                                String sTargetFrameName,
+                                                int    nSearchFlags)
     {
         System.out.println("Interceptor.queryDispatch('"+aURL.Complete+"', '"+sTargetFrameName+"', "+nSearchFlags+") called");
 
+        checkNoSolarMutexHeld();
+
+        System.out.println("Interceptor.queryDispatch - re-entered successfully");
+
         if (impl_isBlockedURL(aURL.Complete))
         {
             System.out.println("Interceptor.queryDispatch(): URL blocked => returns NULL");
@@ -307,3 +336,5 @@ public class Interceptor implements XDispatch,
         return sVal1.equals(sVal2);
     }
 }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/qa/complex/dispatches/checkdispatchapi.java b/framework/qa/complex/dispatches/checkdispatchapi.java
index c1b52b2..b55659c 100644
--- a/framework/qa/complex/dispatches/checkdispatchapi.java
+++ b/framework/qa/complex/dispatches/checkdispatchapi.java
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /*
  * This file is part of the LibreOffice project.
  *
@@ -38,8 +39,6 @@ import org.junit.Test;
 import org.openoffice.test.OfficeConnection;
 import static org.junit.Assert.*;
 
-
-
 /** @short  Check the interface XDispatchInformationProvider
 
 @descr  Because there exists more than one implementation of a dispatch
@@ -47,14 +46,12 @@ object, we have to test all these implementations ...
  */
 public class checkdispatchapi
 {
-
-    // some const
-
-
     // member
     /** points to the global uno service manager. */
     private XMultiServiceFactory m_xMSF = null;
-    private connectivity.tools.HsqlDatabase db;
+
+//    private connectivity.tools.HsqlDatabase db;
+
     /** can be used to create new test frames. */
     private XFrame m_xDesktop = null;
     /** provides XDispatchInformationProvider interface. */
@@ -73,7 +70,7 @@ public class checkdispatchapi
         // get uno service manager from global test environment
         m_xMSF = getMSF();
 
-        db = new connectivity.tools.HsqlDatabase(m_xMSF);
+//        db = new connectivity.tools.HsqlDatabase(m_xMSF);
 
         // create desktop
         m_xDesktop = UnoRuntime.queryInterface(XFrame.class, m_xMSF.createInstance("com.sun.star.frame.Desktop"));
@@ -81,97 +78,84 @@ public class checkdispatchapi
         m_xFrame = impl_createNewFrame();
     }
 
-
     /** @short  close the environment.
      */
     @After public void after() throws Exception
     {
-        db.close();
+//        db.close();
         impl_closeFrame(m_xFrame);
         m_xFrame = null;
     }
 
-
     @Test public void checkDispatchInfoOfWriter() throws Exception
     {
         impl_checkDispatchInfoOfXXX("private:factory/swriter");
     }
 
-
     @Test public void checkDispatchInfoOfCalc() throws Exception
     {
         impl_checkDispatchInfoOfXXX("private:factory/scalc");
     }
 
-
     @Test public void checkDispatchInfoOfDraw() throws Exception
     {
         impl_checkDispatchInfoOfXXX("private:factory/sdraw");
     }
 
-
     @Test public void checkDispatchInfoOfImpress() throws Exception
     {
         impl_checkDispatchInfoOfXXX("private:factory/simpress");
     }
 
-
     @Test public void checkDispatchInfoOfChart() throws Exception
     {
         impl_checkDispatchInfoOfXXX("private:factory/schart");
     }
 
-
     @Test public void checkDispatchInfoOfMath() throws Exception
     {
         impl_checkDispatchInfoOfXXX("private:factory/smath");
     }
 
-
     @Test public void checkDispatchInfoOfDataBase() throws Exception
     {
-        impl_checkDispatchInfoOfXXX("private:factory/sdatabase");
+//        impl_checkDispatchInfoOfXXX("private:factory/sdatabase");
     }
 
-
     @Test public void checkDispatchInfoOfBibliography() throws Exception
     {
-        impl_checkDispatchInfoOfXXX(".component:Bibliography/View1");
+//        impl_checkDispatchInfoOfXXX(".component:Bibliography/View1");
     }
 
-
     @Test public void checkDispatchInfoOfQueryDesign()
     {
-        callDatabaseDispatch(".component:DB/QueryDesign");
+//        callDatabaseDispatch(".component:DB/QueryDesign");
     }
 
-
     @Test public void checkDispatchInfoOfTableDesign() throws Exception
     {
-        callDatabaseDispatch(".component:DB/TableDesign");
+//        callDatabaseDispatch(".component:DB/TableDesign");
     }
 
-
     @Test public void checkDispatchInfoOfFormGridView() throws Exception
     {
-        impl_checkDispatchInfoOfXXX(".component:DB/FormGridView");
+//        impl_checkDispatchInfoOfXXX(".component:DB/FormGridView");
     }
 
-
     @Test public void checkDispatchInfoOfDataSourceBrowser() throws Exception
     {
-        impl_checkDispatchInfoOfXXX(".component:DB/DataSourceBrowser");
+//        impl_checkDispatchInfoOfXXX(".component:DB/DataSourceBrowser");
     }
 
-
     @Test public void checkDispatchInfoOfRelationDesign()
     {
-        callDatabaseDispatch(".component:DB/RelationDesign");
+//        callDatabaseDispatch(".component:DB/RelationDesign");
     }
 
-
     private void callDatabaseDispatch(String url)
     {
+/*        disabled along with all db related tests for now.
+
         try
         {
             final PropertyValue args = new PropertyValue();
@@ -189,31 +173,28 @@ public class checkdispatchapi
         }
         catch (java.lang.Exception e)
         {
-        }
+        } */
     }
 
-
     @Test public void checkDispatchInfoOfBasic() throws Exception
     {
         Object aComponent = impl_createUNOComponent("com.sun.star.script.BasicIDE");
         impl_checkDispatchInfo(aComponent);
     }
 
-
     @Test public void checkDispatchInfoOfStartModule() throws Exception
     {
         Object aComponent = impl_createUNOComponent("com.sun.star.frame.StartModule");
         impl_checkDispatchInfo(aComponent);
     }
 
-
     public void checkInterceptorLifeTime() throws Exception
     {
         // Note: It's important for the following test, that aInterceptor will be hold alive by the uno reference
         // xInterceptor. Otherwhise we can't check some internal states of aInterceptor at the end of this method, because
         // it was already killed .-)
 
-        Interceptor aInterceptor = new Interceptor();
+        Interceptor aInterceptor = new Interceptor(m_xMSF);
         XDispatchProviderInterceptor xInterceptor = UnoRuntime.queryInterface(XDispatchProviderInterceptor.class, aInterceptor);
 
         XFrame xFrame = impl_createNewFrame();
@@ -241,13 +222,12 @@ public class checkdispatchapi
         System.out.println("Destruction of interception chain works as designed .-)");
     }
 
-
     public void checkInterception() throws Exception
     {
         String[] lDisabledURLs = new String[] { ".uno:Open" };
 
         System.out.println("create and initialize interceptor ...");
-        Interceptor aInterceptor = new Interceptor();
+        Interceptor aInterceptor = new Interceptor(m_xMSF);
         aInterceptor.setURLs4URLs4Blocking(lDisabledURLs);
 
         XDispatchProviderInterceptor xInterceptor = UnoRuntime.queryInterface(XDispatchProviderInterceptor.class, aInterceptor);
@@ -265,7 +245,6 @@ public class checkdispatchapi
         xInterception.releaseDispatchProviderInterceptor(xInterceptor);
     }
 
-
     private void impl_checkDispatchInfoOfXXX(String sXXX) throws Exception
     {
         XFrame xFrame = impl_createNewFrame();
@@ -274,7 +253,6 @@ public class checkdispatchapi
         impl_closeFrame(xFrame);
     }
 
-
     /** @short  load an URL into the current test frame.
      */
     private void impl_loadIntoFrame(XFrame xFrame, String sURL, PropertyValue args[]) throws Exception
@@ -293,7 +271,6 @@ public class checkdispatchapi
         }
     }
 
-
     /** @short  create an uno implementation directly.
      */
     private Object impl_createUNOComponent(String sName)
@@ -315,7 +292,6 @@ public class checkdispatchapi
         return aComponent;
     }
 
-
     /** @short  check the interface XDispatchInformationProvider
     at the specified component.
      */
@@ -372,7 +348,6 @@ public class checkdispatchapi
         }
     }
 
-
     private synchronized XFrame impl_createNewFrame()
     {
         XFrame xFrame = m_xDesktop.findFrame("_blank", 0);
@@ -380,7 +355,6 @@ public class checkdispatchapi
         return xFrame;
     }
 
-
     private synchronized void impl_closeFrame(XFrame xFrame) throws Exception
     {
         XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xFrame);
@@ -409,3 +383,5 @@ public class checkdispatchapi
     }
     private static final OfficeConnection connection = new OfficeConnection();
 }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list