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

Noel Power noelp at kemper.freedesktop.org
Mon May 14 04:01:14 PDT 2012


 basic/CppunitTest_basic_enable.mk |   54 +++++++++++++++++++++++++
 basic/Module_basic.mk             |    1 
 basic/qa/cppunit/test_append.cxx  |   82 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 137 insertions(+)

New commits:
commit d87676da2201bca921f319bd7b02ef8853edfa4f
Author: Noel Power <noel.power at novell.com>
Date:   Mon May 14 12:00:00 2012 +0100

    simple compile test for use of 'Enable' in a Dim statement
    
    Change-Id: I051dbb5cd56fe61e2b0aea1184dcdb03c6413834

diff --git a/basic/CppunitTest_basic_enable.mk b/basic/CppunitTest_basic_enable.mk
new file mode 100644
index 0000000..e325650
--- /dev/null
+++ b/basic/CppunitTest_basic_enable.mk
@@ -0,0 +1,54 @@
+$(eval $(call gb_CppunitTest_CppunitTest,basic_enable))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,basic_enable, \
+    basic/qa/cppunit/test_append \
+))
+
+$(eval $(call gb_CppunitTest_use_library_objects,basic_enable,sb))
+
+# add a list of all needed libraries here
+$(eval $(call gb_CppunitTest_use_libraries,basic_enable, \
+    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_enable, \
+	oleaut32 \
+))
+endif
+
+$(eval $(call gb_CppunitTest_set_include,basic_enable,\
+-I$(SRCDIR)/basic/source/inc \
+-I$(SRCDIR)/basic/inc \
+$$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,basic_enable,\
+    offapi \
+    udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,basic_enable))
+
+$(eval $(call gb_CppunitTest_use_components,basic_enable,\
+    configmgr/source/configmgr \
+    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/Module_basic.mk b/basic/Module_basic.mk
index c3ba0ee..fe430ff 100644
--- a/basic/Module_basic.mk
+++ b/basic/Module_basic.mk
@@ -36,6 +36,7 @@ $(eval $(call gb_Module_add_targets,basic,\
 
 $(eval $(call gb_Module_add_check_targets,basic,\
      CppunitTest_basic_scanner \
+     CppunitTest_basic_enable \
 ))
 
 endif
diff --git a/basic/qa/cppunit/test_append.cxx b/basic/qa/cppunit/test_append.cxx
new file mode 100644
index 0000000..2afd912
--- /dev/null
+++ b/basic/qa/cppunit/test_append.cxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+#include "sal/config.h"
+#include "sal/precppunit.hxx"
+
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
+#include "cppunit/plugin/TestPlugIn.h"
+
+#include <test/bootstrapfixture.hxx>
+
+#include "osl/file.hxx"
+#include "osl/process.h"
+
+#include "basic/sbstar.hxx"
+#include "basic/sbmod.hxx"
+#include "basic/basrdll.hxx"
+namespace
+{
+    class EnableTest : public test::BootstrapFixture
+    {
+        private:
+        bool mbError;
+        public:
+        EnableTest() : mbError(false) {};
+        void testDimEnable();
+        // Adds code needed to register the test suite
+        CPPUNIT_TEST_SUITE(EnableTest);
+
+        // Declares the method as a test to call
+        CPPUNIT_TEST(testDimEnable);
+
+        // End of test suite definition
+        CPPUNIT_TEST_SUITE_END();
+
+        DECL_LINK( BasicErrorHdl, StarBASIC * );
+        bool HasError() { return mbError; }
+        BasicDLL& basicDLL()
+        {
+            static BasicDLL maDll; // we need a dll instance for resouce manager etc.
+            return maDll;
+        }
+    };
+
+IMPL_LINK( EnableTest, BasicErrorHdl, StarBASIC *, /*pBasic*/)
+{
+    fprintf(stderr,"Got error: \n\t%s!!!\n", rtl::OUStringToOString( StarBASIC::GetErrorText(), RTL_TEXTENCODING_UTF8 ).getStr() );
+    mbError = true;
+    return 0;
+}
+
+class MyBASIC : public StarBASIC
+{
+    public:
+    MyBASIC(){}
+    ~MyBASIC(){}
+};
+
+void EnableTest::testDimEnable()
+{
+    CPPUNIT_ASSERT_MESSAGE( "No resource manager", basicDLL().GetBasResMgr() != NULL );
+    std::auto_ptr<MyBASIC> pBasic;
+    pBasic.reset( new MyBASIC() );
+    StarBASIC::SetGlobalErrorHdl( LINK( this, EnableTest, BasicErrorHdl ) );
+
+    rtl::OUString sSource("Sub Test\n");
+    sSource += rtl::OUString("Dim Enable as String\n");
+    sSource += rtl::OUString("End Sub\n");
+
+    SbModule* pMod = pBasic->MakeModule( rtl::OUString( "TestModule" ), sSource );
+    pMod->Compile();
+
+    CPPUNIT_ASSERT_MESSAGE("Dim causes compile error", !mbError );
+    StarBASIC::SetGlobalErrorHdl( Link() );
+}
+
+  // Put the test suite in the registry
+  CPPUNIT_TEST_SUITE_REGISTRATION(EnableTest);
+} // namespace
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list