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 <sal/types.h>
14 #include <rtl/ustring.hxx>
15 #include <vcl/IconThemeScanner.hxx>
16 #include <vcl/IconThemeInfo.hxx>
18 #include <cppunit/TestAssert.h>
19 #include <cppunit/TestFixture.h>
20 #include <cppunit/extensions/HelperMacros.h>
21 #include <cppunit/plugin/TestPlugIn.h>
23 class IconThemeScannerTest
: public CppUnit::TestFixture
26 AddedThemeIsFoundById();
29 AddedThemeInfoIsReturned();
32 ExceptionIsThrownIfInvalidInfoIsRequested();
34 // Adds code needed to register the test suite
35 CPPUNIT_TEST_SUITE(IconThemeScannerTest
);
36 CPPUNIT_TEST(AddedThemeIsFoundById
);
37 CPPUNIT_TEST(AddedThemeInfoIsReturned
);
38 CPPUNIT_TEST(ExceptionIsThrownIfInvalidInfoIsRequested
);
40 // End of test suite definition
41 CPPUNIT_TEST_SUITE_END();
45 IconThemeScannerTest::AddedThemeIsFoundById()
47 vcl::IconThemeScanner scanner
;
48 OUString
theme("file:://images_katze.zip");
49 scanner
.AddIconThemeByPath(theme
);
50 OUString id
= vcl::IconThemeInfo::FileNameToThemeId("images_katze.zip");
51 bool found
= scanner
.IconThemeIsInstalled(id
);
52 CPPUNIT_ASSERT_EQUAL_MESSAGE("icon theme could be added by url", true, found
);
56 IconThemeScannerTest::AddedThemeInfoIsReturned()
58 vcl::IconThemeScanner scanner
;
59 OUString
theme("file:://images_katze.zip");
60 scanner
.AddIconThemeByPath(theme
);
61 OUString id
= vcl::IconThemeInfo::FileNameToThemeId("images_katze.zip");
62 const vcl::IconThemeInfo
& info
= scanner
.GetIconThemeInfo(id
);
63 CPPUNIT_ASSERT_EQUAL_MESSAGE("'katze' icon theme is found from id", theme
, info
.GetUrlToFile());
67 IconThemeScannerTest::ExceptionIsThrownIfInvalidInfoIsRequested()
69 vcl::IconThemeScanner scanner
;
70 OUString
theme("file:://images_katze.zip");
71 scanner
.AddIconThemeByPath(theme
);
75 scanner
.GetIconThemeInfo("hund");
77 catch (const std::runtime_error
&)
81 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception is thrown if invalid theme info is requested", true, thrown
);
84 // Put the test suite in the registry
85 CPPUNIT_TEST_SUITE_REGISTRATION(IconThemeScannerTest
);
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */