Pass DocumentService to the loader during macro tests.

And disable user interaction during type detection, since that would
cause the test to fail.

With this change, 'make check' works once again.

Change-Id: I2f45a2e962e45ee64f7984e794cff814fbfe6dab
This commit is contained in:
Kohei Yoshida
2013-02-05 14:38:43 -05:00
parent a0dd5a8d6a
commit 7d3ddc2c6c
17 changed files with 34 additions and 25 deletions

View File

@@ -80,7 +80,7 @@ void ScMacrosTest::testStarBasic()
rtl::OUString aFileName;
createFileURL(aFileNameBase, aFileName);
std::cout << "StarBasic test" << std::endl;
uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName);
uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
CPPUNIT_ASSERT_MESSAGE("Failed to load StarBasic.ods", xComponent.is());
@@ -122,7 +122,7 @@ void ScMacrosTest::testVba()
{
rtl::OUString aFileName;
createFileURL(testInfo[i].sFileBaseName + "xls", aFileName);
uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName);
uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
rtl::OUString sMsg( "Failed to load " + aFileName );
CPPUNIT_ASSERT_MESSAGE( rtl::OUStringToOString( sMsg, RTL_TEXTENCODING_UTF8 ).getStr(), xComponent.is() );

View File

@@ -114,7 +114,7 @@ void ScChartRegressionTest::test()
{
rtl::OUString aFileName;
createFileURL( "testChart.", "ods", aFileName);
uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName);
uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
CPPUNIT_ASSERT(xComponent.is());

View File

@@ -92,7 +92,7 @@ uno::Reference< uno::XInterface > ScCellRangeObj::init()
createFileURL(aFileBase, aFileURL);
std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
if( !mxComponent.is())
mxComponent = loadFromDesktop(aFileURL);
mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
uno::Reference< sheet::XSpreadsheetDocument> xDoc (mxComponent, UNO_QUERY_THROW);
uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
@@ -112,7 +112,7 @@ uno::Reference< uno::XInterface > ScCellRangeObj::getXCellRangeData()
createFileURL(aFileBase, aFileURL);
std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
if( !mxComponent.is())
mxComponent = loadFromDesktop(aFileURL);
mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
uno::Reference< sheet::XSpreadsheetDocument> xDoc (mxComponent, UNO_QUERY_THROW);
uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW);

View File

@@ -75,7 +75,7 @@ uno::Reference< uno::XInterface > ScDatabaseRangeObj::init( const rtl::OUString&
rtl::OUString aFileURL;
createFileURL("ScDatabaseRangeObj.ods", aFileURL);
if(!mxComponent.is())
mxComponent = loadFromDesktop(aFileURL);
mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
CPPUNIT_ASSERT(mxComponent.is());
uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);

View File

@@ -78,7 +78,7 @@ uno::Reference< uno::XInterface > ScDataPilotFieldObj::init()
rtl::OUString aFileURL;
createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("scdatapilotfieldobj.ods")), aFileURL);
if(!mxComponent.is())
mxComponent = loadFromDesktop(aFileURL);
mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
CPPUNIT_ASSERT(mxComponent.is());
uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);

View File

@@ -93,7 +93,7 @@ uno::Reference< uno::XInterface > ScDataPilotTableObj::init()
rtl::OUString aFileURL;
createFileURL("ScDataPilotTableObj.ods", aFileURL);
if(!mxComponent.is())
mxComponent = loadFromDesktop(aFileURL);
mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
CPPUNIT_ASSERT(mxComponent.is());
uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
@@ -130,7 +130,7 @@ uno::Reference< uno::XInterface > ScDataPilotTableObj::initDP2()
rtl::OUString aFileURL;
createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScDataPilotTableObj.ods")), aFileURL);
if(!mxComponent.is())
mxComponent = loadFromDesktop(aFileURL);
mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
CPPUNIT_ASSERT(mxComponent.is());
uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);

View File

@@ -46,7 +46,7 @@ uno::Reference< uno::XInterface > ScModelObj::init()
rtl::OUString aFileURL;
createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScModelObj.ods")), aFileURL);
if(!mxComponent.is())
mxComponent = loadFromDesktop(aFileURL);
mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
CPPUNIT_ASSERT(mxComponent.is());
return mxComponent;

View File

@@ -84,7 +84,7 @@ uno::Reference< sheet::XNamedRanges > ScNamedRangeObj::init_impl()
rtl::OUString aFileURL;
createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScNamedRangeObj.ods")), aFileURL);
if(!mxComponent.is())
mxComponent = loadFromDesktop(aFileURL);
mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
CPPUNIT_ASSERT(mxComponent.is());
uno::Reference< beans::XPropertySet > xPropSet (mxComponent, UNO_QUERY_THROW);

View File

@@ -72,7 +72,7 @@ uno::Reference< uno::XInterface > ScNamedRangesObj::init(sal_Int32 nSheet)
rtl::OUString aFileURL;
createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScNamedRangeObj.ods")), aFileURL);
if(!mxComponent.is())
mxComponent = loadFromDesktop(aFileURL);
mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
CPPUNIT_ASSERT(mxComponent.is());
uno::Reference< beans::XPropertySet > xPropSet (mxComponent, UNO_QUERY_THROW);

View File

@@ -76,7 +76,7 @@ uno::Reference< uno::XInterface > ScTableSheetObj::init()
rtl::OUString aFileURL;
createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScTableSheetObj.ods")), aFileURL);
if(!mxComponent.is())
mxComponent = loadFromDesktop(aFileURL);
mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
CPPUNIT_ASSERT(mxComponent.is());
uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);

View File

@@ -53,7 +53,7 @@ namespace {
bool hasStream(const uno::Reference<io::XInputStream>& xInStream, const OUString& rName)
{
SfxMedium aMedium;
aMedium.UseInteractionHandler(true);
aMedium.UseInteractionHandler(false);
aMedium.setStreamToLoadFrom(xInStream, true);
SvStream* pStream = aMedium.GetInStream();
if (!pStream)
@@ -77,7 +77,7 @@ bool hasStream(const uno::Reference<io::XInputStream>& xInStream, const OUString
bool isExcel40(const uno::Reference<io::XInputStream>& xInStream)
{
SfxMedium aMedium;
aMedium.UseInteractionHandler(true);
aMedium.UseInteractionHandler(false);
aMedium.setStreamToLoadFrom(xInStream, true);
SvStream* pStream = aMedium.GetInStream();
if (!pStream)

View File

@@ -89,7 +89,7 @@ void SwLayoutTest::test()
rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("test."));
rtl::OUString aExtension(RTL_CONSTASCII_USTRINGPARAM("odt"));
createFileURL(aFileBase, aExtension, aFilePath);
uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFilePath);
uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFilePath, "com.sun.star.text.TextDocument");
CPPUNIT_ASSERT(xComponent.is());
}

View File

@@ -117,7 +117,7 @@ void SwMacrosTest::testStarBasic()
rtl::OUString aFileExtension(aFileFormats[0].pName, strlen(aFileFormats[0].pName), RTL_TEXTENCODING_UTF8 );
rtl::OUString aFileName;
createFileURL(aFileNameBase, aFileExtension, aFileName);
uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName);
uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName, "com.sun.star.text.TextDocument");
CPPUNIT_ASSERT_MESSAGE("Failed to load StarBasic.ods", xComponent.is());
@@ -151,7 +151,7 @@ void SwMacrosTest::testVba()
{
rtl::OUString aFileName;
createFileURL(testInfo[i].sFileBaseName, aFileExtension, aFileName);
uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName);
uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName, "com.sun.star.text.TextDocument");
rtl::OUStringBuffer sMsg( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Failed to load ")) );
sMsg.append ( aFileName );
CPPUNIT_ASSERT_MESSAGE( rtl::OUStringToOString( sMsg.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ).getStr(), xComponent.is() );

View File

@@ -243,7 +243,7 @@ protected:
// Output name early, so in the case of a hang, the name of the hanging input file is visible.
fprintf(stderr, "%s,", pName);
m_nStartTime = osl_getGlobalTimer();
mxComponent = loadFromDesktop(getURLFromSrc(pDir) + OUString::createFromAscii(pName));
mxComponent = loadFromDesktop(getURLFromSrc(pDir) + OUString::createFromAscii(pName), "com.sun.star.text.TextDocument");
calcLayout();
}
@@ -258,7 +258,7 @@ protected:
xStorable->storeToURL(aTempFile.GetURL(), aArgs);
uno::Reference<lang::XComponent> xComponent(xStorable, uno::UNO_QUERY);
xComponent->dispose();
mxComponent = loadFromDesktop(aTempFile.GetURL());
mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument");
if (mpXmlBuffer)
{
xmlBufferFree(mpXmlBuffer);

View File

@@ -46,7 +46,7 @@ namespace unotest {
class OOO_DLLPUBLIC_UNOTEST MacrosTest
{
public:
com::sun::star::uno::Reference< com::sun::star::lang::XComponent > loadFromDesktop(const rtl::OUString& rURL);
com::sun::star::uno::Reference< com::sun::star::lang::XComponent > loadFromDesktop(const OUString& rURL, const char* pDocService = NULL);
protected:
com::sun::star::uno::Reference< com::sun::star::frame::XDesktop2> mxDesktop;

View File

@@ -38,16 +38,25 @@ using namespace com::sun::star;
namespace unotest {
uno::Reference< com::sun::star::lang::XComponent > MacrosTest::loadFromDesktop(const rtl::OUString& rURL)
uno::Reference< com::sun::star::lang::XComponent > MacrosTest::loadFromDesktop(const OUString& rURL, const char* pDocService)
{
uno::Reference< com::sun::star::frame::XComponentLoader> xLoader = uno::Reference< com::sun::star::frame::XComponentLoader >( mxDesktop, uno::UNO_QUERY );
com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > args(1);
args[0].Name = rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("MacroExecutionMode"));
args[0].Name = "MacroExecutionMode";
args[0].Handle = -1;
args[0].Value <<=
com::sun::star::document::MacroExecMode::ALWAYS_EXECUTE_NO_WARN;
args[0].State = com::sun::star::beans::PropertyState_DIRECT_VALUE;
if (pDocService)
{
args.realloc(2);
args[1].Name = "DocumentService";
args[1].Handle = -1;
args[1].Value <<= OUString::createFromAscii(pDocService);
args[1].State = com::sun::star::beans::PropertyState_DIRECT_VALUE;
}
uno::Reference< com::sun::star::lang::XComponent> xComponent= xLoader->loadComponentFromURL(rURL, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_default")), 0, args);
rtl::OUString sMessage = rtl::OUString( "loading failed: " ) + rURL;
CPPUNIT_ASSERT_MESSAGE(rtl::OUStringToOString( sMessage, RTL_TEXTENCODING_UTF8 ).getStr( ), xComponent.is());