1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
12 #include <rtl/ustring.hxx>
13 #include <IconThemeScanner.hxx>
14 #include <vcl/IconThemeInfo.hxx>
16 #include <cppunit/TestAssert.h>
17 #include <cppunit/TestFixture.h>
18 #include <cppunit/extensions/HelperMacros.h>
20 class IconThemeScannerTest
: public CppUnit::TestFixture
23 AddedThemeIsFoundById();
26 AddedThemeInfoIsReturned();
29 ExceptionIsThrownIfInvalidInfoIsRequested();
31 // Adds code needed to register the test suite
32 CPPUNIT_TEST_SUITE(IconThemeScannerTest
);
33 CPPUNIT_TEST(AddedThemeIsFoundById
);
34 CPPUNIT_TEST(AddedThemeInfoIsReturned
);
35 CPPUNIT_TEST(ExceptionIsThrownIfInvalidInfoIsRequested
);
37 // End of test suite definition
38 CPPUNIT_TEST_SUITE_END();
42 IconThemeScannerTest::AddedThemeIsFoundById()
44 vcl::IconThemeScanner scanner
;
45 scanner
.AddIconThemeByPath("file:://images_katze.zip");
46 OUString id
= vcl::IconThemeInfo::FileNameToThemeId(u
"images_katze.zip");
47 bool found
= scanner
.IconThemeIsInstalled(id
);
48 CPPUNIT_ASSERT_EQUAL_MESSAGE("icon theme could be added by url", true, found
);
52 IconThemeScannerTest::AddedThemeInfoIsReturned()
54 vcl::IconThemeScanner scanner
;
55 OUString
theme("file:://images_katze.zip");
56 scanner
.AddIconThemeByPath(theme
);
57 OUString id
= vcl::IconThemeInfo::FileNameToThemeId(u
"images_katze.zip");
58 const vcl::IconThemeInfo
& info
= scanner
.GetIconThemeInfo(id
);
59 CPPUNIT_ASSERT_EQUAL_MESSAGE("'katze' icon theme is found from id", theme
, info
.GetUrlToFile());
63 IconThemeScannerTest::ExceptionIsThrownIfInvalidInfoIsRequested()
65 vcl::IconThemeScanner scanner
;
66 scanner
.AddIconThemeByPath("file:://images_katze.zip");
70 scanner
.GetIconThemeInfo("hund");
72 catch (const std::runtime_error
&)
76 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception is thrown if invalid theme info is requested", true, thrown
);
79 // Put the test suite in the registry
80 CPPUNIT_TEST_SUITE_REGISTRATION(IconThemeScannerTest
);
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */