calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / vcl / qa / cppunit / physicalfontcollection.cxx
blobc3cde102ed26761af678b9f38137160a063c2a3b
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 <sal/config.h>
12 #include <test/bootstrapfixture.hxx>
13 #include <cppunit/TestAssert.h>
15 #include <font/PhysicalFontCollection.hxx>
16 #include <font/PhysicalFontFamily.hxx>
18 #include "fontmocks.hxx"
20 #include <memory>
22 constexpr int FONTID = 1;
24 class VclPhysicalFontCollectionTest : public test::BootstrapFixture
26 public:
27 VclPhysicalFontCollectionTest()
28 : BootstrapFixture(true, false)
32 void testShouldCreateAndAddFontFamilyToCollection();
33 void testShouldFindFontFamily();
34 void testShouldNotFindFontFamily();
35 void testShouldFindFontFamilyByTokenNames();
36 void testShouldFindNoFamilyWithWorthlessAttributes();
37 void testShouldFindCJKFamily();
38 void testShouldNotFindCJKFamily();
39 void testShouldFindStarsymbolFamily();
40 void testShouldFindOpensymbolFamilyWithMultipleSymbolFamilies();
41 void testShouldFindSymboltypeFamily();
42 void testShouldFindSymbolFamilyByMatchType();
43 void testImpossibleSymbolFamily();
44 void testShouldNotFindSymbolFamily();
45 void testShouldMatchFamilyName();
46 void testShouldMatchBrushScriptFamily();
47 void testShouldNotMatchBrushScriptFamily();
48 void testShouldMatchFixedFamily();
49 void testShouldNotMatchFixedFamily();
50 void testShouldMatchSerifFamily();
51 void testShouldNotMatchSerifFamily();
52 void testShouldMatchSansSerifFamily();
53 void testShouldNotMatchSansSerifFamily();
54 void testShouldMatchDecorativeFamily();
55 void testShouldFindTitlingFamily();
56 void testShouldFindCapitalsFamily();
57 void testShouldFindFamilyName();
58 void testShouldFindOtherStyleFamily();
59 void testShouldNotFindOtherStyleFamily();
60 void testShouldFindSchoolbookFamily();
62 CPPUNIT_TEST_SUITE(VclPhysicalFontCollectionTest);
63 CPPUNIT_TEST(testShouldCreateAndAddFontFamilyToCollection);
64 CPPUNIT_TEST(testShouldFindFontFamily);
65 CPPUNIT_TEST(testShouldNotFindFontFamily);
66 CPPUNIT_TEST(testShouldFindFontFamilyByTokenNames);
67 CPPUNIT_TEST(testShouldFindNoFamilyWithWorthlessAttributes);
68 CPPUNIT_TEST(testShouldFindCJKFamily);
69 CPPUNIT_TEST(testShouldNotFindCJKFamily);
70 CPPUNIT_TEST(testShouldFindStarsymbolFamily);
71 CPPUNIT_TEST(testShouldFindOpensymbolFamilyWithMultipleSymbolFamilies);
72 CPPUNIT_TEST(testShouldFindSymboltypeFamily);
73 CPPUNIT_TEST(testShouldFindSymbolFamilyByMatchType);
74 CPPUNIT_TEST(testImpossibleSymbolFamily);
75 CPPUNIT_TEST(testShouldNotFindSymbolFamily);
76 CPPUNIT_TEST(testShouldMatchFamilyName);
77 CPPUNIT_TEST(testShouldMatchBrushScriptFamily);
78 CPPUNIT_TEST(testShouldNotMatchBrushScriptFamily);
79 CPPUNIT_TEST(testShouldMatchFixedFamily);
80 CPPUNIT_TEST(testShouldNotMatchFixedFamily);
81 CPPUNIT_TEST(testShouldMatchSerifFamily);
82 CPPUNIT_TEST(testShouldNotMatchSerifFamily);
83 CPPUNIT_TEST(testShouldMatchSansSerifFamily);
84 CPPUNIT_TEST(testShouldNotMatchSansSerifFamily);
85 CPPUNIT_TEST(testShouldMatchDecorativeFamily);
86 CPPUNIT_TEST(testShouldFindTitlingFamily);
87 CPPUNIT_TEST(testShouldFindCapitalsFamily);
88 CPPUNIT_TEST(testShouldFindFamilyName);
89 CPPUNIT_TEST(testShouldFindOtherStyleFamily);
90 CPPUNIT_TEST(testShouldNotFindOtherStyleFamily);
91 CPPUNIT_TEST(testShouldFindSchoolbookFamily);
92 CPPUNIT_TEST_SUITE_END();
95 void VclPhysicalFontCollectionTest::testShouldCreateAndAddFontFamilyToCollection()
97 vcl::font::PhysicalFontCollection aFontCollection;
98 CPPUNIT_ASSERT_EQUAL_MESSAGE("Empty font collection", static_cast<int>(0),
99 aFontCollection.Count());
101 // please note that fonts created this way are NOT normalized and will not be found if you search for them in the collection
102 vcl::font::PhysicalFontFamily* pFontFamily
103 = aFontCollection.FindOrCreateFontFamily("Test Font Family Name");
104 CPPUNIT_ASSERT_EQUAL_MESSAGE("Does not have only one font family in collection",
105 static_cast<int>(1), aFontCollection.Count());
106 CPPUNIT_ASSERT_EQUAL_MESSAGE("Font family name not correct", OUString("Test Font Family Name"),
107 pFontFamily->GetSearchName());
109 vcl::font::PhysicalFontFamily* pFontFamily2
110 = aFontCollection.FindOrCreateFontFamily("Test Font Family Name");
111 CPPUNIT_ASSERT_EQUAL_MESSAGE("Still only one font family in collection", static_cast<int>(1),
112 aFontCollection.Count());
113 CPPUNIT_ASSERT_EQUAL_MESSAGE("Font family name not correct", OUString("Test Font Family Name"),
114 pFontFamily2->GetSearchName());
117 void VclPhysicalFontCollectionTest::testShouldFindFontFamily()
119 // note: you must normalize the search family name (first parameter of PhysicalFontFamily constructor)
120 vcl::font::PhysicalFontCollection aFontCollection;
121 aFontCollection.FindOrCreateFontFamily(GetEnglishSearchFontName(u"Test Font Family Name"));
123 vcl::font::PhysicalFontFamily* pFontFamily
124 = aFontCollection.FindFontFamily(u"Test Font Family Name");
125 CPPUNIT_ASSERT_EQUAL_MESSAGE("Font family name not correct",
126 GetEnglishSearchFontName(u"Test Font Family Name"),
127 pFontFamily->GetSearchName());
130 void VclPhysicalFontCollectionTest::testShouldNotFindFontFamily()
132 // note: you must normalize the search family name (first parameter of PhysicalFontFamily constructor)
133 vcl::font::PhysicalFontCollection aFontCollection;
134 aFontCollection.FindOrCreateFontFamily(GetEnglishSearchFontName(u"Test Font Family Name"));
136 CPPUNIT_ASSERT(!aFontCollection.FindFontFamily(u"blah"));
139 void VclPhysicalFontCollectionTest::testShouldFindFontFamilyByTokenNames()
141 // note: you must normalize the search family name (first parameter of PhysicalFontFamily constructor)
142 vcl::font::PhysicalFontCollection aFontCollection;
143 aFontCollection.FindOrCreateFontFamily(GetEnglishSearchFontName(u"Test Font Family Name"));
145 OUString sTokenNames(GetEnglishSearchFontName(u"Test Font Family Name;"));
146 sTokenNames += GetEnglishSearchFontName(u"Test 2");
148 vcl::font::PhysicalFontFamily* pFontFamily
149 = aFontCollection.FindFontFamilyByTokenNames(u"Test Font Family Name");
150 CPPUNIT_ASSERT_MESSAGE("Did not find the font family", pFontFamily);
151 CPPUNIT_ASSERT_EQUAL_MESSAGE("Font family name incorrect",
152 GetEnglishSearchFontName(u"Test Font Family Name"),
153 pFontFamily->GetSearchName());
156 static void AddNormalFontFace(vcl::font::PhysicalFontFamily* const pFontFamily,
157 OUString const& rFamilyName)
159 FontAttributes aFontAttr;
160 aFontAttr.SetFamilyName(rFamilyName);
161 aFontAttr.SetWeight(WEIGHT_NORMAL);
162 pFontFamily->AddFontFace(new TestFontFace(aFontAttr, FONTID));
165 void VclPhysicalFontCollectionTest::testShouldFindNoFamilyWithWorthlessAttributes()
167 // note: you must normalize the search family name (first parameter of PhysicalFontFamily constructor)
168 vcl::font::PhysicalFontCollection aFontCollection;
169 aFontCollection.FindOrCreateFontFamily(GetEnglishSearchFontName(u"Test Font Family Name"));
171 CPPUNIT_ASSERT(!aFontCollection.FindFontFamilyByAttributes(ImplFontAttrs::None, WEIGHT_NORMAL,
172 WIDTH_NORMAL, ITALIC_NONE, u""));
175 void VclPhysicalFontCollectionTest::testShouldFindCJKFamily()
177 vcl::font::PhysicalFontCollection aFontCollection;
179 // interestingly, you need to normalize the name still
180 vcl::font::PhysicalFontFamily* pFontFamily = aFontCollection.FindOrCreateFontFamily(
181 GetEnglishSearchFontName(u"시험")); // Korean for "test"
182 AddNormalFontFace(pFontFamily, u"시험");
184 vcl::font::PhysicalFontFamily* pCJKFamily = aFontCollection.FindFontFamilyByAttributes(
185 ImplFontAttrs::CJK, WEIGHT_NORMAL, WIDTH_NORMAL, ITALIC_NORMAL, u"");
186 CPPUNIT_ASSERT_MESSAGE("family not found", pCJKFamily);
187 CPPUNIT_ASSERT_EQUAL_MESSAGE("cjk family not found", GetEnglishSearchFontName(u"시험"),
188 pCJKFamily->GetSearchName());
191 void VclPhysicalFontCollectionTest::testShouldNotFindCJKFamily()
193 vcl::font::PhysicalFontCollection aFontCollection;
194 vcl::font::PhysicalFontFamily* pFontFamily
195 = aFontCollection.FindOrCreateFontFamily(GetEnglishSearchFontName(u"No CJK characters"));
196 AddNormalFontFace(pFontFamily, "No CJK characters");
198 CPPUNIT_ASSERT_MESSAGE("family found",
199 !aFontCollection.FindFontFamilyByAttributes(
200 ImplFontAttrs::CJK, WEIGHT_NORMAL, WIDTH_NORMAL, ITALIC_NONE, u""));
203 void VclPhysicalFontCollectionTest::testShouldFindStarsymbolFamily()
205 vcl::font::PhysicalFontCollection aFontCollection;
206 vcl::font::PhysicalFontFamily* pFontFamily
207 = aFontCollection.FindOrCreateFontFamily("starsymbol");
208 AddNormalFontFace(pFontFamily, "starsymbol");
210 CPPUNIT_ASSERT_MESSAGE("starsymbol created", pFontFamily);
212 vcl::font::PhysicalFontFamily* pStarsymbolFamily = aFontCollection.FindFontFamilyByAttributes(
213 ImplFontAttrs::Symbol, WEIGHT_NORMAL, WIDTH_NORMAL, ITALIC_NORMAL, u"");
214 CPPUNIT_ASSERT_MESSAGE("family not found", pStarsymbolFamily);
215 CPPUNIT_ASSERT_EQUAL_MESSAGE("starsymbol family not found", OUString("starsymbol"),
216 pStarsymbolFamily->GetSearchName());
219 void VclPhysicalFontCollectionTest::testShouldFindOpensymbolFamilyWithMultipleSymbolFamilies()
221 vcl::font::PhysicalFontCollection aFontCollection;
223 vcl::font::PhysicalFontFamily* pOpenSymbolFamily
224 = aFontCollection.FindOrCreateFontFamily("opensymbol");
225 AddNormalFontFace(pOpenSymbolFamily, "opensymbol");
227 vcl::font::PhysicalFontFamily* pWingDingsFontFamily
228 = aFontCollection.FindOrCreateFontFamily("wingdings");
229 AddNormalFontFace(pWingDingsFontFamily, "wingdings");
231 vcl::font::PhysicalFontFamily* pStarsymbolFamily = aFontCollection.FindFontFamilyByAttributes(
232 ImplFontAttrs::Symbol, WEIGHT_NORMAL, WIDTH_NORMAL, ITALIC_NORMAL, u"");
233 CPPUNIT_ASSERT_MESSAGE("family not found", pStarsymbolFamily);
234 CPPUNIT_ASSERT_EQUAL_MESSAGE("opensymbol family not found", OUString("opensymbol"),
235 pStarsymbolFamily->GetSearchName());
238 void VclPhysicalFontCollectionTest::testShouldFindSymboltypeFamily()
240 vcl::font::PhysicalFontCollection aFontCollection;
241 vcl::font::PhysicalFontFamily* pFontFamily
242 = aFontCollection.FindOrCreateFontFamily("testsymbol");
244 AddNormalFontFace(pFontFamily, "testsymbol");
246 vcl::font::PhysicalFontFamily* pSymbolFamily = aFontCollection.FindFontFamilyByAttributes(
247 ImplFontAttrs::Symbol, WEIGHT_NORMAL, WIDTH_NORMAL, ITALIC_NORMAL, u"");
248 CPPUNIT_ASSERT_MESSAGE("family not found", pSymbolFamily);
249 CPPUNIT_ASSERT_EQUAL_MESSAGE("test symbol family not found", OUString("testsymbol"),
250 pSymbolFamily->GetSearchName());
253 void VclPhysicalFontCollectionTest::testShouldFindSymbolFamilyByMatchType()
255 // TODO: figure out how to test matchtype with ImplFontAttrs::Full
257 vcl::font::PhysicalFontCollection aFontCollection;
258 vcl::font::PhysicalFontFamily* pFontFamily = aFontCollection.FindOrCreateFontFamily("symbols");
260 FontAttributes aFontAttr;
261 aFontAttr.SetFamilyName("symbols");
262 aFontAttr.SetMicrosoftSymbolEncoded(true);
263 aFontAttr.SetWeight(WEIGHT_NORMAL);
264 pFontFamily->AddFontFace(new TestFontFace(aFontAttr, FONTID));
266 vcl::font::PhysicalFontFamily* pSymbolFamily = aFontCollection.FindFontFamilyByAttributes(
267 ImplFontAttrs::Symbol, WEIGHT_NORMAL, WIDTH_NORMAL, ITALIC_NORMAL, u"");
268 CPPUNIT_ASSERT_MESSAGE("family not found", pSymbolFamily);
269 CPPUNIT_ASSERT_EQUAL_MESSAGE("test symbol family not found", OUString("symbols"),
270 pSymbolFamily->GetSearchName());
273 void VclPhysicalFontCollectionTest::testImpossibleSymbolFamily()
275 vcl::font::PhysicalFontCollection aFontCollection;
276 vcl::font::PhysicalFontFamily* pFontFamily
277 = aFontCollection.FindOrCreateFontFamily("testsymbolfamily");
279 FontAttributes aFontAttr;
280 aFontAttr.SetFamilyName("testsymbolfamily");
281 aFontAttr.SetMicrosoftSymbolEncoded(true);
282 aFontAttr.SetWeight(WEIGHT_NORMAL);
283 TestFontFace* pFontFace = new TestFontFace(aFontAttr, FONTID);
284 pFontFamily->AddFontFace(pFontFace);
286 CPPUNIT_ASSERT_MESSAGE("match for family not possible, but was found anyway",
287 !aFontCollection.FindFontFamilyByAttributes(ImplFontAttrs::Normal,
288 WEIGHT_NORMAL, WIDTH_NORMAL,
289 ITALIC_NORMAL, u""));
292 void VclPhysicalFontCollectionTest::testShouldNotFindSymbolFamily()
294 vcl::font::PhysicalFontCollection aFontCollection;
295 vcl::font::PhysicalFontFamily* pFontFamily = aFontCollection.FindOrCreateFontFamily("symbol");
296 AddNormalFontFace(pFontFamily, "symbol");
298 CPPUNIT_ASSERT_MESSAGE(
299 "Family found", !aFontCollection.FindFontFamilyByAttributes(
300 ImplFontAttrs::Normal, WEIGHT_NORMAL, WIDTH_NORMAL, ITALIC_NONE, u""));
303 void VclPhysicalFontCollectionTest::testShouldMatchFamilyName()
305 vcl::font::PhysicalFontCollection aFontCollection;
307 // note that for this test, it is irrelevant what the search name is for PhysicalFontFamily,
308 // the font searches the family name and uses the search parameter of FindFontFamilyByAttributes()
309 vcl::font::PhysicalFontFamily* pFontFamily
310 = aFontCollection.FindOrCreateFontFamily(u"Matching family name");
311 AddNormalFontFace(pFontFamily, GetEnglishSearchFontName(u"Matching family name"));
313 CPPUNIT_ASSERT_MESSAGE("No family found",
314 aFontCollection.FindFontFamilyByAttributes(
315 ImplFontAttrs::Normal, WEIGHT_NORMAL, WIDTH_NORMAL, ITALIC_NONE,
316 u"Matching family name"));
319 void VclPhysicalFontCollectionTest::testShouldMatchBrushScriptFamily()
321 vcl::font::PhysicalFontCollection aFontCollection;
322 vcl::font::PhysicalFontFamily* pFontFamily = aFontCollection.FindOrCreateFontFamily("script");
323 AddNormalFontFace(pFontFamily, "script");
325 CPPUNIT_ASSERT_MESSAGE("Brush script family not found",
326 aFontCollection.FindFontFamilyByAttributes(ImplFontAttrs::BrushScript,
327 WEIGHT_NORMAL, WIDTH_NORMAL,
328 ITALIC_NONE, u""));
331 void VclPhysicalFontCollectionTest::testShouldNotMatchBrushScriptFamily()
333 vcl::font::PhysicalFontCollection aFontCollection;
334 vcl::font::PhysicalFontFamily* pFontFamily
335 = aFontCollection.FindOrCreateFontFamily("testfamily");
336 AddNormalFontFace(pFontFamily, "testfamily");
338 CPPUNIT_ASSERT_MESSAGE("Brush script family found",
339 !aFontCollection.FindFontFamilyByAttributes(ImplFontAttrs::BrushScript,
340 WEIGHT_NORMAL, WIDTH_NORMAL,
341 ITALIC_NONE, u""));
344 void VclPhysicalFontCollectionTest::testShouldMatchFixedFamily()
346 vcl::font::PhysicalFontCollection aFontCollection;
348 // note that for this test, it is irrelevant what the search name is for PhysicalFontFamily,
349 // the font searches the family name and uses the search parameter of FindFontFamilyByAttributes()
350 vcl::font::PhysicalFontFamily* pFontFamily
351 = aFontCollection.FindOrCreateFontFamily(GetEnglishSearchFontName(u"Matching family name"));
353 FontAttributes aFontAttr;
354 aFontAttr.SetFamilyName(GetEnglishSearchFontName(u"Matching family name"));
355 aFontAttr.SetFamilyType(FAMILY_MODERN);
356 aFontAttr.SetWeight(WEIGHT_NORMAL);
357 TestFontFace* pFontFace = new TestFontFace(aFontAttr, FONTID);
358 pFontFamily->AddFontFace(pFontFace);
360 CPPUNIT_ASSERT_MESSAGE("No fixed family found",
361 aFontCollection.FindFontFamilyByAttributes(
362 ImplFontAttrs::Fixed, WEIGHT_NORMAL, WIDTH_NORMAL, ITALIC_NONE,
363 GetEnglishSearchFontName(u"Matching family name")));
366 void VclPhysicalFontCollectionTest::testShouldNotMatchFixedFamily()
368 vcl::font::PhysicalFontCollection aFontCollection;
370 // note that for this test, it is irrelevant what the search name is for PhysicalFontFamily,
371 // the font searches the family name and uses the search parameter of FindFontFamilyByAttributes()
372 vcl::font::PhysicalFontFamily* pFontFamily
373 = aFontCollection.FindOrCreateFontFamily(GetEnglishSearchFontName(u"Matching family name"));
375 FontAttributes aFontAttr;
376 aFontAttr.SetFamilyName(GetEnglishSearchFontName(u"Matching family name"));
377 aFontAttr.SetFamilyType(FAMILY_SWISS);
378 aFontAttr.SetWeight(WEIGHT_NORMAL);
379 TestFontFace* pFontFace = new TestFontFace(aFontAttr, FONTID);
380 pFontFamily->AddFontFace(pFontFace);
382 CPPUNIT_ASSERT_MESSAGE("Fixed family found",
383 aFontCollection.FindFontFamilyByAttributes(
384 ImplFontAttrs::Fixed, WEIGHT_NORMAL, WIDTH_NORMAL, ITALIC_NONE,
385 GetEnglishSearchFontName(u"Matching family name")));
388 void VclPhysicalFontCollectionTest::testShouldMatchSerifFamily()
390 vcl::font::PhysicalFontCollection aFontCollection;
391 vcl::font::PhysicalFontFamily* pFontFamily = aFontCollection.FindOrCreateFontFamily("serif");
393 FontAttributes aFontAttr;
394 aFontAttr.SetFamilyName("serif");
395 aFontAttr.SetFamilyType(FAMILY_ROMAN);
396 aFontAttr.SetWeight(WEIGHT_NORMAL);
397 TestFontFace* pFontFace = new TestFontFace(aFontAttr, FONTID);
398 pFontFamily->AddFontFace(pFontFace);
400 CPPUNIT_ASSERT_MESSAGE("Serif family not found", aFontCollection.FindFontFamilyByAttributes(
401 ImplFontAttrs::Serif, WEIGHT_NORMAL,
402 WIDTH_NORMAL, ITALIC_NONE, u""));
405 void VclPhysicalFontCollectionTest::testShouldNotMatchSerifFamily()
407 vcl::font::PhysicalFontCollection aFontCollection;
408 vcl::font::PhysicalFontFamily* pFontFamily
409 = aFontCollection.FindOrCreateFontFamily("sansseriftest");
411 FontAttributes aFontAttr;
412 aFontAttr.SetFamilyName("sansseriftest");
413 aFontAttr.SetFamilyType(FAMILY_SWISS);
414 aFontAttr.SetWeight(WEIGHT_NORMAL);
415 TestFontFace* pFontFace = new TestFontFace(aFontAttr, FONTID);
416 pFontFamily->AddFontFace(pFontFace);
418 CPPUNIT_ASSERT_MESSAGE("Serif family found", !aFontCollection.FindFontFamilyByAttributes(
419 ImplFontAttrs::Serif, WEIGHT_NORMAL,
420 WIDTH_NORMAL, ITALIC_NONE, u""));
423 void VclPhysicalFontCollectionTest::testShouldMatchSansSerifFamily()
425 vcl::font::PhysicalFontCollection aFontCollection;
426 vcl::font::PhysicalFontFamily* pFontFamily
427 = aFontCollection.FindOrCreateFontFamily("sansserif");
429 FontAttributes aFontAttr;
430 aFontAttr.SetFamilyName("sansserif");
431 aFontAttr.SetFamilyType(FAMILY_SWISS);
432 aFontAttr.SetWeight(WEIGHT_NORMAL);
433 TestFontFace* pFontFace = new TestFontFace(aFontAttr, FONTID);
434 pFontFamily->AddFontFace(pFontFace);
436 CPPUNIT_ASSERT_MESSAGE("SansSerif family not found",
437 aFontCollection.FindFontFamilyByAttributes(ImplFontAttrs::SansSerif,
438 WEIGHT_NORMAL, WIDTH_NORMAL,
439 ITALIC_NONE, u""));
442 void VclPhysicalFontCollectionTest::testShouldNotMatchSansSerifFamily()
444 vcl::font::PhysicalFontCollection aFontCollection;
445 vcl::font::PhysicalFontFamily* pFontFamily = aFontCollection.FindOrCreateFontFamily("serif");
447 FontAttributes aFontAttr;
448 aFontAttr.SetFamilyName("serif");
449 aFontAttr.SetFamilyType(FAMILY_ROMAN);
450 aFontAttr.SetWeight(WEIGHT_NORMAL);
451 TestFontFace* pFontFace = new TestFontFace(aFontAttr, FONTID);
452 pFontFamily->AddFontFace(pFontFace);
454 CPPUNIT_ASSERT_MESSAGE("SansSerif family found", !aFontCollection.FindFontFamilyByAttributes(
455 ImplFontAttrs::SansSerif, WEIGHT_NORMAL,
456 WIDTH_NORMAL, ITALIC_NONE, u""));
459 void VclPhysicalFontCollectionTest::testShouldMatchDecorativeFamily()
461 vcl::font::PhysicalFontCollection aFontCollection;
462 vcl::font::PhysicalFontFamily* pFontFamily
463 = aFontCollection.FindOrCreateFontFamily("decorative");
465 FontAttributes aFontAttr;
466 aFontAttr.SetFamilyName("decorative");
467 aFontAttr.SetFamilyType(FAMILY_DECORATIVE);
468 aFontAttr.SetWeight(WEIGHT_MEDIUM);
469 TestFontFace* pFontFace = new TestFontFace(aFontAttr, FONTID);
470 pFontFamily->AddFontFace(pFontFace);
472 CPPUNIT_ASSERT_MESSAGE("Decorative family not found",
473 aFontCollection.FindFontFamilyByAttributes(ImplFontAttrs::Decorative,
474 WEIGHT_NORMAL, WIDTH_NORMAL,
475 ITALIC_NORMAL, u""));
478 void VclPhysicalFontCollectionTest::testShouldFindTitlingFamily()
480 vcl::font::PhysicalFontCollection aFontCollection;
481 vcl::font::PhysicalFontFamily* pFontFamily
482 = aFontCollection.FindOrCreateFontFamily("testtitling");
483 AddNormalFontFace(pFontFamily, "testtitling");
485 CPPUNIT_ASSERT_MESSAGE("Titling family not found", aFontCollection.FindFontFamilyByAttributes(
486 ImplFontAttrs::Titling, WEIGHT_NORMAL,
487 WIDTH_NORMAL, ITALIC_NORMAL, u""));
490 void VclPhysicalFontCollectionTest::testShouldFindCapitalsFamily()
492 vcl::font::PhysicalFontCollection aFontCollection;
493 vcl::font::PhysicalFontFamily* pFontFamily = aFontCollection.FindOrCreateFontFamily("testcaps");
494 AddNormalFontFace(pFontFamily, "testcaps");
496 CPPUNIT_ASSERT_MESSAGE("All-caps family not found", aFontCollection.FindFontFamilyByAttributes(
497 ImplFontAttrs::Capitals, WEIGHT_NORMAL,
498 WIDTH_NORMAL, ITALIC_NORMAL, u""));
501 void VclPhysicalFontCollectionTest::testShouldFindFamilyName()
503 vcl::font::PhysicalFontCollection aFontCollection;
504 vcl::font::PhysicalFontFamily* pFontFamily
505 = aFontCollection.FindOrCreateFontFamily(GetEnglishSearchFontName(u"Test font name"));
506 AddNormalFontFace(pFontFamily, GetEnglishSearchFontName(u"Test font name"));
508 CPPUNIT_ASSERT_MESSAGE("Cannot find font name",
509 aFontCollection.FindFontFamilyByAttributes(
510 ImplFontAttrs::Capitals, WEIGHT_NORMAL, WIDTH_NORMAL, ITALIC_NORMAL,
511 GetEnglishSearchFontName(u"Test font name")));
514 void VclPhysicalFontCollectionTest::testShouldFindOtherStyleFamily()
516 vcl::font::PhysicalFontCollection aFontCollection;
517 vcl::font::PhysicalFontFamily* pFontFamily
518 = aFontCollection.FindOrCreateFontFamily("testoldstyle");
519 AddNormalFontFace(pFontFamily, "testoldstyle");
521 CPPUNIT_ASSERT_MESSAGE("Did not find font name", aFontCollection.FindFontFamilyByAttributes(
522 ImplFontAttrs::OtherStyle, WEIGHT_NORMAL,
523 WIDTH_NORMAL, ITALIC_NORMAL, u""));
526 void VclPhysicalFontCollectionTest::testShouldNotFindOtherStyleFamily()
528 vcl::font::PhysicalFontCollection aFontCollection;
529 vcl::font::PhysicalFontFamily* pFontFamily = aFontCollection.FindOrCreateFontFamily("monotype");
530 AddNormalFontFace(pFontFamily, "monotype");
532 CPPUNIT_ASSERT_MESSAGE("Found font name", !aFontCollection.FindFontFamilyByAttributes(
533 ImplFontAttrs::OtherStyle, WEIGHT_NORMAL,
534 WIDTH_NORMAL, ITALIC_NORMAL, u""));
537 void VclPhysicalFontCollectionTest::testShouldFindSchoolbookFamily()
539 vcl::font::PhysicalFontCollection aFontCollection;
540 vcl::font::PhysicalFontFamily* pFontFamily
541 = aFontCollection.FindOrCreateFontFamily("testschoolbook");
542 AddNormalFontFace(pFontFamily, "testschoolbook");
544 CPPUNIT_ASSERT_MESSAGE("Did not find font name", aFontCollection.FindFontFamilyByAttributes(
545 ImplFontAttrs::Schoolbook, WEIGHT_NORMAL,
546 WIDTH_NORMAL, ITALIC_NORMAL, u""));
549 CPPUNIT_TEST_SUITE_REGISTRATION(VclPhysicalFontCollectionTest);
551 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */