diff options
author | Noel Power <noel.power@novell.com> | 2011-10-24 14:26:33 +0100 |
---|---|---|
committer | Noel Power <noel.power@novell.com> | 2011-10-24 15:07:53 +0100 |
commit | 82fb60bc563b444679617396cb4d22a740427e6d (patch) | |
tree | d7265fcd29c542eb87d5f8b3b260c224cf6a79e0 | |
parent | daca9c81e4be825aff0717d599d815a87d71b412 (diff) |
make vba.xls return 'OK' on success, adjust macros-test.cxx to test for 'OK'
-rw-r--r-- | sc/qa/unit/data/xls/vba.xls | bin | 31232 -> 33280 bytes | |||
-rw-r--r-- | sc/qa/unit/macros-test.cxx | 73 |
2 files changed, 47 insertions, 26 deletions
diff --git a/sc/qa/unit/data/xls/vba.xls b/sc/qa/unit/data/xls/vba.xls Binary files differindex 2ee53a5609a5..399b1ec20675 100644 --- a/sc/qa/unit/data/xls/vba.xls +++ b/sc/qa/unit/data/xls/vba.xls 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<SAL_N_ELEMENTS( testInfo ); ++i ) + { + rtl::OUString aFileName; + createFileURL(testInfo[i].sFileBaseName, aFileExtension, aFileName); + ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[1].nFormatType); + rtl::OUString sMsg( RTL_CONSTASCII_USTRINGPARAM("Failed to load ") ); + sMsg.concat( aFileName ); + CPPUNIT_ASSERT_MESSAGE( rtl::OUStringToOString( sMsg, RTL_TEXTENCODING_UTF8 ).getStr(), 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 + String sUrl = testInfo[i].sMacroUrl; + Any aRet; + Sequence< sal_Int16 > 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() |