LCOV - code coverage report
Current view: top level - dbaccess/qa/unit - dbtest_base.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 16 16 100.0 %
Date: 2014-04-11 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           4 : class DBTestBase
      26             :     : public UnoApiTest
      27             : {
      28             : protected:
      29             :     static const OUString our_sFilePath;
      30             : public:
      31           4 :     DBTestBase() : UnoApiTest("dbaccess/qa/unit/data") {};
      32             : 
      33             :     uno::Reference< XOfficeDatabaseDocument >
      34             :         getDocumentForFileName(const OUString &sFileName);
      35             : 
      36             :     uno::Reference< XConnection >
      37             :         getConnectionForDocument(
      38             :             uno::Reference< XOfficeDatabaseDocument >& xDocument);
      39             : };
      40             : 
      41             : uno::Reference< XOfficeDatabaseDocument >
      42           3 :     DBTestBase::getDocumentForFileName(const OUString &sFileName)
      43             : {
      44           3 :     OUString sFilePath;
      45           3 :     createFileURL(sFileName, sFilePath);
      46           6 :     uno::Reference< lang::XComponent > xComponent (loadFromDesktop(sFilePath));
      47           3 :     CPPUNIT_ASSERT(xComponent.is());
      48             : 
      49           3 :     uno::Reference< XOfficeDatabaseDocument > xDocument(xComponent, UNO_QUERY);
      50           3 :     CPPUNIT_ASSERT(xDocument.is());
      51             : 
      52           6 :     return xDocument;
      53             : }
      54             : 
      55           3 : uno::Reference< XConnection > DBTestBase::getConnectionForDocument(
      56             :     uno::Reference< XOfficeDatabaseDocument >& xDocument)
      57             : {
      58           3 :     uno::Reference< XDataSource > xDataSource = xDocument->getDataSource();
      59           3 :     CPPUNIT_ASSERT(xDataSource.is());
      60             : 
      61           3 :     uno::Reference< XConnection > xConnection = xDataSource->getConnection("","");
      62           3 :     CPPUNIT_ASSERT(xConnection.is());
      63             : 
      64           3 :     return xConnection;
      65             : }
      66             : 
      67             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10