[781] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
| 3 | #include <GdiPlus.h>
|
---|
| 4 |
|
---|
| 5 | #define BOOST_TEST_MAIN
|
---|
| 6 |
|
---|
| 7 | #include <boost/test/unit_test.hpp>
|
---|
| 8 |
|
---|
| 9 | #include <Resource/Load.h>
|
---|
| 10 |
|
---|
| 11 | #include <res/resource.h>
|
---|
| 12 |
|
---|
| 13 | namespace fs = boost::filesystem;
|
---|
| 14 |
|
---|
| 15 | namespace abres = ActiveBasic::Resource;
|
---|
| 16 |
|
---|
| 17 | struct HModuleDeleter
|
---|
| 18 | {
|
---|
| 19 | typedef HMODULE pointer;
|
---|
| 20 |
|
---|
| 21 | void operator ()(pointer hmod) const
|
---|
| 22 | {
|
---|
| 23 | ::FreeLibrary(hmod);
|
---|
| 24 | }
|
---|
| 25 | };
|
---|
| 26 |
|
---|
| 27 | typedef std::unique_ptr<HMODULE, HModuleDeleter> UniqueHModule;
|
---|
| 28 |
|
---|
| 29 | bool IconEquals(HICON hiconL, HICON hiconR)
|
---|
| 30 | {
|
---|
| 31 | return false;
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | BOOST_AUTO_TEST_CASE( ResourceLoading )
|
---|
| 35 | {
|
---|
| 36 | TCHAR moduleName[MAX_PATH];
|
---|
| 37 | ::GetModuleFileName(nullptr, moduleName, MAX_PATH);
|
---|
| 38 |
|
---|
| 39 | auto systemDir = fs::path(moduleName).parent_path().parent_path() / "build/release/system";
|
---|
| 40 |
|
---|
| 41 | UniqueHModule hmodRes(::LoadLibraryExW((systemDir / "res.dll").wstring().c_str(), nullptr, LOAD_LIBRARY_AS_DATAFILE));
|
---|
| 42 | BOOST_CHECK(hmodRes != nullptr);
|
---|
| 43 |
|
---|
| 44 | auto hBasicProgramIconTarget = (HICON)LoadImage(hmodRes.get(), MAKEINTRESOURCE(IDI_BASICPROGRAM), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
|
---|
| 45 | auto hBasicProgramIcon = abres::LoadIcon(hmodRes.get(), IDI_BASICPROGRAM, 16, 16, LR_DEFAULTCOLOR);
|
---|
| 46 |
|
---|
| 47 | BOOST_CHECK(hBasicProgramIconTarget != nullptr);
|
---|
| 48 | BOOST_CHECK(hBasicProgramIcon != nullptr);
|
---|
| 49 |
|
---|
| 50 | BOOST_CHECK(IconEquals(hBasicProgramIconTarget, hBasicProgramIcon));
|
---|
| 51 |
|
---|
| 52 | }
|
---|