Use a method from UnoApitest instead of implement a new one in calc
In calc, we see a lot of implementations of createFileURL. So get ride of all it and start to use the UnoAPitest::createFileURL method. Also, clean the UnoApiRest::createFileURL method, fix the path from UnoApiTest and moved some testing files to the right dir that the file belongs. Conflicts: sc/qa/extras/scoutlineobj.cxx Change-Id: Ic02f13777503729ac70da590f4a42866f17ea9b2
This commit is contained in:
committed by
Markus Mohrhard
parent
11cfcf401a
commit
7226ac25e2
@@ -59,6 +59,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_macros_test, \
|
||||
svx \
|
||||
svxcore \
|
||||
test \
|
||||
subsequenttest \
|
||||
tl \
|
||||
tk \
|
||||
ucbhelper \
|
||||
|
@@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
#include <sal/config.h>
|
||||
#include <test/bootstrapfixture.hxx>
|
||||
#include <test/unoapi_test.hxx>
|
||||
#include <unotest/macros_test.hxx>
|
||||
#include <rtl/strbuf.hxx>
|
||||
#include <osl/file.hxx>
|
||||
@@ -53,16 +53,11 @@ using namespace ::com::sun::star::uno;
|
||||
|
||||
/* Implementation of Macros test */
|
||||
|
||||
class ScMacrosTest : public test::BootstrapFixture, public unotest::MacrosTest
|
||||
class ScMacrosTest : public UnoApiTest
|
||||
{
|
||||
public:
|
||||
ScMacrosTest();
|
||||
|
||||
void createFileURL(const rtl::OUString& aFileBase, const rtl::OUString& aFileExtension, rtl::OUString& rFilePath);
|
||||
|
||||
virtual void setUp();
|
||||
virtual void tearDown();
|
||||
|
||||
void testStarBasic();
|
||||
void testVba();
|
||||
CPPUNIT_TEST_SUITE(ScMacrosTest);
|
||||
@@ -77,25 +72,13 @@ public:
|
||||
|
||||
private:
|
||||
uno::Reference<uno::XInterface> m_xCalcComponent;
|
||||
rtl::OUString m_aBaseString;
|
||||
};
|
||||
|
||||
|
||||
void ScMacrosTest::createFileURL(const rtl::OUString& aFileBase, const rtl::OUString& aFileExtension, rtl::OUString& rFilePath)
|
||||
{
|
||||
rtl::OUString aSep(RTL_CONSTASCII_USTRINGPARAM("/"));
|
||||
rtl::OUStringBuffer aBuffer( getSrcRootURL() );
|
||||
aBuffer.append(m_aBaseString).append(aSep).append(aFileExtension);
|
||||
aBuffer.append(aSep).append(aFileBase).append(aFileExtension);
|
||||
rFilePath = aBuffer.makeStringAndClear();
|
||||
}
|
||||
|
||||
void ScMacrosTest::testStarBasic()
|
||||
{
|
||||
const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("StarBasic."));
|
||||
rtl::OUString aFileExtension("ods");
|
||||
const OUString aFileNameBase("StarBasic.ods");
|
||||
rtl::OUString aFileName;
|
||||
createFileURL(aFileNameBase, aFileExtension, aFileName);
|
||||
createFileURL(aFileNameBase, aFileName);
|
||||
std::cout << "StarBasic test" << std::endl;
|
||||
uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName);
|
||||
|
||||
@@ -122,7 +105,6 @@ void ScMacrosTest::testStarBasic()
|
||||
xDocSh->DoClose();
|
||||
}
|
||||
|
||||
|
||||
void ScMacrosTest::testVba()
|
||||
{
|
||||
TestMacroInfo testInfo[] = {
|
||||
@@ -136,11 +118,10 @@ void ScMacrosTest::testVba()
|
||||
}
|
||||
};
|
||||
|
||||
rtl::OUString aFileExtension("xls");
|
||||
for ( sal_uInt32 i=0; i<SAL_N_ELEMENTS( testInfo ); ++i )
|
||||
{
|
||||
rtl::OUString aFileName;
|
||||
createFileURL(testInfo[i].sFileBaseName, aFileExtension, aFileName);
|
||||
createFileURL(testInfo[i].sFileBaseName + "xls", aFileName);
|
||||
uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName);
|
||||
rtl::OUString sMsg( "Failed to load " + aFileName );
|
||||
CPPUNIT_ASSERT_MESSAGE( rtl::OUStringToOString( sMsg, RTL_TEXTENCODING_UTF8 ).getStr(), xComponent.is() );
|
||||
@@ -164,29 +145,10 @@ void ScMacrosTest::testVba()
|
||||
}
|
||||
|
||||
ScMacrosTest::ScMacrosTest()
|
||||
: m_aBaseString(RTL_CONSTASCII_USTRINGPARAM("/sc/qa/unit/data"))
|
||||
: UnoApiTest("/sc/qa/extras/testdocuments")
|
||||
{
|
||||
}
|
||||
|
||||
void ScMacrosTest::setUp()
|
||||
{
|
||||
test::BootstrapFixture::setUp();
|
||||
|
||||
// This is a bit of a fudge, we do this to ensure that ScGlobals::ensure,
|
||||
// which is a private symbol to us, gets called
|
||||
m_xCalcComponent =
|
||||
getMultiServiceFactory()->createInstance(rtl::OUString(
|
||||
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Calc.SpreadsheetDocument")));
|
||||
CPPUNIT_ASSERT_MESSAGE("no calc component!", m_xCalcComponent.is());
|
||||
mxDesktop = com::sun::star::frame::Desktop::create( comphelper::getComponentContext(getMultiServiceFactory()) );
|
||||
}
|
||||
|
||||
void ScMacrosTest::tearDown()
|
||||
{
|
||||
uno::Reference< lang::XComponent >( m_xCalcComponent, UNO_QUERY_THROW )->dispose();
|
||||
test::BootstrapFixture::tearDown();
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(ScMacrosTest);
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
@@ -70,6 +70,7 @@ sal_Int32 ScAnnontationObj::nTest = 0;
|
||||
uno::Reference< lang::XComponent > ScAnnontationObj::mxComponent;
|
||||
|
||||
ScAnnontationObj::ScAnnontationObj()
|
||||
: UnoApiTest("/sc/qa/extras/testdocuments")
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -63,6 +63,7 @@ sal_Int32 ScAnnontationsObj::nTest = 0;
|
||||
uno::Reference< lang::XComponent > ScAnnontationsObj::mxComponent;
|
||||
|
||||
ScAnnontationsObj::ScAnnontationsObj()
|
||||
: UnoApiTest("/sc/qa/extras/testdocuments")
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -79,10 +79,10 @@ sal_Int32 ScCellRangeObj::nTest = 0;
|
||||
uno::Reference< lang::XComponent > ScCellRangeObj::mxComponent;
|
||||
|
||||
ScCellRangeObj::ScCellRangeObj():
|
||||
UnoApiTest("/sc/qa/extras/testdocuments"),
|
||||
apitest::XSearchable(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("15")), 1),
|
||||
apitest::XReplaceable(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("15")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("35")))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
uno::Reference< uno::XInterface > ScCellRangeObj::init()
|
||||
|
@@ -47,6 +47,8 @@ public:
|
||||
|
||||
virtual uno::Reference< uno::XInterface > init( const rtl::OUString& rDBName );
|
||||
|
||||
ScDatabaseRangeObj();
|
||||
|
||||
CPPUNIT_TEST_SUITE(ScDatabaseRangeObj);
|
||||
CPPUNIT_TEST(testDataArea);
|
||||
CPPUNIT_TEST(testGetSortDescriptor);
|
||||
@@ -63,10 +65,15 @@ private:
|
||||
sal_Int32 ScDatabaseRangeObj::nTest = 0;
|
||||
uno::Reference< lang::XComponent > ScDatabaseRangeObj::mxComponent;
|
||||
|
||||
ScDatabaseRangeObj::ScDatabaseRangeObj()
|
||||
: UnoApiTest("/sc/qa/extras/testdocuments")
|
||||
{
|
||||
}
|
||||
|
||||
uno::Reference< uno::XInterface > ScDatabaseRangeObj::init( const rtl::OUString& rDBName )
|
||||
{
|
||||
rtl::OUString aFileURL;
|
||||
createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScDatabaseRangeObj.ods")), aFileURL);
|
||||
createFileURL("ScDatabaseRangeObj.ods", aFileURL);
|
||||
if(!mxComponent.is())
|
||||
mxComponent = loadFromDesktop(aFileURL);
|
||||
CPPUNIT_ASSERT(mxComponent.is());
|
||||
|
@@ -48,6 +48,8 @@ public:
|
||||
virtual void tearDown();
|
||||
virtual uno::Reference< uno::XInterface > init();
|
||||
|
||||
ScDataPilotFieldObj();
|
||||
|
||||
CPPUNIT_TEST_SUITE(ScDataPilotFieldObj);
|
||||
CPPUNIT_TEST(testSortInfo);
|
||||
CPPUNIT_TEST(testLayoutInfo);
|
||||
@@ -66,6 +68,11 @@ private:
|
||||
sal_Int32 ScDataPilotFieldObj::nTest = 0;
|
||||
uno::Reference< lang::XComponent > ScDataPilotFieldObj::mxComponent;
|
||||
|
||||
ScDataPilotFieldObj::ScDataPilotFieldObj()
|
||||
: UnoApiTest("/sc/qa/extras/testdocuments")
|
||||
{
|
||||
}
|
||||
|
||||
uno::Reference< uno::XInterface > ScDataPilotFieldObj::init()
|
||||
{
|
||||
rtl::OUString aFileURL;
|
||||
|
@@ -83,15 +83,15 @@ sal_Int32 ScDataPilotTableObj::nTest = 0;
|
||||
uno::Reference< lang::XComponent > ScDataPilotTableObj::mxComponent;
|
||||
|
||||
ScDataPilotTableObj::ScDataPilotTableObj()
|
||||
: apitest::XNamed(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataPilotTable")))
|
||||
: UnoApiTest("/sc/qa/extras/testdocuments"),
|
||||
apitest::XNamed(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataPilotTable")))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
uno::Reference< uno::XInterface > ScDataPilotTableObj::init()
|
||||
{
|
||||
rtl::OUString aFileURL;
|
||||
createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScDataPilotTableObj.ods")), aFileURL);
|
||||
createFileURL("ScDataPilotTableObj.ods", aFileURL);
|
||||
if(!mxComponent.is())
|
||||
mxComponent = loadFromDesktop(aFileURL);
|
||||
CPPUNIT_ASSERT(mxComponent.is());
|
||||
|
@@ -86,7 +86,10 @@ sal_Int32 ScEditFieldObj_Cell::nTest = 0;
|
||||
uno::Reference<lang::XComponent> ScEditFieldObj_Cell::mxComponent;
|
||||
uno::Reference<text::XTextField> ScEditFieldObj_Cell::mxField;
|
||||
|
||||
ScEditFieldObj_Cell::ScEditFieldObj_Cell() {}
|
||||
ScEditFieldObj_Cell::ScEditFieldObj_Cell()
|
||||
: UnoApiTest("/sc/qa/extras/testdocuments")
|
||||
{
|
||||
}
|
||||
|
||||
void ScEditFieldObj_Cell::setUp()
|
||||
{
|
||||
|
@@ -82,7 +82,10 @@ uno::Reference<lang::XComponent> ScEditFieldObj_Header::mxComponent;
|
||||
uno::Reference<text::XTextField> ScEditFieldObj_Header::mxField;
|
||||
uno::Reference<text::XText> ScEditFieldObj_Header::mxRightText;
|
||||
|
||||
ScEditFieldObj_Header::ScEditFieldObj_Header() {}
|
||||
ScEditFieldObj_Header::ScEditFieldObj_Header()
|
||||
: UnoApiTest("/sc/qa/extras/testdocuments")
|
||||
{
|
||||
}
|
||||
|
||||
void ScEditFieldObj_Header::setUp()
|
||||
{
|
||||
|
@@ -22,6 +22,8 @@ public:
|
||||
|
||||
virtual uno::Reference< uno::XInterface > init();
|
||||
|
||||
ScModelObj();
|
||||
|
||||
CPPUNIT_TEST_SUITE(ScModelObj);
|
||||
CPPUNIT_TEST(testSeekGoal);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
@@ -31,6 +33,10 @@ private:
|
||||
static uno::Reference< lang::XComponent > mxComponent;
|
||||
};
|
||||
|
||||
ScModelObj::ScModelObj()
|
||||
: UnoApiTest("/sc/qa/extras/testdocuments")
|
||||
{
|
||||
}
|
||||
|
||||
sal_Int32 ScModelObj::nTest = 0;
|
||||
uno::Reference< lang::XComponent > ScModelObj::mxComponent;
|
||||
|
@@ -73,10 +73,10 @@ sal_Int32 ScNamedRangeObj::nTest = 0;
|
||||
uno::Reference< lang::XComponent > ScNamedRangeObj::mxComponent;
|
||||
|
||||
ScNamedRangeObj::ScNamedRangeObj():
|
||||
UnoApiTest("/sc/qa/extras/testdocuments"),
|
||||
apitest::XNamed(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NamedRange"))),
|
||||
apitest::XCellRangeReferrer(table::CellRangeAddress(0,1,7,1,7))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
uno::Reference< sheet::XNamedRanges > ScNamedRangeObj::init_impl()
|
||||
|
@@ -45,6 +45,8 @@ public:
|
||||
|
||||
virtual uno::Reference< uno::XInterface > init(sal_Int32 nSheet);
|
||||
|
||||
ScNamedRangesObj();
|
||||
|
||||
CPPUNIT_TEST_SUITE(ScNamedRangesObj);
|
||||
CPPUNIT_TEST(testAddNewByName);
|
||||
CPPUNIT_TEST(testAddNewFromTitles);
|
||||
@@ -60,6 +62,11 @@ private:
|
||||
sal_Int32 ScNamedRangesObj::nTest = 0;
|
||||
uno::Reference< lang::XComponent > ScNamedRangesObj::mxComponent;
|
||||
|
||||
ScNamedRangesObj::ScNamedRangesObj()
|
||||
: UnoApiTest("/sc/qa/extras/testdocuments")
|
||||
{
|
||||
}
|
||||
|
||||
uno::Reference< uno::XInterface > ScNamedRangesObj::init(sal_Int32 nSheet)
|
||||
{
|
||||
rtl::OUString aFileURL;
|
||||
|
@@ -64,10 +64,10 @@ sal_Int32 ScTableSheetObj::nTest = 0;
|
||||
uno::Reference< lang::XComponent > ScTableSheetObj::mxComponent;
|
||||
|
||||
ScTableSheetObj::ScTableSheetObj():
|
||||
UnoApiTest("/sc/qa/extras/testdocuments"),
|
||||
apitest::XSearchable(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("test")), 4),
|
||||
apitest::XReplaceable(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("searchReplaceString")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("replaceReplaceString")))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -74,6 +74,7 @@ uno::Reference< lang::XComponent > ScTableSheetsObj::mxComponent;
|
||||
sal_Int32 ScTableSheetsObj::nTest = 0;
|
||||
|
||||
ScTableSheetsObj::ScTableSheetsObj():
|
||||
UnoApiTest("/sc/qa/extras/testdocuments"),
|
||||
apitest::XNameContainer(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Sheet2")))
|
||||
{
|
||||
|
||||
|
@@ -41,7 +41,7 @@ using namespace ::com::sun::star::uno;
|
||||
class OOO_DLLPUBLIC_TEST UnoApiTest : public test::BootstrapFixture, public unotest::MacrosTest
|
||||
{
|
||||
public:
|
||||
UnoApiTest();
|
||||
UnoApiTest(const OUString& path);
|
||||
|
||||
void createFileURL(const rtl::OUString& aFileBase, rtl::OUString& rFilePath);
|
||||
|
||||
|
@@ -32,8 +32,8 @@
|
||||
#include <com/sun/star/frame/Desktop.hpp>
|
||||
#include <comphelper/processfactory.hxx>
|
||||
|
||||
UnoApiTest::UnoApiTest()
|
||||
: m_aBaseString(RTL_CONSTASCII_USTRINGPARAM("/sc/qa/extras/testdocuments"))
|
||||
UnoApiTest::UnoApiTest(const OUString& path)
|
||||
: m_aBaseString(path)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -58,12 +58,7 @@ void UnoApiTest::tearDown()
|
||||
|
||||
void UnoApiTest::createFileURL(const rtl::OUString& aFileBase, rtl::OUString& rFilePath)
|
||||
{
|
||||
rtl::OUString aSep(RTL_CONSTASCII_USTRINGPARAM("/"));
|
||||
rtl::OUStringBuffer aBuffer( getSrcRootURL() );
|
||||
rtl::OUString aFileExtension(RTL_CONSTASCII_USTRINGPARAM("ods"));
|
||||
aBuffer.append(m_aBaseString).append(aSep);
|
||||
aBuffer.append(aFileBase);
|
||||
rFilePath = aBuffer.makeStringAndClear();
|
||||
rFilePath = getSrcRootURL() + m_aBaseString + "/" + aFileBase;
|
||||
}
|
||||
|
||||
void UnoApiTest::closeDocument( uno::Reference< lang::XComponent > xDocument )
|
||||
|
Reference in New Issue
Block a user