From 056575f7ceff003348783f7611f84a68463fa8c8 Mon Sep 17 00:00:00 2001 From: Jens Carl Date: Wed, 3 Jan 2018 05:42:01 +0000 Subject: tdf#45904 Move _TableValidation Java tests to C++ Fixes #i90346. Change-Id: Iec7e5ebfe28d3d26f5c50950ee2d3f5fc890da65 Reviewed-on: https://gerrit.libreoffice.org/47292 Tested-by: Jenkins Reviewed-by: Jens Carl --- include/test/sheet/tablevalidation.hxx | 34 +++++ qadevOOo/Jar_OOoRunner.mk | 1 - ...m.sun.star.comp.office.ScTableValidationObj.csv | 10 -- .../tests/java/ifc/sheet/_TableValidation.java | 43 ------ sc/qa/extras/sctablevalidationobj.cxx | 10 +- test/Library_subsequenttest.mk | 1 + test/source/sheet/tablevalidation.cxx | 154 +++++++++++++++++++++ 7 files changed, 197 insertions(+), 56 deletions(-) create mode 100644 include/test/sheet/tablevalidation.hxx delete mode 100644 qadevOOo/tests/java/ifc/sheet/_TableValidation.java create mode 100644 test/source/sheet/tablevalidation.cxx diff --git a/include/test/sheet/tablevalidation.hxx b/include/test/sheet/tablevalidation.hxx new file mode 100644 index 000000000000..809745254141 --- /dev/null +++ b/include/test/sheet/tablevalidation.hxx @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#ifndef INCLUDED_TEST_SHEET_TABLEVALIDATION_HXX +#define INCLUDED_TEST_SHEET_TABLEVALIDATION_HXX + +#include +#include + +#include + +namespace apitest +{ +class OOO_DLLPUBLIC_TEST TableValidation +{ +public: + virtual css::uno::Reference init() = 0; + + void testTableValidationProperties(); + +protected: + ~TableValidation() {} +}; +} + +#endif // INCLUDED_TEST_SHEET_TABLEVALIDATION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk index de087a156028..b8ed2487e317 100644 --- a/qadevOOo/Jar_OOoRunner.mk +++ b/qadevOOo/Jar_OOoRunner.mk @@ -581,7 +581,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\ qadevOOo/tests/java/ifc/sheet/_SubTotalDescriptor \ qadevOOo/tests/java/ifc/sheet/_TableAutoFormat \ qadevOOo/tests/java/ifc/sheet/_TableAutoFormatField \ - qadevOOo/tests/java/ifc/sheet/_TableValidation \ qadevOOo/tests/java/ifc/sheet/_XActivationBroadcaster \ qadevOOo/tests/java/ifc/sheet/_XArrayFormulaRange \ qadevOOo/tests/java/ifc/sheet/_XCalculatable \ diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableValidationObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableValidationObj.csv index 6ece7b010e7c..743fb8ef8851 100644 --- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableValidationObj.csv +++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableValidationObj.csv @@ -1,13 +1,3 @@ -"ScTableValidationObj";"com::sun::star::sheet::TableValidation";"Type" -"ScTableValidationObj";"com::sun::star::sheet::TableValidation";"ShowInputMessage" -"ScTableValidationObj";"com::sun::star::sheet::TableValidation";"InputTitle" -"ScTableValidationObj";"com::sun::star::sheet::TableValidation";"InputMessage" -"ScTableValidationObj";"com::sun::star::sheet::TableValidation";"ShowErrorMessage" -"ScTableValidationObj";"com::sun::star::sheet::TableValidation";"ErrorTitle" -"ScTableValidationObj";"com::sun::star::sheet::TableValidation";"ErrorMessage" -"ScTableValidationObj";"com::sun::star::sheet::TableValidation";"IgnoreBlankCells" -"ScTableValidationObj";"com::sun::star::sheet::TableValidation";"ErrorAlertStyle" -"ScTableValidationObj";"com::sun::star::sheet::TableValidation";"ShowList#optional" "ScTableValidationObj";"com::sun::star::beans::XPropertySet";"getPropertySetInfo()" "ScTableValidationObj";"com::sun::star::beans::XPropertySet";"setPropertyValue()" "ScTableValidationObj";"com::sun::star::beans::XPropertySet";"getPropertyValue()" diff --git a/qadevOOo/tests/java/ifc/sheet/_TableValidation.java b/qadevOOo/tests/java/ifc/sheet/_TableValidation.java deleted file mode 100644 index aab7a1640daa..000000000000 --- a/qadevOOo/tests/java/ifc/sheet/_TableValidation.java +++ /dev/null @@ -1,43 +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 ifc.sheet; - -import lib.MultiPropertyTest; - -/** -* Testing com.sun.star.sheet.TableValidation -* service properties : -*
    -*
  • Type
  • -*
  • ShowInputMessage
  • -*
  • InputTitle
  • -*
  • InputMessage
  • -*
  • ShowErrorMessage
  • -*
  • ErrorTitle
  • -*
  • ErrorMessage
  • -*
  • IgnoreBlankCells
  • -*
  • ErrorAlertStyle
  • -*

-* Properties testing is automated by lib.MultiPropertyTest. -* @see com.sun.star.sheet.TableValidation -*/ -public class _TableValidation extends MultiPropertyTest { -} // finish class _TableValidation - - diff --git a/sc/qa/extras/sctablevalidationobj.cxx b/sc/qa/extras/sctablevalidationobj.cxx index 1fe21046071b..03dd18993305 100644 --- a/sc/qa/extras/sctablevalidationobj.cxx +++ b/sc/qa/extras/sctablevalidationobj.cxx @@ -8,6 +8,7 @@ */ #include +#include #include #include @@ -28,9 +29,11 @@ using namespace com::sun::star; namespace sc_apitest { -#define NUMBER_OF_TESTS 4 +#define NUMBER_OF_TESTS 5 -class ScTableValidationObj : public CalcUnoApiTest, public apitest::XSheetCondition +class ScTableValidationObj : public CalcUnoApiTest, + public apitest::TableValidation, + public apitest::XSheetCondition { public: ScTableValidationObj(); @@ -41,6 +44,9 @@ public: CPPUNIT_TEST_SUITE(ScTableValidationObj); + // TableValidation + CPPUNIT_TEST(testTableValidationProperties); + // XSheetCondition CPPUNIT_TEST(testGetSetFormula1); CPPUNIT_TEST(testGetSetFormula2); diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk index 5793f689fc82..6768f10fc692 100644 --- a/test/Library_subsequenttest.mk +++ b/test/Library_subsequenttest.mk @@ -48,6 +48,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\ test/source/sheet/datapilotfield \ test/source/sheet/datapilotitem \ test/source/sheet/scenario \ + test/source/sheet/tablevalidation \ test/source/sheet/xarealink \ test/source/sheet/xarealinks \ test/source/sheet/xcelladdressable \ diff --git a/test/source/sheet/tablevalidation.cxx b/test/source/sheet/tablevalidation.cxx new file mode 100644 index 000000000000..e953e0f2f111 --- /dev/null +++ b/test/source/sheet/tablevalidation.cxx @@ -0,0 +1,154 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#include +#include + +#include +#include +#include +#include +#include + +#include + +using namespace com::sun::star; +using namespace com::sun::star::uno; + +namespace apitest +{ +void TableValidation::testTableValidationProperties() +{ + uno::Reference xTableValidation(init(), UNO_QUERY_THROW); + OUString propName; + uno::Any aNewValue; + + propName = "Type"; + uno::Any aValue = xTableValidation->getPropertyValue(propName); + sheet::ValidationType aValidationType; + aValue >>= aValidationType; + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value Type", sheet::ValidationType_ANY, + aValidationType); + + aNewValue <<= sheet::ValidationType_WHOLE; + xTableValidation->setPropertyValue(propName, aNewValue); + aValue = xTableValidation->getPropertyValue(propName); + aValue >>= aValidationType; + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set property value Type", sheet::ValidationType_WHOLE, + aValidationType); + + propName = "ShowInputMessage"; + bool aShowInputMessage = true; + CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aShowInputMessage); + CPPUNIT_ASSERT_MESSAGE("Unable to get property value ShowInputMessage", !aShowInputMessage); + + aNewValue <<= true; + xTableValidation->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aShowInputMessage); + CPPUNIT_ASSERT_MESSAGE("Unable to set property value ShowInputMessage", aShowInputMessage); + + // only possible if ShowInputMessage is true + propName = "InputMessage"; + OUString aInputMessage; + CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aInputMessage); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value InputMessage", OUString(""), + aInputMessage); + + aNewValue <<= OUString("UnitTest InputMessage"); + xTableValidation->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aInputMessage); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value InputMessage", + OUString("UnitTest InputMessage"), aInputMessage); + + // only possible if ShowInputMessage is true + propName = "InputTitle"; + OUString aInputTitle; + CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aInputTitle); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value InputTitle", OUString(""), + aInputTitle); + + aNewValue <<= OUString("UnitTest InputTitle"); + xTableValidation->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aInputTitle); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value InputTitle", + OUString("UnitTest InputTitle"), aInputTitle); + + propName = "ShowErrorMessage"; + bool aShowErrorMessage = true; + CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aShowErrorMessage); + CPPUNIT_ASSERT_MESSAGE("Unable to get property value ShowErrorMessage", !aShowErrorMessage); + + aNewValue <<= true; + xTableValidation->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aShowErrorMessage); + CPPUNIT_ASSERT_MESSAGE("Unable to set property value ShowErrorMessage", aShowErrorMessage); + + // only possible if ShowErrorMessage is true + propName = "ErrorMessage"; + OUString aErrorMessage; + CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aErrorMessage); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value ErrorMessage", OUString(""), + aErrorMessage); + + aNewValue <<= OUString("UnitTest ErrorMessage"); + xTableValidation->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aErrorMessage); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value ErrorMessage", + OUString("UnitTest ErrorMessage"), aErrorMessage); + + // only possible if ShowErrorMessage is true + propName = "ErrorTitle"; + OUString aErrorTitle; + CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aErrorTitle); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value ErrorTitle", OUString(""), + aErrorTitle); + + aNewValue <<= OUString("UnitTest ErrorTitle"); + xTableValidation->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aErrorTitle); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value ErrorTitle", + OUString("UnitTest ErrorTitle"), aErrorTitle); + + propName = "IgnoreBlankCells"; + bool aIgnoreBlankCells = false; + CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aIgnoreBlankCells); + CPPUNIT_ASSERT_MESSAGE("Unable to get property value IgnoreBlankCells", aIgnoreBlankCells); + + aNewValue <<= false; + xTableValidation->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aIgnoreBlankCells); + CPPUNIT_ASSERT_MESSAGE("Unable to set property value IgnoreBlankCells", !aIgnoreBlankCells); + + propName = "ErrorAlertStyle"; + aValue = xTableValidation->getPropertyValue(propName); + sheet::ValidationAlertStyle aValidationAlertStyle; + aValue >>= aValidationAlertStyle; + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value ValidationAlertStyle", + sheet::ValidationAlertStyle_STOP, aValidationAlertStyle); + + aNewValue <<= sheet::ValidationAlertStyle_WARNING; + xTableValidation->setPropertyValue(propName, aNewValue); + aValue = xTableValidation->getPropertyValue(propName); + aValue >>= aValidationAlertStyle; + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set property value ValidationAlertStyle", + sheet::ValidationAlertStyle_WARNING, aValidationAlertStyle); + + propName = "ShowList"; + sal_Int16 aShowList = 0; + CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aShowList); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unabel to get property value ShowList", sal_Int16(1), aShowList); + + aNewValue <<= sal_Int16(42); + xTableValidation->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aShowList); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unabel to set property value ShowList", sal_Int16(42), aShowList); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ -- cgit