2018-09-25 15:19:30 +08:00
|
|
|
/*
|
2022-04-26 19:31:30 +08:00
|
|
|
* Copyright (C) 2018-2022 Intel Corporation
|
2018-09-25 15:19:30 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/os_interface/os_library.h"
|
|
|
|
#include "shared/source/os_interface/windows/windows_wrapper.h"
|
2022-06-30 03:17:47 +08:00
|
|
|
#include "shared/test/common/test_macros/hw_test.h"
|
2022-04-27 18:28:48 +08:00
|
|
|
|
|
|
|
#include "opencl/source/helpers/windows/gl_helper.h"
|
|
|
|
#include "opencl/test/unit_test/helpers/windows/mock_function.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2018-09-25 15:19:30 +08:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
2019-02-27 18:39:32 +08:00
|
|
|
#include <memory>
|
|
|
|
|
2018-09-25 15:19:30 +08:00
|
|
|
typedef const char *(__cdecl *funcType)();
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2018-09-25 15:19:30 +08:00
|
|
|
class glFunctionHelperMock : public glFunctionHelper {
|
|
|
|
public:
|
|
|
|
glFunctionHelperMock(OsLibrary *glLibrary, const std::string &functionName) : glFunctionHelper(glLibrary, functionName) {}
|
|
|
|
using glFunctionHelper::glFunctionPtr;
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST(glFunctionHelper, whenCreateGlFunctionHelperThenSetGlFunctionPtrToLoadAnotherFunctions) {
|
|
|
|
std::unique_ptr<OsLibrary> glLibrary(OsLibrary::load("mock_opengl32.dll"));
|
|
|
|
EXPECT_TRUE(glLibrary->isLoaded());
|
|
|
|
glFunctionHelperMock loader(glLibrary.get(), "mockLoader");
|
|
|
|
funcType function1 = ConvertibleProcAddr{loader.glFunctionPtr("realFunction")};
|
|
|
|
funcType function2 = loader["realFunction"];
|
|
|
|
EXPECT_STREQ(function1(), function2());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(glFunctionHelper, givenNonExistingFunctionNameWhenCreateGlFunctionHelperThenNullptr) {
|
|
|
|
std::unique_ptr<OsLibrary> glLibrary(OsLibrary::load("mock_opengl32.dll"));
|
|
|
|
EXPECT_TRUE(glLibrary->isLoaded());
|
|
|
|
glFunctionHelper loader(glLibrary.get(), "mockLoader");
|
|
|
|
funcType function = loader["nonExistingFunction"];
|
|
|
|
EXPECT_EQ(nullptr, function);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(glFunctionHelper, givenRealFunctionNameWhenCreateGlFunctionHelperThenGetPointerToAppropriateFunction) {
|
|
|
|
std::unique_ptr<OsLibrary> glLibrary(OsLibrary::load("mock_opengl32.dll"));
|
|
|
|
EXPECT_TRUE(glLibrary->isLoaded());
|
|
|
|
glFunctionHelper loader(glLibrary.get(), "mockLoader");
|
|
|
|
funcType function = loader["realFunction"];
|
|
|
|
EXPECT_STREQ(realFunction(), function());
|
|
|
|
}
|
2019-03-26 18:59:46 +08:00
|
|
|
}; // namespace NEO
|