fix test for different Ubuntu versions
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <catch2/catch_all.hpp>
|
#include <catch2/catch_all.hpp>
|
||||||
#include "Host/SystemFontResolver.hpp"
|
#include "Host/SystemFontResolver.hpp"
|
||||||
|
#include "Host/SystemInfo.hpp"
|
||||||
#include "Base/Logger.hpp"
|
#include "Base/Logger.hpp"
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
@@ -15,18 +16,31 @@ TEST_CASE("Search system fonts")
|
|||||||
{
|
{
|
||||||
Logger::SetupLogger("", "tests.log");
|
Logger::SetupLogger("", "tests.log");
|
||||||
|
|
||||||
|
OsVersion version = SystemInfo::GetOsVersion();
|
||||||
|
std::array<std::string, 2> fontFiles = { "/usr/share/fonts/truetype/ubuntu/", "/usr/share/fonts/truetype/ubuntu/" };
|
||||||
|
if (version.major <= 22)
|
||||||
|
{
|
||||||
|
fontFiles[0] += "Ubuntu-R.ttf";
|
||||||
|
fontFiles[1] += "UbuntuMono-BI.ttf";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fontFiles[0] += "Ubuntu[wdth,wght].ttf";
|
||||||
|
fontFiles[1] += "UbuntuMono-Italic[wght].ttf";
|
||||||
|
}
|
||||||
|
|
||||||
// assume these fonts are present since they are default
|
// assume these fonts are present since they are default
|
||||||
std::string path = SystemFontResolver::GetSystemFontPath("Ubuntu Regular");
|
std::string path = SystemFontResolver::GetSystemFontPath("Ubuntu Regular");
|
||||||
REQUIRE(path == "/usr/share/fonts/truetype/ubuntu/Ubuntu-R.ttf");
|
REQUIRE(path == fontFiles[0]);
|
||||||
|
|
||||||
path = SystemFontResolver::GetSystemFontPath("ubuntu regular");
|
path = SystemFontResolver::GetSystemFontPath("ubuntu regular");
|
||||||
REQUIRE(path == "/usr/share/fonts/truetype/ubuntu/Ubuntu-R.ttf");
|
REQUIRE(path == fontFiles[0]);
|
||||||
|
|
||||||
path = SystemFontResolver::GetSystemFontPath("Ubuntu Mono Bold Italic");
|
path = SystemFontResolver::GetSystemFontPath("Ubuntu Mono Bold Italic");
|
||||||
REQUIRE(path == "/usr/share/fonts/truetype/ubuntu/UbuntuMono-BI.ttf");
|
REQUIRE(path == fontFiles[1]);
|
||||||
|
|
||||||
path = SystemFontResolver::GetSystemFontPath("ubuntu mono bold italic");
|
path = SystemFontResolver::GetSystemFontPath("ubuntu mono bold italic");
|
||||||
REQUIRE(path == "/usr/share/fonts/truetype/ubuntu/UbuntuMono-BI.ttf");
|
REQUIRE(path == fontFiles[1]);
|
||||||
|
|
||||||
path = SystemFontResolver::GetSystemFontPath("NON-EXISTING Font");
|
path = SystemFontResolver::GetSystemFontPath("NON-EXISTING Font");
|
||||||
REQUIRE(path.empty());
|
REQUIRE(path.empty());
|
||||||
|
|||||||
Reference in New Issue
Block a user