fix Workbooks.xls unit test ( was failing on windows )

Change-Id: Id1e3a761765c1e860f611f40a78a6c24fa17d055
This commit is contained in:
Noel Power
2013-05-13 15:22:30 +01:00
parent 935d074e9f
commit f34c31560b
2 changed files with 19 additions and 7 deletions

View File

@@ -175,23 +175,18 @@ void ScMacrosTest::testVba()
OUString("MiscControlTests."), OUString("MiscControlTests."),
OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document") OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
}, },
#if 0
{ {
OUString("Workbooks."), OUString("Workbooks."),
OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document") OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
}, },
#endif
}; };
OUString sTempDir; OUString sTempDir;
OUString sTempDirURL; OUString sTempDirURL;
osl::FileBase:: getTempDirURL( sTempDirURL ); osl::FileBase:: getTempDirURL( sTempDirURL );
osl::FileBase::getSystemPathFromFileURL( sTempDirURL, sTempDir ); osl::FileBase::getSystemPathFromFileURL( sTempDirURL, sTempDir );
sTempDir += OUString( SAL_PATHDELIMITER );
OUString sTestFileName("My Test WorkBook.xls");
Sequence< uno::Any > aParams; Sequence< uno::Any > aParams;
if ( !sTempDir.isEmpty() )
{
aParams.realloc(1);
aParams[ 0 ] <<= sTempDir;
}
for ( sal_uInt32 i=0; i<SAL_N_ELEMENTS( testInfo ); ++i ) for ( sal_uInt32 i=0; i<SAL_N_ELEMENTS( testInfo ); ++i )
{ {
OUString aFileName; OUString aFileName;
@@ -204,6 +199,15 @@ void ScMacrosTest::testVba()
Any aRet; Any aRet;
Sequence< sal_Int16 > aOutParamIndex; Sequence< sal_Int16 > aOutParamIndex;
Sequence< Any > aOutParam; Sequence< Any > aOutParam;
bool bWorkbooksHandling = OUString( testInfo[i].sFileBaseName ).equalsAscii("Workbooks.") && !sTempDir.isEmpty() ;
if ( bWorkbooksHandling )
{
aParams.realloc(2);
aParams[ 0 ] <<= sTempDir;
aParams[ 1 ] <<= sTestFileName;
}
SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent); SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent);
CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
@@ -215,6 +219,14 @@ void ScMacrosTest::testVba()
std::cout << "value of Ret " << OUStringToOString( aStringRes, RTL_TEXTENCODING_UTF8 ).getStr() << std::endl; std::cout << "value of Ret " << OUStringToOString( aStringRes, RTL_TEXTENCODING_UTF8 ).getStr() << std::endl;
CPPUNIT_ASSERT_MESSAGE( "script reported failure",aStringRes == "OK" ); CPPUNIT_ASSERT_MESSAGE( "script reported failure",aStringRes == "OK" );
pFoundShell->DoClose(); pFoundShell->DoClose();
if ( bWorkbooksHandling )
{
OUString sFileUrl;
OUString sFilePath = sTempDir + sTestFileName;
osl::FileBase::getFileURLFromSystemPath( sFilePath, sFileUrl );
if ( !sFileUrl.isEmpty() )
osl::File::remove( sFileUrl );
}
} }
} }