LCOV - code coverage report
Current view: top level - sc/qa/extras - scstyleloaderobj.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 44 45 97.8 %
Date: 2015-06-13 12:38:46 Functions: 18 19 94.7 %
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 <test/calc_unoapi_test.hxx>
      11             : #include <test/sheet/xstyleloader.hxx>
      12             : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      13             : #include <com/sun/star/beans/XPropertySet.hpp>
      14             : 
      15             : 
      16             : using namespace css;
      17             : using namespace css::uno;
      18             : 
      19             : namespace sc_apitest {
      20             : 
      21             : #define NUMBER_OF_TESTS 2
      22             : 
      23           4 : class ScStyleLoaderObj : public CalcUnoApiTest, apitest::XStyleLoader
      24             : {
      25             : public:
      26             :     ScStyleLoaderObj();
      27             : 
      28             :     virtual void setUp() SAL_OVERRIDE;
      29             :     virtual void tearDown() SAL_OVERRIDE;
      30             : 
      31             :     virtual uno::Reference< uno::XInterface > init() SAL_OVERRIDE;
      32             :     virtual uno::Reference< lang::XComponent  > getTargetComponent() SAL_OVERRIDE;
      33             :     virtual uno::Reference< lang::XComponent > getSourceComponent() SAL_OVERRIDE;
      34             :     virtual OUString getTestURL() SAL_OVERRIDE;
      35             : 
      36           2 :     CPPUNIT_TEST_SUITE(ScStyleLoaderObj);
      37           1 :     CPPUNIT_TEST(testLoadStylesFromURL);
      38           1 :     CPPUNIT_TEST(testLoadStylesFromDocument);
      39           5 :     CPPUNIT_TEST_SUITE_END();
      40             : 
      41             : private:
      42             : 
      43             :     static sal_Int32 nTest;
      44             :     static uno::Reference< lang::XComponent > mxSourceComponent;
      45             :     static uno::Reference< lang::XComponent > mxTargetComponent;
      46             : 
      47             : 
      48             : };
      49             : 
      50             : sal_Int32 ScStyleLoaderObj::nTest = 0;
      51           1 : uno::Reference< lang::XComponent > ScStyleLoaderObj::mxSourceComponent;
      52           1 : uno::Reference< lang::XComponent > ScStyleLoaderObj::mxTargetComponent;
      53             : 
      54             : 
      55           2 : ScStyleLoaderObj::ScStyleLoaderObj()
      56           2 :        : CalcUnoApiTest("sc/qa/extras/testdocuments")
      57             : {
      58           2 : }
      59             : 
      60             : 
      61           2 : uno::Reference< uno::XInterface > ScStyleLoaderObj::init()
      62             : {
      63           2 :   return getTargetComponent();
      64             : }
      65             : 
      66             : 
      67           2 : uno::Reference< lang::XComponent > ScStyleLoaderObj::getTargetComponent(){
      68             :   // target is always an empty document
      69             : 
      70           2 :     if (mxTargetComponent.is())
      71           1 :         closeDocument(mxTargetComponent);
      72             : 
      73           2 :     mxTargetComponent = loadFromDesktop("private:factory/scalc");
      74             : 
      75           2 :     return mxTargetComponent;
      76             : }
      77             : 
      78           1 : uno::Reference< lang::XComponent > ScStyleLoaderObj::getSourceComponent(){
      79             : 
      80           1 :     if (mxSourceComponent.is())
      81           0 :         closeDocument(mxSourceComponent);
      82             : 
      83             :       // get the test file url
      84           1 :       OUString aFileURL = getTestURL();
      85             : 
      86           1 :       if(!mxSourceComponent.is())
      87           1 :           mxSourceComponent = loadFromDesktop(aFileURL);
      88           1 :       CPPUNIT_ASSERT_MESSAGE("Component not loaded",mxSourceComponent.is());
      89             : 
      90           1 :     return mxSourceComponent;
      91             : }
      92             : 
      93           2 : OUString ScStyleLoaderObj::getTestURL(){
      94             : 
      95           2 :       OUString aFileURL;
      96           2 :       createFileURL(OUString("ScStyleLoaderObj.ods"), aFileURL);
      97             : 
      98           2 :       return aFileURL;
      99             : }
     100             : 
     101           2 : void ScStyleLoaderObj::setUp()
     102             : {
     103           2 :     nTest++;
     104           2 :     CalcUnoApiTest::setUp();
     105           2 : }
     106             : 
     107           2 : void ScStyleLoaderObj::tearDown()
     108             : {
     109           2 :     if (nTest == NUMBER_OF_TESTS)
     110             :     {
     111           1 :       if (mxSourceComponent.is())
     112             :       {
     113           1 :           closeDocument(mxSourceComponent);
     114           1 :           mxSourceComponent.clear();
     115             :       }
     116           1 :       if (mxTargetComponent.is())
     117             :       {
     118           1 :           closeDocument(mxTargetComponent);
     119           1 :           mxTargetComponent.clear();
     120             :       }
     121             :     }
     122           2 :     CalcUnoApiTest::tearDown();
     123           2 : }
     124             : 
     125           1 : CPPUNIT_TEST_SUITE_REGISTRATION(ScStyleLoaderObj);
     126             : 
     127             : }
     128             : 
     129           4 : CPPUNIT_PLUGIN_IMPLEMENT();
     130             : 
     131             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11