LCOV - code coverage report
Current view: top level - sc/qa/extras - scstyleloaderobj.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 44 45 97.8 %
Date: 2014-11-03 Functions: 15 16 93.8 %
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           8 : 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           4 :     CPPUNIT_TEST_SUITE(ScStyleLoaderObj);
      37           2 :     CPPUNIT_TEST(testLoadStylesFromURL);
      38           2 :     CPPUNIT_TEST(testLoadStylesFromDocument);
      39           4 :     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           2 : uno::Reference< lang::XComponent > ScStyleLoaderObj::mxSourceComponent;
      52           2 : uno::Reference< lang::XComponent > ScStyleLoaderObj::mxTargetComponent;
      53             : 
      54             : 
      55           4 : ScStyleLoaderObj::ScStyleLoaderObj()
      56           4 :        : CalcUnoApiTest("sc/qa/extras/testdocuments")
      57             : {
      58           4 : }
      59             : 
      60             : 
      61           4 : uno::Reference< uno::XInterface > ScStyleLoaderObj::init()
      62             : {
      63           4 :   return getTargetComponent();
      64             : }
      65             : 
      66             : 
      67           4 : uno::Reference< lang::XComponent > ScStyleLoaderObj::getTargetComponent(){
      68             :   // target is always an empty document
      69             : 
      70           4 :     if (mxTargetComponent.is())
      71           2 :         closeDocument(mxTargetComponent);
      72             : 
      73           4 :     mxTargetComponent = loadFromDesktop("private:factory/scalc");
      74             : 
      75           4 :     return mxTargetComponent;
      76             : }
      77             : 
      78           2 : uno::Reference< lang::XComponent > ScStyleLoaderObj::getSourceComponent(){
      79             : 
      80           2 :     if (mxSourceComponent.is())
      81           0 :         closeDocument(mxSourceComponent);
      82             : 
      83             :       // get the test file url
      84           2 :       OUString aFileURL = getTestURL();
      85             : 
      86           2 :       if(!mxSourceComponent.is())
      87           2 :           mxSourceComponent = loadFromDesktop(aFileURL);
      88           2 :       CPPUNIT_ASSERT_MESSAGE("Component not loaded",mxSourceComponent.is());
      89             : 
      90           2 :     return mxSourceComponent;
      91             : }
      92             : 
      93           4 : OUString ScStyleLoaderObj::getTestURL(){
      94             : 
      95           4 :       OUString aFileURL;
      96           4 :       createFileURL(OUString("ScStyleLoaderObj.ods"), aFileURL);
      97             : 
      98           4 :       return aFileURL;
      99             : }
     100             : 
     101           4 : void ScStyleLoaderObj::setUp()
     102             : {
     103           4 :     nTest++;
     104           4 :     CalcUnoApiTest::setUp();
     105           4 : }
     106             : 
     107           4 : void ScStyleLoaderObj::tearDown()
     108             : {
     109           4 :     if (nTest == NUMBER_OF_TESTS)
     110             :     {
     111           2 :       if (mxSourceComponent.is())
     112             :       {
     113           2 :           closeDocument(mxSourceComponent);
     114           2 :           mxSourceComponent.clear();
     115             :       }
     116           2 :       if (mxTargetComponent.is())
     117             :       {
     118           2 :           closeDocument(mxTargetComponent);
     119           2 :           mxTargetComponent.clear();
     120             :       }
     121             :     }
     122           4 :     CalcUnoApiTest::tearDown();
     123           4 : }
     124             : 
     125           2 : CPPUNIT_TEST_SUITE_REGISTRATION(ScStyleLoaderObj);
     126             : 
     127             : }
     128             : 
     129           8 : CPPUNIT_PLUGIN_IMPLEMENT();
     130             : 
     131             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10