office-gobmx/sw/qa/api/SwXAutoTextContainer.cxx

78 lines
2.3 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 <test/unoapi_test.hxx>
#include <test/container/xnameaccess.hxx>
#include <test/container/xindexaccess.hxx>
#include <test/container/xelementaccess.hxx>
#include <test/text/xautotextcontainer.hxx>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/text/XAutoTextContainer.hpp>
#include <com/sun/star/text/AutoTextContainer.hpp>
#include <comphelper/processfactory.hxx>
using namespace css;
using namespace css::uno;
namespace
{
/**
* Initial tests for SwXAutoTextContainer.
*/
class SwXAutoTextContainer final : public UnoApiTest,
public apitest::XElementAccess,
public apitest::XIndexAccess,
Fix CppunitTest_sw_apitests For one, a dependency was missing to avoid > [_RUN_____] (anonymous namespace)::SwXAutoTextContainer::testGetByName > standard > test/source/container/xnameaccess.cxx:30:(anonymous namespace)::SwXAutoTextContainer::testGetByName > unexpected exception caught > - Caught: unknown. > > (anonymous namespace)::SwXAutoTextContainer::testGetByName finished in: 147ms > [_RUN_____] (anonymous namespace)::SwXAutoTextContainer::testGetElementNames > standard > (anonymous namespace)::SwXAutoTextContainer::testGetElementNames finished in: 0ms > [_RUN_____] (anonymous namespace)::SwXAutoTextContainer::testHasByName > standard > test/source/container/xnameaccess.cxx:48:(anonymous namespace)::SwXAutoTextContainer::testHasByName > assertion failed > - Expression: xNA->hasByName(m_aName) > > (anonymous namespace)::SwXAutoTextContainer::testHasByName finished in: 0ms > [_RUN_____] (anonymous namespace)::SwXAutoTextContainer::testGetCount > standard > test/source/container/xindexaccess.cxx:26:(anonymous namespace)::SwXAutoTextContainer::testGetCount > equality assertion failed > - Expected: 3 > - Actual : 1 > > (anonymous namespace)::SwXAutoTextContainer::testGetCount finished in: 0ms > [_RUN_____] (anonymous namespace)::SwXAutoTextContainer::testGetByIndex > standard > test/source/container/xindexaccess.cxx:32:(anonymous namespace)::SwXAutoTextContainer::testGetByIndex > equality assertion failed > - Expected: 3 > - Actual : 1 > > (anonymous namespace)::SwXAutoTextContainer::testGetByIndex finished in: 0ms And for another, executing the XAutoTextContainer test code in SwXAutoTextContainer corrupted instdir/, testInsertNewByName creating a spurious instdir/share/autotext/en-US/crdbus50Insert.bau, and testRemoveByName removing instdir/share/autotext/en-US/crdbus50.bau, which caused subsequent runs of the CppunitTest to fail with > [_RUN_____] (anonymous namespace)::SwXAutoTextContainer::testGetCount > standard > /home/tdf/lode/jenkins/workspace/lo_tb_master_linux_dbg/test/source/container/xindexaccess.cxx:26:(anonymous namespace)::SwXAutoTextContainer::testGetCount > equality assertion failed > - Expected: 3 > - Actual : 4 > > (anonymous namespace)::SwXAutoTextContainer::testGetCount finished in: 0ms > [_RUN_____] (anonymous namespace)::SwXAutoTextContainer::testGetByIndex > standard > /home/tdf/lode/jenkins/workspace/lo_tb_master_linux_dbg/test/source/container/xindexaccess.cxx:32:(anonymous namespace)::SwXAutoTextContainer::testGetByIndex > equality assertion failed > - Expected: 3 > - Actual : 4 > > (anonymous namespace)::SwXAutoTextContainer::testGetByIndex finished in: 0ms (<https://ci.libreoffice.org//job/lo_tb_master_linux_dbg/44666/>). So this commit reverts that part of 7b999ca22824e102d283a8b7327fa2717db6568a "tdf#45904: Move _XAutoTextContainer Java tests to C++" for now. Change-Id: I46387d3fea21706846f2c1ba4c462402f9343fdc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156192 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-08-28 06:21:04 -05:00
public apitest::XNameAccess
{
public:
SwXAutoTextContainer()
: UnoApiTest(u""_ustr)
, XElementAccess(cppu::UnoType<text::XAutoTextGroup>::get())
, XIndexAccess(3)
, XNameAccess(u"crdbus50"_ustr)
{
}
virtual void setUp() override
{
UnoApiTest::setUp();
mxDesktop.set(frame::Desktop::create(mxComponentContext));
}
Reference<XInterface> init() override
{
Reference<text::XAutoTextContainer> xAutoTextContainer
= text::AutoTextContainer::create(comphelper::getProcessComponentContext());
Reference<container::XNameAccess> xNA(xAutoTextContainer, UNO_QUERY_THROW);
Sequence<rtl::OUString> aNames = xNA->getElementNames();
std::cout << aNames[0] << std::endl;
return Reference<XInterface>(xAutoTextContainer, UNO_QUERY_THROW);
}
CPPUNIT_TEST_SUITE(SwXAutoTextContainer);
CPPUNIT_TEST(testGetByName);
CPPUNIT_TEST(testGetElementNames);
CPPUNIT_TEST(testHasByName);
CPPUNIT_TEST(testGetCount);
CPPUNIT_TEST(testGetByIndex);
CPPUNIT_TEST(testGetElementType);
CPPUNIT_TEST(testHasElements);
CPPUNIT_TEST_SUITE_END();
};
CPPUNIT_TEST_SUITE_REGISTRATION(SwXAutoTextContainer);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */