Files
OpenVulkano/tests/Host/Windows/ResourceLoaderTests.cpp
2024-12-19 16:10:41 +02:00

45 lines
1.6 KiB
C++

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#include <catch2/catch_all.hpp>
#include "Host/Windows/EmbeddedResourceLoaderWindows.hpp"
#include "Base/Logger.hpp"
#include "../resources/resource.h"
#include <Windows.h>
#include <filesystem>
#include <fstream>
using namespace OpenVulkano;
TEST_CASE("Load icon")
{
Logger::SetupLogger("", "tests.log");
EmbeddedResourceLoaderWindows loader;
// the icon is split into RT_GROUP_ICON and RT_ICON. resource.h defines RT_GROUP_ICON entry
// RT_GROUP_ICON data
Array<char> groupData = loader.GetResource(MAKEINTRESOURCE(IDI_MADVOXEL_ICON), RT_GROUP_ICON);
// load resource that has no numeric ID
Array<char> groupData2 = loader.GetResource("MADVOXEL_ICON", RT_GROUP_ICON);
// load resource providing it's full name entry from .rc file without specifying explicit resource type
Array<char> groupData3 = loader.GetResource("MADVOXEL_ICON");
REQUIRE((!groupData.Empty() && !groupData2.Empty() && !groupData3.Empty()));
REQUIRE((groupData.Size() == groupData2.Size() && groupData2.Size() == groupData3.Size()));
// ICON data
Array<char> iconData = loader.GetResource(MAKEINTRESOURCE(1), RT_ICON);
REQUIRE((!iconData.Empty() && iconData.Size() == 194344));
// non-existing resources
Array<char> nonExistingRes = loader.GetResource(1234, RT_FONT);
Array<char> nonExistingRes2 = loader.GetResource("NON_EXISTING_ICON", RT_GROUP_ICON);
REQUIRE((nonExistingRes.Empty() && nonExistingRes2.Empty()));
}