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

Lionel Elie Mamane lionel at mamane.lu
Sat Nov 9 22:34:46 CET 2013


 dbaccess/qa/unit/dbtest_base.cxx                |   35 +++++-----------------
 dbaccess/qa/unit/embeddeddb_performancetest.cxx |   38 ++++++++++++------------
 2 files changed, 28 insertions(+), 45 deletions(-)

New commits:
commit 1b85ffca7d56cb1336800d04761884149a7b4247
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Sat Nov 9 22:33:33 2013 +0100

    factorise code; make DBTestBase a UnoApiTest
    
    Change-Id: I29c131f60caa36c464d99b9b86a59e2e16ce94e3

diff --git a/dbaccess/qa/unit/dbtest_base.cxx b/dbaccess/qa/unit/dbtest_base.cxx
index 633a144..1f226c1 100644
--- a/dbaccess/qa/unit/dbtest_base.cxx
+++ b/dbaccess/qa/unit/dbtest_base.cxx
@@ -8,8 +8,7 @@
  */
 
 #include <comphelper/processfactory.hxx>
-#include <test/bootstrapfixture.hxx>
-#include <unotest/macros_test.hxx>
+#include <test/unoapi_test.hxx>
 
 #include <com/sun/star/frame/XModel.hpp>
 #include <com/sun/star/frame/Desktop.hpp>
@@ -24,30 +23,27 @@ using namespace ::com::sun::star::sdbc;
 using namespace ::com::sun::star::uno;
 
 class DBTestBase
-    : public ::test::BootstrapFixture
-    , public ::unotest::MacrosTest
+    : public UnoApiTest
 {
 protected:
     static const OUString our_sFilePath;
 public:
-    virtual void setUp();
-    virtual void tearDown();
+    DBTestBase() : UnoApiTest("dbaccess/qa/unit/data") {};
 
     uno::Reference< XOfficeDatabaseDocument >
-        getDocumentForFileName(OUString sFileName);
+        getDocumentForFileName(const OUString &sFileName);
 
     uno::Reference< XConnection >
         getConnectionForDocument(
             uno::Reference< XOfficeDatabaseDocument >& xDocument);
 };
 
-const OUString DBTestBase::our_sFilePath("/dbaccess/qa/unit/data/");
-
 uno::Reference< XOfficeDatabaseDocument >
-    DBTestBase::getDocumentForFileName(OUString sFileName)
+    DBTestBase::getDocumentForFileName(const OUString &sFileName)
 {
-    uno::Reference< lang::XComponent > xComponent =
-        loadFromDesktop(getSrcRootURL() + our_sFilePath + sFileName);
+    OUString sFilePath;
+    createFileURL(sFileName, sFilePath);
+    uno::Reference< lang::XComponent > xComponent (loadFromDesktop(sFilePath));
     CPPUNIT_ASSERT(xComponent.is());
 
     uno::Reference< XOfficeDatabaseDocument > xDocument(xComponent, UNO_QUERY);
@@ -68,19 +64,4 @@ uno::Reference< XConnection > DBTestBase::getConnectionForDocument(
     return xConnection;
 }
 
-
-void DBTestBase::setUp()
-{
-    ::test::BootstrapFixture::setUp();
-
-    mxDesktop = ::com::sun::star::frame::Desktop::create(
-                    ::comphelper::getProcessComponentContext());
-    CPPUNIT_ASSERT(mxDesktop.is());
-}
-
-void DBTestBase::tearDown()
-{
-    test::BootstrapFixture::tearDown();
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/qa/unit/embeddeddb_performancetest.cxx b/dbaccess/qa/unit/embeddeddb_performancetest.cxx
index 0ba4ac4..c326db6 100644
--- a/dbaccess/qa/unit/embeddeddb_performancetest.cxx
+++ b/dbaccess/qa/unit/embeddeddb_performancetest.cxx
@@ -100,6 +100,8 @@ private:
 
     void setupTestTable(uno::Reference< XConnection >& xConnection);
 
+    SvFileStream *getWordListStream();
+
     // Individual Tests
     void performPreparedStatementInsertTest(
         uno::Reference< XConnection >& xConnection,
@@ -123,6 +125,22 @@ public:
     CPPUNIT_TEST_SUITE_END();
 };
 
+SvFileStream* EmbeddedDBPerformanceTest::getWordListStream()
+{
+    OUString wlPath;
+    createFileURL("wordlist", wlPath);
+
+    SvFileStream *pFile(new SvFileStream(wlPath, STREAM_READ));
+
+    if (!pFile)
+    {
+        fprintf(stderr, "Please ensure the wordlist is present\n");
+        CPPUNIT_ASSERT(false);
+    }
+
+    return pFile;
+}
+
 void EmbeddedDBPerformanceTest::printTimes(
     const TimeValue* pTime1,
     const TimeValue* pTime2,
@@ -252,15 +270,7 @@ void EmbeddedDBPerformanceTest::performPreparedStatementInsertTest(
 
     uno::Reference< XParameters > xParameters(xPreparedStatement, UNO_QUERY_THROW);
 
-    ::boost::scoped_ptr< SvFileStream > pFile(new SvFileStream(
-            getSrcRootURL() + our_sFilePath + "wordlist",
-            STREAM_READ));
-
-    if (!pFile)
-    {
-        fprintf(stderr, "Please ensure the wordlist is present\n");
-        CPPUNIT_ASSERT(false);
-    }
+    ::boost::scoped_ptr< SvFileStream > pFile(getWordListStream());
 
     OUString aWord;
     sal_Int32 aID = 0;
@@ -296,15 +306,7 @@ void EmbeddedDBPerformanceTest::performStatementInsertTest(
     uno::Reference< XStatement > xStatement =
         xConnection->createStatement();
 
-    ::boost::scoped_ptr< SvFileStream > pFile(new SvFileStream(
-            getSrcRootURL() + our_sFilePath + "wordlist",
-            STREAM_READ));
-
-    if (!pFile)
-    {
-        fprintf(stderr, "Please ensure the wordlist is present\n");
-        CPPUNIT_ASSERT(false);
-    }
+    ::boost::scoped_ptr< SvFileStream > pFile(getWordListStream());
 
     OUString aWord;
     sal_Int32 aID = 0;


More information about the Libreoffice-commits mailing list