winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

Fonts.cpp (1228B)


      1 // Copyright (c) Microsoft Corporation.
      2 // Licensed under the MIT License.
      3 #include "pch.h"
      4 #include "TestCommon.h"
      5 #include <winget/Fonts.h>
      6 
      7 using namespace AppInstaller::Fonts;
      8 using namespace TestCommon;
      9 
     10 constexpr std::wstring_view s_testFontName = L"Times New Roman";
     11 
     12 TEST_CASE("GetInstalledFonts", "[fonts]")
     13 {
     14     FontCatalog fontCatalog;
     15     std::vector<FontFamily> installedFontFamilies;
     16     REQUIRE_NOTHROW(installedFontFamilies = fontCatalog.GetInstalledFontFamilies());
     17     REQUIRE(installedFontFamilies.size() > 0);
     18 }
     19 
     20 TEST_CASE("GetSingleFontFamily", "[fonts]")
     21 {
     22     FontCatalog fontCatalog;
     23     std::vector<FontFamily> fontFamily;
     24     REQUIRE_NOTHROW(fontFamily = fontCatalog.GetInstalledFontFamilies(std::wstring(s_testFontName)));
     25     REQUIRE_FALSE(fontFamily.empty());
     26     FontFamily singleFontFamily = fontFamily[0];
     27     REQUIRE(AppInstaller::Utility::CaseInsensitiveEquals(singleFontFamily.Name, s_testFontName));
     28     REQUIRE(singleFontFamily.Faces.size() > 0);
     29 }
     30 
     31 TEST_CASE("GetInvalidFontFamily", "[fonts]")
     32 {
     33     FontCatalog fontCatalog;
     34     std::vector<FontFamily> fontFamily;
     35     REQUIRE_NOTHROW(fontFamily = fontCatalog.GetInstalledFontFamilies(L"Invalid Font"));
     36     REQUIRE(fontFamily.empty());
     37 }