LCOV - code coverage report
Current view: top level - dbaccess/qa/unit - dbtest_base.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 16 16 100.0 %
Date: 2015-06-13 12:38:46 Functions: 4 5 80.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include <comphelper/processfactory.hxx>
      11             : #include <test/unoapi_test.hxx>
      12             : 
      13             : #include <com/sun/star/frame/XModel.hpp>
      14             : #include <com/sun/star/frame/Desktop.hpp>
      15             : #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
      16             : #include <com/sun/star/sdbc/XConnection.hpp>
      17             : #include <com/sun/star/sdbc/XDataSource.hpp>
      18             : 
      19             : using namespace ::com::sun::star;
      20             : using namespace ::com::sun::star::frame;
      21             : using namespace ::com::sun::star::sdb;
      22             : using namespace ::com::sun::star::sdbc;
      23             : using namespace ::com::sun::star::uno;
      24             : 
      25           1 : class DBTestBase
      26             :     : public UnoApiTest
      27             : {
      28             : public:
      29           1 :     DBTestBase() : UnoApiTest("dbaccess/qa/unit/data") {};
      30             : 
      31             :     uno::Reference< XOfficeDatabaseDocument >
      32             :         getDocumentForFileName(const OUString &sFileName);
      33             : 
      34             :     uno::Reference< XConnection >
      35             :         getConnectionForDocument(
      36             :             uno::Reference< XOfficeDatabaseDocument >& xDocument);
      37             : };
      38             : 
      39             : uno::Reference< XOfficeDatabaseDocument >
      40           1 :     DBTestBase::getDocumentForFileName(const OUString &sFileName)
      41             : {
      42           1 :     OUString sFilePath;
      43           1 :     createFileURL(sFileName, sFilePath);
      44           2 :     uno::Reference< lang::XComponent > xComponent (loadFromDesktop(sFilePath));
      45           1 :     CPPUNIT_ASSERT(xComponent.is());
      46             : 
      47           1 :     uno::Reference< XOfficeDatabaseDocument > xDocument(xComponent, UNO_QUERY);
      48           1 :     CPPUNIT_ASSERT(xDocument.is());
      49             : 
      50           2 :     return xDocument;
      51             : }
      52             : 
      53           1 : uno::Reference< XConnection > DBTestBase::getConnectionForDocument(
      54             :     uno::Reference< XOfficeDatabaseDocument >& xDocument)
      55             : {
      56           1 :     uno::Reference< XDataSource > xDataSource = xDocument->getDataSource();
      57           1 :     CPPUNIT_ASSERT(xDataSource.is());
      58             : 
      59           1 :     uno::Reference< XConnection > xConnection = xDataSource->getConnection("","");
      60           1 :     CPPUNIT_ASSERT(xConnection.is());
      61             : 
      62           1 :     return xConnection;
      63             : }
      64             : 
      65             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11