LCOV - code coverage report
Current view: top level - vcl/qa/cppunit/app - test_IconThemeScanner.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 33 33 100.0 %
Date: 2015-06-13 12:38:46 Functions: 14 14 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           5 :     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 = scanner.IconThemeIsInstalled(id);
      52           2 :     CPPUNIT_ASSERT_EQUAL_MESSAGE("icon theme could be added by url", true, found);
      53           1 : }
      54             : 
      55             : void
      56           1 : IconThemeScannerTest::AddedThemeInfoIsReturned()
      57             : {
      58           1 :     vcl::IconThemeScanner scanner;
      59           2 :     OUString theme("file:://images_katze.zip");
      60           1 :     scanner.AddIconThemeByPath(theme);
      61           2 :     OUString id = vcl::IconThemeInfo::FileNameToThemeId("images_katze.zip");
      62           1 :     const vcl::IconThemeInfo& info = scanner.GetIconThemeInfo(id);
      63           2 :     CPPUNIT_ASSERT_EQUAL_MESSAGE("'katze' icon theme is found from id", theme, info.GetUrlToFile());
      64           1 : }
      65             : 
      66             : void
      67           1 : IconThemeScannerTest::ExceptionIsThrownIfInvalidInfoIsRequested()
      68             : {
      69           1 :     vcl::IconThemeScanner scanner;
      70           2 :     OUString theme("file:://images_katze.zip");
      71           1 :     scanner.AddIconThemeByPath(theme);
      72           1 :     bool thrown = false;
      73             :     try
      74             :     {
      75           2 :         scanner.GetIconThemeInfo("hund");
      76             :     }
      77           2 :     catch (const std::runtime_error&)
      78             :     {
      79           1 :         thrown = true;
      80             :     }
      81           2 :     CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception is thrown if invalid theme info is requested", true, thrown);
      82           1 : }
      83             : 
      84             : // Put the test suite in the registry
      85           3 : CPPUNIT_TEST_SUITE_REGISTRATION(IconThemeScannerTest);
      86             : 
      87             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11