[Libreoffice-commits] .: basic/CppunitTest_basic_enable.mk basic/qa

Noel Power noelp at kemper.freedesktop.org
Mon May 14 05:59:14 PDT 2012


 basic/CppunitTest_basic_enable.mk |    3 ---
 basic/qa/cppunit/test_append.cxx  |   34 +++++++++++++++++++++++++++-------
 2 files changed, 27 insertions(+), 10 deletions(-)

New commits:
commit d7149abc7793eafd654214ed9446b3d84d628d58
Author: Noel Power <noel.power at novell.com>
Date:   Mon May 14 13:58:43 2012 +0100

    add simple basic runtime test
    
    Change-Id: If8742cb174aa1d017763d3ba42807ac4cf6c7420

diff --git a/basic/CppunitTest_basic_enable.mk b/basic/CppunitTest_basic_enable.mk
index e325650..487cdd4 100644
--- a/basic/CppunitTest_basic_enable.mk
+++ b/basic/CppunitTest_basic_enable.mk
@@ -49,6 +49,3 @@ $(eval $(call gb_CppunitTest_use_components,basic_enable,\
     ucb/source/core/ucb1 \
 ))
 $(eval $(call gb_CppunitTest_use_configuration,basic_enable))
-
-$(eval $(call gb_CppunitTest_use_filter_configuration,basic_enable))
-
diff --git a/basic/qa/cppunit/test_append.cxx b/basic/qa/cppunit/test_append.cxx
index 2afd912..622d1d2 100644
--- a/basic/qa/cppunit/test_append.cxx
+++ b/basic/qa/cppunit/test_append.cxx
@@ -14,6 +14,7 @@
 
 #include "basic/sbstar.hxx"
 #include "basic/sbmod.hxx"
+#include "basic/sbmeth.hxx"
 #include "basic/basrdll.hxx"
 namespace
 {
@@ -24,11 +25,13 @@ namespace
         public:
         EnableTest() : mbError(false) {};
         void testDimEnable();
+        void testEnableRuntime();
         // Adds code needed to register the test suite
         CPPUNIT_TEST_SUITE(EnableTest);
 
         // Declares the method as a test to call
         CPPUNIT_TEST(testDimEnable);
+        CPPUNIT_TEST(testEnableRuntime);
 
         // End of test suite definition
         CPPUNIT_TEST_SUITE_END();
@@ -49,18 +52,35 @@ IMPL_LINK( EnableTest, BasicErrorHdl, StarBASIC *, /*pBasic*/)
     return 0;
 }
 
-class MyBASIC : public StarBASIC
+void EnableTest::testEnableRuntime()
 {
-    public:
-    MyBASIC(){}
-    ~MyBASIC(){}
-};
+    CPPUNIT_ASSERT_MESSAGE( "No resource manager", basicDLL().GetBasResMgr() != NULL );
+    StarBASICRef pBasic = new StarBASIC();
+    StarBASIC::SetGlobalErrorHdl( LINK( this, EnableTest, BasicErrorHdl ) );
+
+    rtl::OUString    sSource("Function Test as Integer\n");
+    sSource += rtl::OUString("Dim Enable as Integer\n");
+    sSource += rtl::OUString("Enable = 1\n");
+    sSource += rtl::OUString("Enable = Enable + 2\n");
+    sSource += rtl::OUString("Test = Enable\n");
+    sSource += rtl::OUString("End Function\n");
+
+    SbModule* pMod = pBasic->MakeModule( rtl::OUString( "TestModule" ), sSource );
+    pMod->Compile();
+    CPPUNIT_ASSERT_MESSAGE("testEnableRuntime fails with compile error",!mbError );
+    SbMethod* pMeth = static_cast<SbMethod*>(pMod->Find( rtl::OUString("Test"),  SbxCLASS_METHOD ));
+    CPPUNIT_ASSERT_MESSAGE("testEnableRuntime no method found", pMeth );
+    SbxVariableRef refTemp = pMeth;
+    // forces a broadcast
+    SbxVariableRef pNew = new  SbxMethod( *((SbxMethod*)pMeth));
+    CPPUNIT_ASSERT(pNew->GetInteger() == 3 );
+    StarBASIC::SetGlobalErrorHdl( Link() );
 
+}
 void EnableTest::testDimEnable()
 {
     CPPUNIT_ASSERT_MESSAGE( "No resource manager", basicDLL().GetBasResMgr() != NULL );
-    std::auto_ptr<MyBASIC> pBasic;
-    pBasic.reset( new MyBASIC() );
+    StarBASICRef pBasic = new StarBASIC();
     StarBASIC::SetGlobalErrorHdl( LINK( this, EnableTest, BasicErrorHdl ) );
 
     rtl::OUString sSource("Sub Test\n");


More information about the Libreoffice-commits mailing list