Kaydet (Commit) 056575f7 authored tarafından Jens Carl's avatar Jens Carl

tdf#45904 Move _TableValidation Java tests to C++

Fixes #i90346.

Change-Id: Iec7e5ebfe28d3d26f5c50950ee2d3f5fc890da65
Reviewed-on: https://gerrit.libreoffice.org/47292Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst acdba3c2
/* -*- 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 <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <test/testdllapi.hxx>
namespace apitest
{
class OOO_DLLPUBLIC_TEST TableValidation
{
public:
virtual css::uno::Reference<css::uno::XInterface> 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: */
......@@ -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 \
......
"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()"
......
/*
* 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 <code>com.sun.star.sheet.TableValidation</code>
* service properties :
* <ul>
* <li><code> Type</code></li>
* <li><code> ShowInputMessage</code></li>
* <li><code> InputTitle</code></li>
* <li><code> InputMessage</code></li>
* <li><code> ShowErrorMessage</code></li>
* <li><code> ErrorTitle</code></li>
* <li><code> ErrorMessage</code></li>
* <li><code> IgnoreBlankCells</code></li>
* <li><code> ErrorAlertStyle</code></li>
* </ul> <p>
* Properties testing is automated by <code>lib.MultiPropertyTest</code>.
* @see com.sun.star.sheet.TableValidation
*/
public class _TableValidation extends MultiPropertyTest {
} // finish class _TableValidation
......@@ -8,6 +8,7 @@
*/
#include <test/calc_unoapi_test.hxx>
#include <test/sheet/tablevalidation.hxx>
#include <test/sheet/xsheetcondition.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
......@@ -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);
......
......@@ -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 \
......
/* -*- 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 <array>
#include <test/sheet/tablevalidation.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/sheet/ValidationAlertStyle.hpp>
#include <com/sun/star/sheet/ValidationType.hpp>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <cppunit/extensions/HelperMacros.h>
using namespace com::sun::star;
using namespace com::sun::star::uno;
namespace apitest
{
void TableValidation::testTableValidationProperties()
{
uno::Reference<beans::XPropertySet> 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: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment