From 26cbb045a06c4027bd7b446d692c3b38297d0283 Mon Sep 17 00:00:00 2001 From: Jens Carl Date: Mon, 28 Feb 2022 23:54:54 -0800 Subject: tdf#45904 Move XComponent Java test to C++ Move XComponent Jave tests to C++ for ScCellFieldObj_Cell and ScCellFieldObj_Header (formerly ScCellFieldObj). Change-Id: Ibf293a72801720fee49acdda5a3a463e9202bb58 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130742 Tested-by: Jenkins Reviewed-by: Jens Carl --- framework/qa/complex/api_internal/api.lst | 1 - qadevOOo/Jar_OOoRunner.mk | 1 - .../sc/com.sun.star.comp.office.ScCellFieldObj.csv | 3 - qadevOOo/tests/java/mod/_sc/ScCellFieldObj.java | 158 --------------------- sc/qa/extras/sceditfieldobj-cell.cxx | 8 ++ sc/qa/extras/sceditfieldobj-header.cxx | 8 ++ sc/qa/unoapi/sc_2.sce | 1 - 7 files changed, 16 insertions(+), 164 deletions(-) delete mode 100644 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellFieldObj.csv delete mode 100644 qadevOOo/tests/java/mod/_sc/ScCellFieldObj.java diff --git a/framework/qa/complex/api_internal/api.lst b/framework/qa/complex/api_internal/api.lst index b588cfd18b4b..6854643155be 100644 --- a/framework/qa/complex/api_internal/api.lst +++ b/framework/qa/complex/api_internal/api.lst @@ -72,7 +72,6 @@ job72=sc.ScAccessiblePageHeader job73=sc.ScAccessiblePreviewTable job74=sc.ScAccessibleSpreadsheet job78=sc.ScAutoFormatFieldObj -job81=sc.ScCellFieldObj job88=sc.ScDatabaseRangeObj job98=sc.ScHeaderFieldObj job126=sc.ScSheetLinkObj diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk index 4b91eee49fd4..38a0b628ed4d 100644 --- a/qadevOOo/Jar_OOoRunner.mk +++ b/qadevOOo/Jar_OOoRunner.mk @@ -944,7 +944,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\ qadevOOo/tests/java/mod/_sc/ScAnnotationTextCursor \ qadevOOo/tests/java/mod/_sc/ScAutoFormatFieldObj \ qadevOOo/tests/java/mod/_sc/ScCellCursorObj \ - qadevOOo/tests/java/mod/_sc/ScCellFieldObj \ qadevOOo/tests/java/mod/_sc/ScCellObj \ qadevOOo/tests/java/mod/_sc/ScCellRangeObj \ qadevOOo/tests/java/mod/_sc/ScCellRangesObj \ diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellFieldObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellFieldObj.csv deleted file mode 100644 index 35be57d9423c..000000000000 --- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellFieldObj.csv +++ /dev/null @@ -1,3 +0,0 @@ -"ScCellFieldObj";"com::sun::star::lang::XComponent";"dispose()" -"ScCellFieldObj";"com::sun::star::lang::XComponent";"addEventListener()" -"ScCellFieldObj";"com::sun::star::lang::XComponent";"removeEventListener()" diff --git a/qadevOOo/tests/java/mod/_sc/ScCellFieldObj.java b/qadevOOo/tests/java/mod/_sc/ScCellFieldObj.java deleted file mode 100644 index 0194491218ff..000000000000 --- a/qadevOOo/tests/java/mod/_sc/ScCellFieldObj.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * 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 mod._sc; - -import java.io.PrintWriter; - -import lib.TestCase; -import lib.TestEnvironment; -import lib.TestParameters; -import util.SOfficeFactory; - -import com.sun.star.container.XIndexAccess; -import com.sun.star.lang.XComponent; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.sheet.XSpreadsheet; -import com.sun.star.sheet.XSpreadsheetDocument; -import com.sun.star.sheet.XSpreadsheets; -import com.sun.star.table.XCell; -import com.sun.star.text.XText; -import com.sun.star.text.XTextContent; -import com.sun.star.uno.AnyConverter; -import com.sun.star.uno.Type; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XInterface; - -/** -* Test for object that represents a text field (implements -* com.sun.star.text.TextField) which inserted in a cell of -* the spreadsheet.

-* Object implements the following interfaces : -*

-* @see com.sun.star.text.TextField -* @see com.sun.star.lang.XComponent -* @see com.sun.star.beans.XPropertySet -* @see com.sun.star.text.XTextField -* @see com.sun.star.text.XTextContent -* @see com.sun.star.text.TextContent -* @see ifc.lang._XComponent -* @see ifc.beans._XPropertySet -* @see ifc.text._XTextField -* @see ifc.text._XTextContent -* @see ifc.text._TextContent -*/ -public class ScCellFieldObj extends TestCase { - private XSpreadsheetDocument xSheetDoc = null; - - /** - * Creates Spreadsheet document. - */ - @Override - protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { - SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); - log.println( "creating a Spreadsheet document" ); - xSheetDoc = SOF.createCalcDoc(null); - } - - /** - * Disposes Spreadsheet document. - */ - @Override - protected void cleanup( TestParameters tParam, PrintWriter log ) { - log.println( " disposing xSheetDoc " ); - XComponent oComp = UnoRuntime.queryInterface (XComponent.class, xSheetDoc); - util.DesktopTools.closeDoc(oComp); - } - - /** - * Creating a TestEnvironment for the interfaces to be tested. - * Creates an instance of the service - * com.sun.star.text.TextField.URL, inserts it to the content - * of the cell in the spreadsheet, retrieves a text content - * com.sun.star.text.XTextContent from the cell.

- * Object relations created : - *

- */ - @Override - protected TestEnvironment createTestEnvironment( - TestParameters Param, PrintWriter log) throws Exception { - - XInterface oObj = null; - XText oText = null; - XTextContent oContent = null; - XInterface aField = null; - - // we want to create an instance of ScCellFieldObj. - // to do this we must get an MultiServiceFactory. - - XMultiServiceFactory _oMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xSheetDoc); - - // Now create the instance of com.sun.star.text.TextField. - // This object has type ScCellFieldObj. - - oObj = (XInterface) - _oMSF.createInstance("com.sun.star.text.TextField.URL"); - - aField = (XInterface) - _oMSF.createInstance("com.sun.star.text.TextField.URL"); - oContent = UnoRuntime.queryInterface(XTextContent.class, aField); - - XSpreadsheets oSheets = xSheetDoc.getSheets() ; - XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets); - XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject( - new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0)); - - XCell oCell = oSheet.getCellByPosition(2,3); - oText = UnoRuntime.queryInterface(XText.class, oCell); - - XTextContent oTextContent = UnoRuntime.queryInterface(XTextContent.class, oObj); - - oText.insertTextContent( - oText.createTextCursor(), oTextContent, true); - - oCell = oSheet.getCellByPosition(1,4); - oText = UnoRuntime.queryInterface(XText.class, oCell); - - TestEnvironment tEnv = new TestEnvironment(oObj) ; - - log.println ("Object created.") ; - tEnv.addObjRelation("TRO", Boolean.TRUE); - - tEnv.addObjRelation("CONTENT",oContent); - tEnv.addObjRelation("TEXT",oText); - - return tEnv; - } - -} // finish class ScCellFieldObj - diff --git a/sc/qa/extras/sceditfieldobj-cell.cxx b/sc/qa/extras/sceditfieldobj-cell.cxx index 53f333269989..b4efe8931e20 100644 --- a/sc/qa/extras/sceditfieldobj-cell.cxx +++ b/sc/qa/extras/sceditfieldobj-cell.cxx @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -35,6 +36,7 @@ namespace sc_apitest { class ScEditFieldObj_Cell : public CalcUnoApiTest, public apitest::TextContent, + public apitest::XComponent, public apitest::XPropertySet, public apitest::XTextContent, public apitest::XTextField @@ -48,6 +50,7 @@ public: virtual uno::Reference getTextContent() override; virtual uno::Reference getTextRange() override; virtual bool isAttachSupported() override { return true; } + virtual void triggerDesktopTerminate() override{}; void testEditFieldProperties(); @@ -56,6 +59,11 @@ public: // TextContent CPPUNIT_TEST(testTextContentProperties); + // XComponent + CPPUNIT_TEST(testAddEventListener); + CPPUNIT_TEST(testRemoveEventListener); + CPPUNIT_TEST(testDispose); + // XPropertySet CPPUNIT_TEST(testGetPropertySetInfo); CPPUNIT_TEST(testGetPropertyValue); diff --git a/sc/qa/extras/sceditfieldobj-header.cxx b/sc/qa/extras/sceditfieldobj-header.cxx index 57e4d067f381..da4558a85826 100644 --- a/sc/qa/extras/sceditfieldobj-header.cxx +++ b/sc/qa/extras/sceditfieldobj-header.cxx @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -35,6 +36,7 @@ namespace sc_apitest { class ScEditFieldObj_Header : public CalcUnoApiTest, public apitest::TextContent, + public apitest::XComponent, public apitest::XPropertySet, public apitest::XTextContent, public apitest::XTextField @@ -48,12 +50,18 @@ public: virtual uno::Reference getTextContent() override; virtual uno::Reference getTextRange() override; virtual bool isAttachSupported() override { return false; } + virtual void triggerDesktopTerminate() override{}; CPPUNIT_TEST_SUITE(ScEditFieldObj_Header); // TextContent CPPUNIT_TEST(testTextContentProperties); + // XComponent + CPPUNIT_TEST(testAddEventListener); + CPPUNIT_TEST(testRemoveEventListener); + CPPUNIT_TEST(testDispose); + // XPropertySet CPPUNIT_TEST(testGetPropertySetInfo); CPPUNIT_TEST(testGetPropertyValue); diff --git a/sc/qa/unoapi/sc_2.sce b/sc/qa/unoapi/sc_2.sce index ca7b7b54a042..7f3495a1d6ba 100644 --- a/sc/qa/unoapi/sc_2.sce +++ b/sc/qa/unoapi/sc_2.sce @@ -24,5 +24,4 @@ # -o sc.ScAnnotationShapeObj -o sc.ScAutoFormatFieldObj -o sc.ScCellCursorObj -# ported to cppunit -o sc.ScCellFieldObj -o sc.ScCellObj -- cgit