LCOV - code coverage report
Current view: top level - vcl/qa/cppunit/app - test_IconThemeScanner.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 34 34 100.0 %
Date: 2014-04-11 Functions: 11 11 100.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 <stdexcept>
      11             : 
      12             : #include <sal/types.h>
      13             : 
      14             : #include <rtl/ustring.hxx>
      15             : #include <vcl/IconThemeScanner.hxx>
      16             : #include <vcl/IconThemeInfo.hxx>
      17             : 
      18             : #include <cppunit/TestAssert.h>
      19             : #include <cppunit/TestFixture.h>
      20             : #include <cppunit/extensions/HelperMacros.h>
      21             : #include <cppunit/plugin/TestPlugIn.h>
      22             : 
      23           9 : class IconThemeScannerTest : public CppUnit::TestFixture
      24             : {
      25             :     void
      26             :     AddedThemeIsFoundById();
      27             : 
      28             :     void
      29             :     AddedThemeInfoIsReturned();
      30             : 
      31             :     void
      32             :     ExceptionIsThrownIfInvalidInfoIsRequested();
      33             : 
      34             :     // Adds code needed to register the test suite
      35           2 :     CPPUNIT_TEST_SUITE(IconThemeScannerTest);
      36           1 :     CPPUNIT_TEST(AddedThemeIsFoundById);
      37           1 :     CPPUNIT_TEST(AddedThemeInfoIsReturned);
      38           1 :     CPPUNIT_TEST(ExceptionIsThrownIfInvalidInfoIsRequested);
      39             : 
      40             :     // End of test suite definition
      41           2 :     CPPUNIT_TEST_SUITE_END();
      42             : };
      43             : 
      44             : void
      45           1 : IconThemeScannerTest::AddedThemeIsFoundById()
      46             : {
      47           1 :     vcl::IconThemeScanner scanner;
      48           2 :     OUString theme("file:://images_katze.zip");
      49           1 :     scanner.AddIconThemeByPath(theme);
      50           2 :     OUString id = vcl::IconThemeInfo::FileNameToThemeId("images_katze.zip");
      51           1 :     bool found = false;
      52           1 :     found = scanner.IconThemeIsInstalled(id);
      53           2 :     CPPUNIT_ASSERT_EQUAL_MESSAGE("icon theme could be added by url", true, found);
      54           1 : }
      55             : 
      56             : void
      57           1 : IconThemeScannerTest::AddedThemeInfoIsReturned()
      58             : {
      59           1 :     vcl::IconThemeScanner scanner;
      60           2 :     OUString theme("file:://images_katze.zip");
      61           1 :     scanner.AddIconThemeByPath(theme);
      62           2 :     OUString id = vcl::IconThemeInfo::FileNameToThemeId("images_katze.zip");
      63           1 :     const vcl::IconThemeInfo& info = scanner.GetIconThemeInfo(id);
      64           2 :     CPPUNIT_ASSERT_EQUAL_MESSAGE("'katze' icon theme is found from id", theme, info.GetUrlToFile());
      65           1 : }
      66             : 
      67             : void
      68           1 : IconThemeScannerTest::ExceptionIsThrownIfInvalidInfoIsRequested()
      69             : {
      70           1 :     vcl::IconThemeScanner scanner;
      71           2 :     OUString theme("file:://images_katze.zip");
      72           1 :     scanner.AddIconThemeByPath(theme);
      73           1 :     bool thrown = false;
      74             :     try
      75             :     {
      76           2 :         scanner.GetIconThemeInfo("hund");
      77             :     }
      78           2 :     catch (const std::runtime_error&)
      79             :     {
      80           1 :         thrown = true;
      81             :     }
      82           2 :     CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception is thrown if invalid theme info is requested", true, thrown);
      83           1 : }
      84             : 
      85             : // Put the test suite in the registry
      86           3 : CPPUNIT_TEST_SUITE_REGISTRATION(IconThemeScannerTest);
      87             : 
      88             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10