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 <vcl/IconThemeInfo.hxx>
15 #include <cppunit/TestAssert.h>
16 #include <cppunit/TestFixture.h>
17 #include <cppunit/extensions/HelperMacros.h>
21 class IconThemeInfoTest
: public CppUnit::TestFixture
24 UpperCaseDisplayNameIsReturnedForNonDefaultId();
27 ImagesZipIsNotValid();
30 ImagesColibreZipIsValid();
33 ThemeIdIsDetectedFromFileNameWithUnderscore();
36 ExceptionIsThrownWhenIdCannotBeDetermined1();
39 ExceptionIsThrownWhenIdCannotBeDetermined2();
41 // Adds code needed to register the test suite
42 CPPUNIT_TEST_SUITE(IconThemeInfoTest
);
43 CPPUNIT_TEST(UpperCaseDisplayNameIsReturnedForNonDefaultId
);
44 CPPUNIT_TEST(ThemeIdIsDetectedFromFileNameWithUnderscore
);
45 CPPUNIT_TEST(ImagesZipIsNotValid
);
46 CPPUNIT_TEST(ImagesColibreZipIsValid
);
47 CPPUNIT_TEST(ExceptionIsThrownWhenIdCannotBeDetermined1
);
48 CPPUNIT_TEST(ExceptionIsThrownWhenIdCannotBeDetermined2
);
50 // End of test suite definition
51 CPPUNIT_TEST_SUITE_END();
55 IconThemeInfoTest::UpperCaseDisplayNameIsReturnedForNonDefaultId()
57 OUString displayName
= vcl::IconThemeInfo::ThemeIdToDisplayName("katze");
58 CPPUNIT_ASSERT_EQUAL_MESSAGE("theme id is properly uppercased", OUString("Katze"), displayName
);
62 IconThemeInfoTest::ImagesZipIsNotValid()
64 bool valid
= vcl::IconThemeInfo::UrlCanBeParsed("file://images.zip");
65 CPPUNIT_ASSERT_EQUAL_MESSAGE("images.zip is not a valid theme name", false, valid
);
69 IconThemeInfoTest::ImagesColibreZipIsValid()
71 bool valid
= vcl::IconThemeInfo::UrlCanBeParsed("file://images_colibre.zip");
72 CPPUNIT_ASSERT_EQUAL_MESSAGE("images_colibre.zip is a valid theme name", true, valid
);
76 IconThemeInfoTest::ThemeIdIsDetectedFromFileNameWithUnderscore()
78 OUString sname
= vcl::IconThemeInfo::FileNameToThemeId("images_colibre.zip");
79 CPPUNIT_ASSERT_EQUAL_MESSAGE("'colibre' theme id is returned for 'images_colibre.zip'", OUString("colibre"), sname
);
83 IconThemeInfoTest::ExceptionIsThrownWhenIdCannotBeDetermined1()
87 vcl::IconThemeInfo::FileNameToThemeId("images_colibre");
89 catch (std::runtime_error
&) {
92 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception was thrown",true, thrown
);
96 IconThemeInfoTest::ExceptionIsThrownWhenIdCannotBeDetermined2()
100 vcl::IconThemeInfo::FileNameToThemeId("image_colibre.zip");
102 catch (std::runtime_error
&) {
105 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception was thrown", true, thrown
);
108 // Put the test suite in the registry
109 CPPUNIT_TEST_SUITE_REGISTRATION(IconThemeInfoTest
);
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */