nss: upgrade to release 3.73
[LibreOffice.git] / vcl / qa / cppunit / app / test_IconThemeInfo.cxx
bloba68df2f78b9e2e1eb9abc63bac02f2d8b43e4b7b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include <stdexcept>
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>
19 using namespace vcl;
21 class IconThemeInfoTest : public CppUnit::TestFixture
23 void
24 UpperCaseDisplayNameIsReturnedForNonDefaultId();
26 void
27 ImagesZipIsNotValid();
29 void
30 ImagesColibreZipIsValid();
32 void
33 ThemeIdIsDetectedFromFileNameWithUnderscore();
35 void
36 ExceptionIsThrownWhenIdCannotBeDetermined1();
38 void
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();
54 void
55 IconThemeInfoTest::UpperCaseDisplayNameIsReturnedForNonDefaultId()
57 OUString displayName = vcl::IconThemeInfo::ThemeIdToDisplayName("katze");
58 CPPUNIT_ASSERT_EQUAL_MESSAGE("theme id is properly uppercased", OUString("Katze"), displayName);
61 void
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);
68 void
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);
75 void
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);
82 void
83 IconThemeInfoTest::ExceptionIsThrownWhenIdCannotBeDetermined1()
85 bool thrown = false;
86 try {
87 vcl::IconThemeInfo::FileNameToThemeId("images_colibre");
89 catch (std::runtime_error&) {
90 thrown = true;
92 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception was thrown",true, thrown);
95 void
96 IconThemeInfoTest::ExceptionIsThrownWhenIdCannotBeDetermined2()
98 bool thrown = false;
99 try {
100 vcl::IconThemeInfo::FileNameToThemeId("image_colibre.zip");
102 catch (std::runtime_error&) {
103 thrown = true;
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: */