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
const id("katze");
58 OUString displayName
= vcl::IconThemeInfo::ThemeIdToDisplayName(id
);
59 CPPUNIT_ASSERT_EQUAL_MESSAGE("theme id is properly uppercased", OUString("Katze"), displayName
);
63 IconThemeInfoTest::ImagesZipIsNotValid()
65 bool valid
= vcl::IconThemeInfo::UrlCanBeParsed("file://images.zip");
66 CPPUNIT_ASSERT_EQUAL_MESSAGE("images.zip is not a valid theme name", false, valid
);
70 IconThemeInfoTest::ImagesColibreZipIsValid()
72 OUString
const id("file://images_colibre.zip");
73 bool valid
= vcl::IconThemeInfo::UrlCanBeParsed(id
);
74 CPPUNIT_ASSERT_EQUAL_MESSAGE("images_colibre.zip is a valid theme name", true, valid
);
78 IconThemeInfoTest::ThemeIdIsDetectedFromFileNameWithUnderscore()
80 OUString
const fname("images_colibre.zip");
81 OUString sname
= vcl::IconThemeInfo::FileNameToThemeId(fname
);
82 CPPUNIT_ASSERT_EQUAL_MESSAGE("'colibre' theme id is returned for 'images_colibre.zip'", OUString("colibre"), sname
);
86 IconThemeInfoTest::ExceptionIsThrownWhenIdCannotBeDetermined1()
89 OUString
const fname("images_colibre");
91 vcl::IconThemeInfo::FileNameToThemeId(fname
);
93 catch (std::runtime_error
&) {
96 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception was thrown",true, thrown
);
100 IconThemeInfoTest::ExceptionIsThrownWhenIdCannotBeDetermined2()
103 OUString
const fname("image_colibre.zip");
105 vcl::IconThemeInfo::FileNameToThemeId(fname
);
107 catch (std::runtime_error
&) {
110 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception was thrown", true, thrown
);
113 // Put the test suite in the registry
114 CPPUNIT_TEST_SUITE_REGISTRATION(IconThemeInfoTest
);
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */