[Libreoffice-commits] core.git: sc/qa

Noel Power noel.power at suse.com
Wed Jul 31 02:55:26 PDT 2013


 sc/qa/extras/macros-test.cxx                               |   40 +++++++++++++
 sc/qa/extras/testdocuments/MasterScriptProviderProblem.ods |binary
 2 files changed, 40 insertions(+)

New commits:
commit 6add3c38a82bbac7e096327277707ba4858bf26a
Author: Noel Power <noel.power at suse.com>
Date:   Wed Jul 31 10:50:35 2013 +0100

    unit ( slowcheck ) test for fdo#67547
    
    although this really isn't the correct location for the test ( a scripting
    module slowcheck test would be more appropriate I think ). Still better than
     no test.
    
    Change-Id: I434e1217c25ee33b59ea3b09c4500bdd7bb081ba

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index f65b88c..31171c7 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -39,11 +39,13 @@ public:
 
     void testStarBasic();
     void testVba();
+    void testMSP();
     CPPUNIT_TEST_SUITE(ScMacrosTest);
 #if !defined(MACOSX)
     //enable this test if you want to play with star basic macros in unit tests
     //works but does nothing useful yet
     CPPUNIT_TEST(testStarBasic);
+    CPPUNIT_TEST(testMSP);
     CPPUNIT_TEST(testVba);
 #endif
 
@@ -53,6 +55,44 @@ private:
     uno::Reference<uno::XInterface> m_xCalcComponent;
 };
 
+// I suppose you could say this test doesn't really belong here, OTOH
+// we need a full document to run the test ( it related originally to an
+// imported Excel VBA macro ) It's convenient and fast to unit test
+// this the problem this way. Perhaps in the future there will be some sort
+// of slowcheck tests ( requiring a full document environment in the scripting
+// module, we could move the test there then ) - relates to fdo#67547
+void ScMacrosTest::testMSP()
+{
+    const OUString aFileNameBase("MasterScriptProviderProblem.ods");
+    OUString aFileName;
+    createFileURL(aFileNameBase, aFileName);
+    std::cout << "MasterScriptProviderProblem (fdo#67547) test" << std::endl;
+    uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to load MasterScriptProviderProblem.ods", xComponent.is());
+
+    OUString aURL("vnd.sun.Star.script:Standard.Module1.TestMSP?language=Basic&location=document");
+    String sUrl = aURL;
+    Any aRet;
+    Sequence< sal_Int16 > aOutParamIndex;
+    Sequence< Any > aOutParam;
+    Sequence< uno::Any > aParams;
+
+    SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent);
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
+    ScDocShell* xDocSh = static_cast<ScDocShell*>(pFoundShell);
+    ScDocument* pDoc = xDocSh->GetDocument();
+
+    pFoundShell->CallXScript(xComponent, sUrl, aParams, aRet, aOutParamIndex,aOutParam);
+    OUString sResult;
+    aRet >>= sResult;
+
+    std::cout << "Result is " << sResult << std::endl;
+    CPPUNIT_ASSERT_MESSAGE("TestMSP ( for fdo#67547) failed", sResult == "OK" );
+    xDocSh->DoClose();
+}
+
 void ScMacrosTest::testStarBasic()
 {
     const OUString aFileNameBase("StarBasic.ods");
diff --git a/sc/qa/extras/testdocuments/MasterScriptProviderProblem.ods b/sc/qa/extras/testdocuments/MasterScriptProviderProblem.ods
new file mode 100644
index 0000000..35e2b985
Binary files /dev/null and b/sc/qa/extras/testdocuments/MasterScriptProviderProblem.ods differ


More information about the Libreoffice-commits mailing list