summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Carl <j.carl43@gmx.de>2019-01-25 00:41:35 +0000
committerJens Carl <j.carl43@gmx.de>2019-01-25 04:17:29 +0100
commitdd0155967e0b679b7df3907fcb12e8cbd82cdefb (patch)
tree2308d5df1d7a86e3a9aa3d734c5ef134ea526877
parent017f846efa9b31cb692ad0c477b8e3607f297181 (diff)
tdf#45904 Move XPropertySet Java tests to C++
Move XPropertySet Java tests to C++ for ScTableValidationObj. Change-Id: If058f40ff73203d2705bf9841d0496d52ff93ed8 Reviewed-on: https://gerrit.libreoffice.org/66890 Tested-by: Jenkins Reviewed-by: Jens Carl <j.carl43@gmx.de>
-rw-r--r--framework/qa/complex/api_internal/api.lst1
-rw-r--r--include/test/beans/xpropertyset.hxx25
-rw-r--r--qadevOOo/Jar_OOoRunner.mk1
-rw-r--r--qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableValidationObj.csv7
-rw-r--r--qadevOOo/tests/java/mod/_sc/ScTableValidationObj.java118
-rw-r--r--sc/qa/extras/sctablevalidationobj.cxx14
-rw-r--r--sc/qa/unoapi/sc_7.sce1
-rw-r--r--solenv/clang-format/blacklist2
-rw-r--r--test/source/beans/xpropertyset.cxx128
9 files changed, 145 insertions, 152 deletions
diff --git a/framework/qa/complex/api_internal/api.lst b/framework/qa/complex/api_internal/api.lst
index 28c133dcdf10..609e7d5c323d 100644
--- a/framework/qa/complex/api_internal/api.lst
+++ b/framework/qa/complex/api_internal/api.lst
@@ -91,7 +91,6 @@ job132=sc.ScStyleObj
job134=sc.ScTableColumnObj
job135=sc.ScTableColumnsObj
job138=sc.ScTableRowObj
-job139=sc.ScTableValidationObj
job140=sc.XMLContentExporter
job141=sc.XMLContentImporter
job142=sc.XMLImporter
diff --git a/include/test/beans/xpropertyset.hxx b/include/test/beans/xpropertyset.hxx
index 3b110a53db3c..72827aa6ee76 100644
--- a/include/test/beans/xpropertyset.hxx
+++ b/include/test/beans/xpropertyset.hxx
@@ -10,36 +10,46 @@
#ifndef INCLUDED_TEST_BEANS_XPROPERTYSET_HXX
#define INCLUDED_TEST_BEANS_XPROPERTYSET_HXX
-#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
#include <test/testdllapi.hxx>
+#include <set>
#include <vector>
-namespace apitest {
-
+namespace apitest
+{
class OOO_DLLPUBLIC_TEST XPropertySet
{
public:
- virtual ~XPropertySet();
+ XPropertySet() {}
+ XPropertySet(const std::set<OUString> rIgnoreValue)
+ : m_IgnoreValue(rIgnoreValue)
+ {
+ }
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
void testGetPropertySetInfo();
void testSetPropertyValue();
void testGetPropertyValue();
+ void testPropertyChangeListner();
+ void testVetoableChangeListner();
protected:
+ ~XPropertySet(){};
bool isPropertyValueChangeable(const OUString& rName);
virtual bool isPropertyIgnored(const OUString& rName);
private:
void fillPropsToTest(const css::uno::Reference<css::beans::XPropertySetInfo>& xPropInfo);
- static bool getSinglePropertyValue(
- const css::uno::Reference<css::beans::XPropertySet>& xPropSet, const OUString& rName);
+ static bool
+ getSinglePropertyValue(const css::uno::Reference<css::beans::XPropertySet>& xPropSet,
+ const OUString& rName);
struct OOO_DLLPUBLIC_TEST PropsToTest
{
@@ -54,9 +64,10 @@ private:
};
PropsToTest maPropsToTest;
+ std::set<OUString> m_IgnoreValue;
};
-}
+} // namespace apitest
#endif
diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk
index 8a8374069326..71887651aa48 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -992,7 +992,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/mod/_sc/ScTableRowObj \
qadevOOo/tests/java/mod/_sc/ScTableSheetObj \
qadevOOo/tests/java/mod/_sc/ScTableSheetsObj \
- qadevOOo/tests/java/mod/_sc/ScTableValidationObj \
qadevOOo/tests/java/mod/_sc/ScTabViewObj \
qadevOOo/tests/java/mod/_sc/ScViewPaneObj \
qadevOOo/tests/java/mod/_sc/XMLContentExporter \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableValidationObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableValidationObj.csv
deleted file mode 100644
index 743fb8ef8851..000000000000
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableValidationObj.csv
+++ /dev/null
@@ -1,7 +0,0 @@
-"ScTableValidationObj";"com::sun::star::beans::XPropertySet";"getPropertySetInfo()"
-"ScTableValidationObj";"com::sun::star::beans::XPropertySet";"setPropertyValue()"
-"ScTableValidationObj";"com::sun::star::beans::XPropertySet";"getPropertyValue()"
-"ScTableValidationObj";"com::sun::star::beans::XPropertySet";"addPropertyChangeListener()"
-"ScTableValidationObj";"com::sun::star::beans::XPropertySet";"removePropertyChangeListener()"
-"ScTableValidationObj";"com::sun::star::beans::XPropertySet";"addVetoableChangeListener()"
-"ScTableValidationObj";"com::sun::star::beans::XPropertySet";"removeVetoableChangeListener()"
diff --git a/qadevOOo/tests/java/mod/_sc/ScTableValidationObj.java b/qadevOOo/tests/java/mod/_sc/ScTableValidationObj.java
deleted file mode 100644
index ce1a84e2b394..000000000000
--- a/qadevOOo/tests/java/mod/_sc/ScTableValidationObj.java
+++ /dev/null
@@ -1,118 +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.beans.XPropertySet;
-import com.sun.star.container.XIndexAccess;
-import com.sun.star.lang.XComponent;
-import com.sun.star.sheet.XSpreadsheet;
-import com.sun.star.sheet.XSpreadsheetDocument;
-import com.sun.star.sheet.XSpreadsheets;
-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 which is represented by service
-* <code>com.sun.star.sheet.TableValidation</code>. <p>
-* Object implements the following interfaces :
-* <ul>
-* <li> <code>com::sun::star::sheet::TableValidation</code></li>
-* <li> <code>com::sun::star::beans::XPropertySet</code></li>
-* <li> <code>com::sun::star::sheet::XSheetCondition</code></li>
-* </ul>
-* @see com.sun.star.sheet.TableValidation
-* @see com.sun.star.beans.XPropertySet
-* @see com.sun.star.sheet.XSheetCondition
-* @see ifc.sheet._TableValidation
-* @see ifc.beans._XPropertySet
-* @see ifc.sheet._XSheetCondition
-*/
-public class ScTableValidationObj extends TestCase {
- private XSpreadsheetDocument xSpreadsheetDoc = null;
-
- /**
- * Creates Spreadsheet document.
- */
- @Override
- protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
- // get a soffice factory object
- SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
- log.println( "creating a sheetdocument" );
- xSpreadsheetDoc = SOF.createCalcDoc(null);
- }
-
- /**
- * Disposes Spreadsheet document.
- */
- @Override
- protected void cleanup( TestParameters tParam, PrintWriter log ) {
- log.println( " disposing xSheetDoc " );
- XComponent oComp = UnoRuntime.queryInterface (XComponent.class, xSpreadsheetDoc) ;
- util.DesktopTools.closeDoc(oComp);
- }
-
- /**
- * Creating a TestEnvironment for the interfaces to be tested.
- * Retrieves a collection of spreadsheets from the document and takes one of
- * them. Fills some cell in the spreadsheet. Obtains the property
- * <code>'Validation'</code> of the spreadsheet. The value of the property
- * is the instance of the service <code>com.sun.star.sheet.TableValidation</code>.
- * @see com.sun.star.sheet.TableValidation
- */
- @Override
- protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception {
-
- XInterface oObj = null;
-
- log.println("getting sheets");
- XSpreadsheets xSpreadsheets = xSpreadsheetDoc.getSheets();
-
- log.println("getting a sheet");
- XSpreadsheet oSheet = null;
- XIndexAccess oIndexAccess = UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
- oSheet = (XSpreadsheet) AnyConverter.toObject(
- new Type(XSpreadsheet.class),oIndexAccess.getByIndex(0));
-
- log.println("filling some cells");
- oSheet.getCellByPosition(5, 5).setValue(15);
- oSheet.getCellByPosition(1, 4).setValue(10);
- oSheet.getCellByPosition(2, 0).setValue(-5.15);
-
- XPropertySet Props = null;
-
- Props = UnoRuntime.queryInterface(XPropertySet.class, oSheet);
- oObj = (XInterface) AnyConverter.toObject(
- new Type(XInterface.class),Props.getPropertyValue("Validation"));
-
- log.println("creating a new environment for object");
- TestEnvironment tEnv = new TestEnvironment(oObj);
-
- return tEnv;
- } // finish method getTestEnvironment
-} // finish class ScTableValidationObj
-
diff --git a/sc/qa/extras/sctablevalidationobj.cxx b/sc/qa/extras/sctablevalidationobj.cxx
index 8de69c907549..542e5b2fa7d6 100644
--- a/sc/qa/extras/sctablevalidationobj.cxx
+++ b/sc/qa/extras/sctablevalidationobj.cxx
@@ -8,6 +8,7 @@
*/
#include <test/calc_unoapi_test.hxx>
+#include <test/beans/xpropertyset.hxx>
#include <test/sheet/tablevalidation.hxx>
#include <test/sheet/xsheetcondition.hxx>
@@ -18,10 +19,10 @@
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/sheet/XSpreadsheets.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Sequence.hxx>
-#include <com/sun/star/uno/XInterface.hpp>
using namespace css;
using namespace css::uno;
@@ -31,6 +32,7 @@ namespace sc_apitest
{
class ScTableValidationObj : public CalcUnoApiTest,
public apitest::TableValidation,
+ public apitest::XPropertySet,
public apitest::XSheetCondition
{
public:
@@ -45,6 +47,13 @@ public:
// TableValidation
CPPUNIT_TEST(testTableValidationProperties);
+ // XPropertySet
+ CPPUNIT_TEST(testGetPropertySetInfo);
+ CPPUNIT_TEST(testSetPropertyValue);
+ CPPUNIT_TEST(testGetPropertyValue);
+ CPPUNIT_TEST(testPropertyChangeListner);
+ CPPUNIT_TEST(testVetoableChangeListner);
+
// XSheetCondition
CPPUNIT_TEST(testGetSetFormula1);
CPPUNIT_TEST(testGetSetFormula2);
@@ -59,6 +68,7 @@ private:
ScTableValidationObj::ScTableValidationObj()
: CalcUnoApiTest("/sc/qa/extras/testdocuments")
+ , XPropertySet({ "Type", "ErrorAlertStyle" })
{
}
@@ -95,7 +105,7 @@ void ScTableValidationObj::tearDown()
CPPUNIT_TEST_SUITE_REGISTRATION(ScTableValidationObj);
-} // end namespace
+} // namespace sc_apitest
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/qa/unoapi/sc_7.sce b/sc/qa/unoapi/sc_7.sce
index c394803fdad7..db39280b3d51 100644
--- a/sc/qa/unoapi/sc_7.sce
+++ b/sc/qa/unoapi/sc_7.sce
@@ -23,7 +23,6 @@
# -o sc.ScTableRowObj
# -o sc.ScTableSheetObj
# -o sc.ScTableSheetsObj
--o sc.ScTableValidationObj
#-o sc.ScViewPaneObj
# #i89411 -o sc.XMLContentExporter
# #i89411 -o sc.XMLContentImporter
diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index d582d0a1d68e..265e01eb5670 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -7569,7 +7569,6 @@ include/svx/zoomslideritem.hxx
include/systools/win32/comtools.hxx
include/systools/win32/qswin32.h
include/systools/win32/uwinapi.h
-include/test/beans/xpropertyset.hxx
include/test/bootstrapfixture.hxx
include/test/calc_unoapi_test.hxx
include/test/callgrind.hxx
@@ -16559,7 +16558,6 @@ sw/source/uibase/wrtsh/wrtsh2.cxx
sw/source/uibase/wrtsh/wrtsh3.cxx
sw/source/uibase/wrtsh/wrtsh4.cxx
sw/source/uibase/wrtsh/wrtundo.cxx
-test/source/beans/xpropertyset.cxx
test/source/bootstrapfixture.cxx
test/source/calc_unoapi_test.cxx
test/source/callgrind.cxx
diff --git a/test/source/beans/xpropertyset.cxx b/test/source/beans/xpropertyset.cxx
index 2da14e7cdf6d..f0b6ac67e3b5 100644
--- a/test/source/beans/xpropertyset.cxx
+++ b/test/source/beans/xpropertyset.cxx
@@ -8,22 +8,121 @@
*/
#include <test/beans/xpropertyset.hxx>
-#include <cppunit/extensions/HelperMacros.h>
-#include <com/sun/star/uno/Type.h>
+#include <com/sun/star/beans/Property.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/PropertyChangeEvent.hpp>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/beans/XVetoableChangeListener.hpp>
+#include <com/sun/star/lang/EventObject.hpp>
#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Type.h>
+
+#include <cppuhelper/implbase.hxx>
+#include <rtl/ref.hxx>
+
#include <set>
+#include <cppunit/extensions/HelperMacros.h>
+
using namespace css;
using namespace css::uno;
-namespace apitest {
+namespace apitest
+{
+XPropertySet::PropsToTest::PropsToTest()
+ : initialized(false)
+{
+}
+
+class MockedPropertyChangeListener : public ::cppu::WeakImplHelper<beans::XPropertyChangeListener>
+{
+public:
+ MockedPropertyChangeListener()
+ : m_bListenerCalled(false)
+ {
+ }
+
+ bool m_bListenerCalled;
+
+ virtual void SAL_CALL propertyChange(const beans::PropertyChangeEvent& /* xEvent */) override
+ {
+ m_bListenerCalled = true;
+ }
+
+ virtual void SAL_CALL disposing(const lang::EventObject& /* xEventObj */) override {}
+};
+
+class MockedVetoableChangeListener : public ::cppu::WeakImplHelper<beans::XVetoableChangeListener>
+{
+public:
+ MockedVetoableChangeListener()
+ : m_bListenerCalled(false)
+ {
+ }
+
+ bool m_bListenerCalled;
-XPropertySet::~XPropertySet() {}
+ virtual void SAL_CALL vetoableChange(const beans::PropertyChangeEvent& /* xEvent */) override
+ {
+ m_bListenerCalled = true;
+ }
+
+ virtual void SAL_CALL disposing(const lang::EventObject& /* xEventObj */) override {}
+};
+
+void XPropertySet::testPropertyChangeListner()
+{
+ uno::Reference<beans::XPropertySet> xPropSet(init(), uno::UNO_QUERY_THROW);
+ uno::Reference<beans::XPropertySetInfo> xPropInfo = xPropSet->getPropertySetInfo();
+ fillPropsToTest(xPropInfo);
+
+ for (const auto& aName : maPropsToTest.bound)
+ {
+ rtl::Reference<MockedPropertyChangeListener> xListener = new MockedPropertyChangeListener();
+ xPropSet->addPropertyChangeListener(
+ aName, uno::Reference<beans::XPropertyChangeListener>(xListener.get()));
+ if (!isPropertyValueChangeable(aName))
+ continue;
+
+ CPPUNIT_ASSERT(xListener->m_bListenerCalled);
+
+ xListener->m_bListenerCalled = false;
+ xPropSet->removePropertyChangeListener(
+ aName, uno::Reference<beans::XPropertyChangeListener>(xListener.get()));
+ isPropertyValueChangeable(aName);
+ CPPUNIT_ASSERT(!xListener->m_bListenerCalled);
+ }
+}
+
+void XPropertySet::testVetoableChangeListner()
+{
+ uno::Reference<beans::XPropertySet> xPropSet(init(), uno::UNO_QUERY_THROW);
+ uno::Reference<beans::XPropertySetInfo> xPropInfo = xPropSet->getPropertySetInfo();
+ fillPropsToTest(xPropInfo);
+
+ for (const auto& aName : maPropsToTest.bound)
+ {
+ rtl::Reference<MockedVetoableChangeListener> xListener = new MockedVetoableChangeListener();
+ xPropSet->addVetoableChangeListener(
+ aName, uno::Reference<beans::XVetoableChangeListener>(xListener.get()));
+ if (!isPropertyValueChangeable(aName))
+ continue;
+
+ CPPUNIT_ASSERT(xListener->m_bListenerCalled);
-XPropertySet::PropsToTest::PropsToTest() : initialized(false) {}
+ xListener->m_bListenerCalled = false;
+ xPropSet->removeVetoableChangeListener(
+ aName, uno::Reference<beans::XVetoableChangeListener>(xListener.get()));
+ isPropertyValueChangeable(aName);
+ CPPUNIT_ASSERT(!xListener->m_bListenerCalled);
+ }
+}
void XPropertySet::testGetPropertySetInfo()
{
@@ -147,7 +246,8 @@ bool XPropertySet::isPropertyValueChangeable(const OUString& rName)
std::cout << type.getTypeName() << std::endl;
std::cout << rName << std::endl;
- CPPUNIT_ASSERT_MESSAGE("XPropertySet::isChangeable: unknown type in Any tested.", false);
+ CPPUNIT_ASSERT_MESSAGE("XPropertySet::isChangeable: unknown type in Any tested.",
+ false);
}
uno::Any anyTest = xPropSet->getPropertyValue(rName);
@@ -155,7 +255,9 @@ bool XPropertySet::isPropertyValueChangeable(const OUString& rName)
}
catch (const uno::Exception&)
{
- CPPUNIT_ASSERT_MESSAGE("XPropertySet::isChangeable: exception thrown while retrieving the property value.", false);
+ CPPUNIT_ASSERT_MESSAGE(
+ "XPropertySet::isChangeable: exception thrown while retrieving the property value.",
+ false);
}
return false;
@@ -191,7 +293,7 @@ void XPropertySet::fillPropsToTest(const uno::Reference<beans::XPropertySetInfo>
if ((aProp.Attributes & beans::PropertyAttribute::MAYBEVOID) != 0)
continue;
- bool bBound = (aProp.Attributes & beans::PropertyAttribute::BOUND) != 0;
+ bool bBound = (aProp.Attributes & beans::PropertyAttribute::BOUND) != 0;
bool bConstrained = (aProp.Attributes & beans::PropertyAttribute::CONSTRAINED) != 0;
bool bCanChange = isPropertyValueChangeable(aProp.Name);
@@ -208,8 +310,8 @@ void XPropertySet::fillPropsToTest(const uno::Reference<beans::XPropertySetInfo>
maPropsToTest.initialized = true;
}
-bool XPropertySet::getSinglePropertyValue(
- const uno::Reference<beans::XPropertySet>& xPropSet, const OUString& rName)
+bool XPropertySet::getSinglePropertyValue(const uno::Reference<beans::XPropertySet>& xPropSet,
+ const OUString& rName)
{
try
{
@@ -222,11 +324,11 @@ bool XPropertySet::getSinglePropertyValue(
return false;
}
-bool XPropertySet::isPropertyIgnored(const OUString& /*rName*/)
+bool XPropertySet::isPropertyIgnored(const OUString& rName)
{
- return false;
+ return m_IgnoreValue.count(rName) > 0;
}
-}
+} // namespace apitest
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */