summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2013-11-09 22:33:33 +0100
committerLionel Elie Mamane <lionel@mamane.lu>2013-11-09 22:34:14 +0100
commit1b85ffca7d56cb1336800d04761884149a7b4247 (patch)
treef8ca04c6e67136dfcbe7ecd493c5adc6f1aea16b /dbaccess
parentf0389a7f4fa39e437642a7236d7804c6a0cb47a0 (diff)
factorise code; make DBTestBase a UnoApiTest
Change-Id: I29c131f60caa36c464d99b9b86a59e2e16ce94e3
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/qa/unit/dbtest_base.cxx35
-rw-r--r--dbaccess/qa/unit/embeddeddb_performancetest.cxx38
2 files changed, 28 insertions, 45 deletions
diff --git a/dbaccess/qa/unit/dbtest_base.cxx b/dbaccess/qa/unit/dbtest_base.cxx
index 633a14402ce8..1f226c1e88f6 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 0ba4ac4a58cc..c326db65f809 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;