From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:51:28 +0200 Subject: Adding upstream version 1:7.0.4. Signed-off-by: Daniel Baumann --- .../complex/ModuleManager/CheckXModuleManager.java | 330 +++++++++++++++++++++ 1 file changed, 330 insertions(+) create mode 100644 framework/qa/complex/ModuleManager/CheckXModuleManager.java (limited to 'framework/qa/complex/ModuleManager') diff --git a/framework/qa/complex/ModuleManager/CheckXModuleManager.java b/framework/qa/complex/ModuleManager/CheckXModuleManager.java new file mode 100644 index 000000000..1015d00c2 --- /dev/null +++ b/framework/qa/complex/ModuleManager/CheckXModuleManager.java @@ -0,0 +1,330 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.ModuleManager; + +import com.sun.star.beans.*; +import com.sun.star.frame.*; +import com.sun.star.lang.*; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.*; +import com.sun.star.container.*; + + + +// ---------- junit imports ----------------- +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; + + + +/** @short todo document me + */ +public class CheckXModuleManager +{ + + // some const + + + // member + + /** points to the global uno service manager. */ + private XMultiServiceFactory m_xSmgr = null; + + /** the module manager for testing. */ + private XModuleManager m_xMM = null; + + /** a special frame used to load documents there. */ + private XComponentLoader m_xLoader = null; + + + // test environment + + + /** @short Create the environment for following tests. + + @descr Use either a component loader from desktop or + from frame + */ + @Before public void before() + throws java.lang.Exception + { + // get uno service manager from global test environment + m_xSmgr = getMSF(); + + // create module manager + m_xMM = UnoRuntime.queryInterface(XModuleManager.class, m_xSmgr.createInstance("com.sun.star.frame.ModuleManager")); + + // create desktop instance to create a special frame to load documents there. + XFrame xDesktop = UnoRuntime.queryInterface(XFrame.class, m_xSmgr.createInstance("com.sun.star.frame.Desktop")); + + m_xLoader = UnoRuntime.queryInterface(XComponentLoader.class, xDesktop.findFrame("_blank", 0)); + } + + + /** @short close the environment. + */ + @After public void after() + throws java.lang.Exception + { + XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, m_xLoader); + xClose.close(false); + + m_xLoader = null; + m_xMM = null; + m_xSmgr = null; + } + + + /** @todo document me + */ + @Test public void checkModuleIdentification() + throws java.lang.Exception + { + impl_identifyModulesBasedOnDocs("com.sun.star.text.TextDocument" ); + impl_identifyModulesBasedOnDocs("com.sun.star.text.WebDocument" ); + impl_identifyModulesBasedOnDocs("com.sun.star.text.GlobalDocument" ); + impl_identifyModulesBasedOnDocs("com.sun.star.formula.FormulaProperties" ); + impl_identifyModulesBasedOnDocs("com.sun.star.sheet.SpreadsheetDocument" ); + impl_identifyModulesBasedOnDocs("com.sun.star.drawing.DrawingDocument" ); + impl_identifyModulesBasedOnDocs("com.sun.star.presentation.PresentationDocument"); + impl_identifyModulesBasedOnDocs("com.sun.star.sdb.OfficeDatabaseDocument" ); + // TODO: fails + // impl_identifyModulesBasedOnDocs("com.sun.star.chart.ChartDocument" ); + } + + + /** @todo document me + */ + @Test public void checkModuleConfigurationReadable() + throws java.lang.Exception + { + } + + + /** @todo document me + */ + @Test public void checkModuleConfigurationWriteable() + throws java.lang.Exception + { + // modules supporting real documents + impl_checkReadOnlyPropsOfModule("com.sun.star.text.TextDocument" ); + impl_checkReadOnlyPropsOfModule("com.sun.star.text.WebDocument" ); + impl_checkReadOnlyPropsOfModule("com.sun.star.text.GlobalDocument" ); + impl_checkReadOnlyPropsOfModule("com.sun.star.formula.FormulaProperties" ); + impl_checkReadOnlyPropsOfModule("com.sun.star.sheet.SpreadsheetDocument" ); + impl_checkReadOnlyPropsOfModule("com.sun.star.drawing.DrawingDocument" ); + impl_checkReadOnlyPropsOfModule("com.sun.star.presentation.PresentationDocument"); + impl_checkReadOnlyPropsOfModule("com.sun.star.sdb.OfficeDatabaseDocument" ); + impl_checkReadOnlyPropsOfModule("com.sun.star.chart.ChartDocument" ); + + // other modules + impl_checkReadOnlyPropsOfModule("com.sun.star.sdb.FormDesign" ); + impl_checkReadOnlyPropsOfModule("com.sun.star.sdb.TextReportDesign" ); + impl_checkReadOnlyPropsOfModule("com.sun.star.sdb.RelationDesign" ); + impl_checkReadOnlyPropsOfModule("com.sun.star.sdb.QueryDesign" ); + impl_checkReadOnlyPropsOfModule("com.sun.star.sdb.TableDesign" ); + impl_checkReadOnlyPropsOfModule("com.sun.star.sdb.DataSourceBrowser"); + impl_checkReadOnlyPropsOfModule("com.sun.star.frame.Bibliography" ); + impl_checkReadOnlyPropsOfModule("com.sun.star.script.BasicIDE" ); + impl_checkReadOnlyPropsOfModule("com.sun.star.frame.StartModule" ); + } + + + /** @todo document me + */ + @Test public void checkModuleConfigurationQueries() + throws java.lang.Exception + { + impl_searchModulesByDocumentService("com.sun.star.text.TextDocument" ); + impl_searchModulesByDocumentService("com.sun.star.text.WebDocument" ); + impl_searchModulesByDocumentService("com.sun.star.text.GlobalDocument" ); + impl_searchModulesByDocumentService("com.sun.star.formula.FormulaProperties" ); + impl_searchModulesByDocumentService("com.sun.star.sheet.SpreadsheetDocument" ); + impl_searchModulesByDocumentService("com.sun.star.drawing.DrawingDocument" ); + impl_searchModulesByDocumentService("com.sun.star.presentation.PresentationDocument"); + impl_searchModulesByDocumentService("com.sun.star.sdb.OfficeDatabaseDocument" ); + impl_searchModulesByDocumentService("com.sun.star.chart.ChartDocument" ); + } + + + /** @todo document me + */ + private void impl_searchModulesByDocumentService(String sDocumentService) + throws java.lang.Exception + { + System.out.println("search modules matching document service '"+sDocumentService+"' ..."); + + NamedValue[] lProps = new NamedValue[1]; + lProps[0] = new NamedValue(); + lProps[0].Name = "ooSetupFactoryDocumentService"; + lProps[0].Value = sDocumentService; + + XContainerQuery xMM = UnoRuntime.queryInterface(XContainerQuery.class, m_xMM); + XEnumeration xResult = xMM.createSubSetEnumerationByProperties(lProps); + while(xResult.hasMoreElements()) + { + PropertyValue[] lModuleProps = (PropertyValue[])AnyConverter.toArray(xResult.nextElement()); + int c = lModuleProps.length; + int i = 0; + String sFoundModule = ""; + String sFoundDocService = ""; + for (i=0; i