From 82fb60bc563b444679617396cb4d22a740427e6d Mon Sep 17 00:00:00 2001 From: Noel Power Date: Mon, 24 Oct 2011 14:26:33 +0100 Subject: make vba.xls return 'OK' on success, adjust macros-test.cxx to test for 'OK' --- sc/qa/unit/data/xls/vba.xls | Bin 31232 -> 33280 bytes sc/qa/unit/macros-test.cxx | 73 ++++++++++++++++++++++++++++---------------- 2 files changed, 47 insertions(+), 26 deletions(-) (limited to 'sc/qa/unit') diff --git a/sc/qa/unit/data/xls/vba.xls b/sc/qa/unit/data/xls/vba.xls index 2ee53a5609a5..399b1ec20675 100644 Binary files a/sc/qa/unit/data/xls/vba.xls and b/sc/qa/unit/data/xls/vba.xls differ diff --git a/sc/qa/unit/macros-test.cxx b/sc/qa/unit/macros-test.cxx index e3c9974e3dba..3737869aa0ef 100644 --- a/sc/qa/unit/macros-test.cxx +++ b/sc/qa/unit/macros-test.cxx @@ -165,7 +165,7 @@ public: CPPUNIT_TEST(testStarBasic); //enable if you want to hack vba support for unit tests //does not work, still problems during loading - //CPPUNIT_TEST(testVba); + CPPUNIT_TEST(testVba); CPPUNIT_TEST_SUITE_END(); @@ -262,37 +262,58 @@ void ScMacrosTest::testStarBasic() xDocSh->DoClose(); } +struct TestMacroInfo +{ + rtl::OUString sFileBaseName; + rtl::OUString sMacroUrl; +}; void ScMacrosTest::testVba() { - const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("vba.")); + TestMacroInfo testInfo[] { + { + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TestAddress.")), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.Star.script:VBAProject.Sheet1.test?language=Basic&location=document")) + }, +/* + vba.xls is still throwing up a basic error :-/ + { + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vba.")), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.Star.script:VBAProject.Modul1.Modul1?language=Basic&location=document")), + } +*/ + }; + rtl::OUString aFileExtension(aFileFormats[1].pName, strlen(aFileFormats[1].pName), RTL_TEXTENCODING_UTF8 ); rtl::OUString aFilterName(aFileFormats[1].pFilterName, strlen(aFileFormats[1].pFilterName), RTL_TEXTENCODING_UTF8) ; - rtl::OUString aFileName; - createFileURL(aFileNameBase, aFileExtension, aFileName); rtl::OUString aFilterType(aFileFormats[1].pTypeName, strlen(aFileFormats[1].pTypeName), RTL_TEXTENCODING_UTF8); std::cout << aFileFormats[1].pName << " Test" << std::endl; - ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[1].nFormatType); - - CPPUNIT_ASSERT_MESSAGE("Failed to load vba.xls", xDocSh.Is()); - - //is it really the right way to call a vba macro through CallXScript? - //it seems that the basic ide does it differently, but then we would need to init all parts ourself - //the problem is that CallXScript inits the basic part - ////BasicIDE::RunMethod takes an SbMethod as parametre - rtl::OUString aURL(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.Star.script:VBAProject.Modul1.Modul1?language=Basic&location=document")); - String sUrl = aURL; - Any aRet; - Sequence< sal_Int16 > aOutParamIndex; - Sequence< Any > aOutParam; - Sequence< uno::Any > aParams; - ScDocument* pDoc = xDocSh->GetDocument(); - - xDocSh->CallXScript(sUrl, aParams, aRet, aOutParamIndex,aOutParam); - double aValue; - pDoc->GetValue(0,0,0,aValue); - std::cout << aValue << std::endl; - CPPUNIT_ASSERT_MESSAGE("script did not change the value of Sheet1.A1",aValue==2); - xDocSh->DoClose(); + for ( sal_uInt32 i=0; i aOutParamIndex; + Sequence< Any > aOutParam; + Sequence< uno::Any > aParams; + ScDocument* pDoc = xDocSh->GetDocument(); + + xDocSh->CallXScript(sUrl, aParams, aRet, aOutParamIndex,aOutParam); + rtl::OUString aStringRes; + aRet >>= aStringRes; + std::cout << "value of Ret " << rtl::OUStringToOString( aStringRes, RTL_TEXTENCODING_UTF8 ).getStr() << std::endl; + CPPUNIT_ASSERT_MESSAGE("script reported failure",aStringRes.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OK") )) ); + xDocSh->DoClose(); + } } ScMacrosTest::ScMacrosTest() -- cgit v1.2.3