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

Noel Power noelp at kemper.freedesktop.org
Thu Jul 5 07:03:18 PDT 2012


 basic/CppunitTest_basic_nested_struct.mk |   49 +++++++++++++++++++++++++++++++
 basic/qa/cppunit/test_nested_struct.cxx  |   38 ++++++++++++++++++++++++
 2 files changed, 87 insertions(+)

New commits:
commit 8e9e166d35191eaacfe2001fa0d50fb8c29394f4
Author: Noel Power <noel.power at novell.com>
Date:   Thu Jul 5 15:02:06 2012 +0100

    fix missing makefile, also add a further test to test_nested_struct.cxx
    
    Change-Id: I7da88595fd3024f72b260267e34200375358e401

diff --git a/basic/CppunitTest_basic_nested_struct.mk b/basic/CppunitTest_basic_nested_struct.mk
new file mode 100644
index 0000000..904e666
--- /dev/null
+++ b/basic/CppunitTest_basic_nested_struct.mk
@@ -0,0 +1,49 @@
+$(eval $(call gb_CppunitTest_CppunitTest,basic_nested_struct))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,basic_nested_struct, \
+    basic/qa/cppunit/test_nested_struct \
+))
+
+# add a list of all needed libraries here
+$(eval $(call gb_CppunitTest_use_libraries,basic_nested_struct, \
+    comphelper \
+    cppu \
+    cppuhelper \
+    sal \
+    salhelper \
+    sb \
+    sot \
+    svl \
+    svt \
+    tl \
+    utl \
+    vcl \
+    xcr \
+    test \
+    $(gb_STDLIBS) \
+))
+
+ifeq ($(GUI),WNT)
+$(eval $(call gb_CppunitTest_use_libraries,basic_nested_struct, \
+	oleaut32 \
+))
+endif
+
+$(eval $(call gb_CppunitTest_set_include,basic_nested_struct,\
+-I$(SRCDIR)/basic/source/inc \
+-I$(SRCDIR)/basic/inc \
+$$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,basic_nested_struct,\
+    offapi \
+    udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,basic_nested_struct))
+
+$(eval $(call gb_CppunitTest_use_components,basic_nested_struct,\
+    configmgr/source/configmgr \
+    ucb/source/core/ucb1 \
+))
+$(eval $(call gb_CppunitTest_use_configuration,basic_nested_struct))
diff --git a/basic/qa/cppunit/test_nested_struct.cxx b/basic/qa/cppunit/test_nested_struct.cxx
index f0684bf..defcaf1 100644
--- a/basic/qa/cppunit/test_nested_struct.cxx
+++ b/basic/qa/cppunit/test_nested_struct.cxx
@@ -19,16 +19,20 @@ namespace
         public:
         Nested_Struct() {};
         void testAssign1();
+        void testOldAssign();
         // Adds code needed to register the test suite
         CPPUNIT_TEST_SUITE(Nested_Struct);
 
         // Declares the method as a test to call
         CPPUNIT_TEST(testAssign1);
+        CPPUNIT_TEST(testOldAssign);
 
         // End of test suite definition
         CPPUNIT_TEST_SUITE_END();
     };
 
+// tests the new behaviour, we should be able to
+// directly modify the value of the nested 'HorizontalLine' struct
 rtl::OUString sTestSource1(
     "Function simpleNestStructAccess() as Integer\n"
     "Dim b0 as new \"com.sun.star.table.TableBorder\"\n"
@@ -37,6 +41,22 @@ rtl::OUString sTestSource1(
     "End Function\n"
 );
 
+// tests the old behaviour, we should still be able
+// to use the old workaround of
+// a) creating a new instance BorderLine,
+// b) cloning the new instance with the value of b0.HorizontalLine
+// c) modifying the new instance
+// d) setting b0.HorizontalLine with the value of the new instance
+rtl::OUString sTestSource2(
+    "Function simpleRegressionTestOld()\n"
+    "Dim b0 as new \"com.sun.star.table.TableBorder\", l as new \"com.sun.star.table.BorderLine\"\n"
+    "l = b0.HorizontalLine\n"
+    "l.OuterLineWidth = 9\n"
+    "b0.HorizontalLine = l\n"
+    "simpleRegressionTestOld = b0.HorizontalLine.OuterLineWidth\n"
+"End Function\n"
+);
+
 void Nested_Struct::testAssign1()
 {
     CPPUNIT_ASSERT_MESSAGE( "No resource manager", basicDLL().GetBasResMgr() != NULL );
@@ -55,6 +75,24 @@ void Nested_Struct::testAssign1()
     CPPUNIT_ASSERT(pNew->GetInteger() == 9 );
 }
 
+void Nested_Struct::testOldAssign()
+{
+    CPPUNIT_ASSERT_MESSAGE( "No resource manager", basicDLL().GetBasResMgr() != NULL );
+    StarBASICRef pBasic = new StarBASIC();
+    ResetError();
+    StarBASIC::SetGlobalErrorHdl( LINK( this, Nested_Struct, BasicErrorHdl ) );
+
+    SbModule* pMod = pBasic->MakeModule( rtl::OUString( "TestModule" ), sTestSource2 );
+    pMod->Compile();
+    CPPUNIT_ASSERT_MESSAGE("testOldAssign fails with compile error",!HasError() );
+    SbMethod* pMeth = static_cast<SbMethod*>(pMod->Find( rtl::OUString("simpleRegressionTestOld"),  SbxCLASS_METHOD ));
+    CPPUNIT_ASSERT_MESSAGE("testOldAssign no method found", pMeth );
+    SbxVariableRef refTemp = pMeth;
+    // forces a broadcast
+    SbxVariableRef pNew = new  SbxMethod( *((SbxMethod*)pMeth));
+    CPPUNIT_ASSERT(pNew->GetInteger() == 9 );
+}
+
   // Put the test suite in the registry
   CPPUNIT_TEST_SUITE_REGISTRATION(Nested_Struct);
 } // namespace


More information about the Libreoffice-commits mailing list