Skip to content

Commit

Permalink
tests: Add IDXGIVkInteropFactory1 mock
Browse files Browse the repository at this point in the history
Also adjust test environments.
  • Loading branch information
jp7677 committed Aug 23, 2023
1 parent e591010 commit c3a1c48
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
4 changes: 3 additions & 1 deletion tests/nvapi_sysinfo_mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "../src/sysinfo/vulkan.h"
#include "../src/sysinfo/nvml.h"

class IDXGIDxvkFactoryMock : public IDXGIFactory1, public IDXGIVkInteropFactory {};
class IDXGIDxvkFactoryMock : public IDXGIFactory1, public IDXGIVkInteropFactory1 {};

class DXGIDxvkFactoryMock final : public trompeloeil::mock_interface<IDXGIDxvkFactoryMock> {
MAKE_MOCK2(QueryInterface, HRESULT(REFIID, void**), override);
Expand All @@ -23,6 +23,8 @@ class DXGIDxvkFactoryMock final : public trompeloeil::mock_interface<IDXGIDxvkFa
IMPLEMENT_MOCK2(EnumAdapters1);
IMPLEMENT_MOCK0(IsCurrent);
IMPLEMENT_MOCK2(GetVulkanInstance);
IMPLEMENT_MOCK2(GetGlobalHDRState);
IMPLEMENT_MOCK2(SetGlobalHDRState);
};

class IDXGIDxvkAdapter : public IDXGIAdapter1, public IDXGIVkInteropAdapter {};
Expand Down
20 changes: 18 additions & 2 deletions tests/resource_factory_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void ResetGlobals() {
initializationCount = 0ULL;
}

[[nodiscard]] std::array<std::unique_ptr<expectation>, 18> ConfigureDefaultTestEnvironment(
[[nodiscard]] std::array<std::unique_ptr<expectation>, 21> ConfigureDefaultTestEnvironment(
DXGIDxvkFactoryMock& dxgiFactory,
VulkanMock& vulkan,
NvmlMock& nvml,
Expand All @@ -41,6 +41,14 @@ void ResetGlobals() {
NAMED_ALLOW_CALL(dxgiFactory, EnumAdapters1(1U, _))
.RETURN(DXGI_ERROR_NOT_FOUND),

NAMED_ALLOW_CALL(dxgiFactory, QueryInterface(IDXGIVkInteropFactory1::guid, _))
.LR_SIDE_EFFECT(*_2 = static_cast<IDXGIVkInteropFactory1*>(&dxgiFactory))
.RETURN(S_OK),
NAMED_ALLOW_CALL(dxgiFactory, GetGlobalHDRState(_, _))
.RETURN(S_OK),
NAMED_ALLOW_CALL(dxgiFactory, SetGlobalHDRState(_, _))
.RETURN(S_OK),

NAMED_ALLOW_CALL(adapter, QueryInterface(IDXGIVkInteropAdapter::guid, _))
.LR_SIDE_EFFECT(*_2 = static_cast<IDXGIVkInteropAdapter*>(&adapter))
.RETURN(S_OK),
Expand Down Expand Up @@ -83,7 +91,7 @@ void ResetGlobals() {
.RETURN(false)};
}

[[nodiscard]] std::array<std::unique_ptr<expectation>, 33> ConfigureExtendedTestEnvironment(
[[nodiscard]] std::array<std::unique_ptr<expectation>, 36> ConfigureExtendedTestEnvironment(
DXGIDxvkFactoryMock& dxgiFactory,
VulkanMock& vulkan,
NvmlMock& nvml,
Expand All @@ -107,6 +115,14 @@ void ResetGlobals() {
NAMED_ALLOW_CALL(dxgiFactory, EnumAdapters1(2U, _))
.RETURN(DXGI_ERROR_NOT_FOUND),

NAMED_ALLOW_CALL(dxgiFactory, QueryInterface(IDXGIVkInteropFactory1::guid, _))
.LR_SIDE_EFFECT(*_2 = static_cast<IDXGIVkInteropFactory1*>(&dxgiFactory))
.RETURN(S_OK),
NAMED_ALLOW_CALL(dxgiFactory, GetGlobalHDRState(_, _))
.RETURN(S_OK),
NAMED_ALLOW_CALL(dxgiFactory, SetGlobalHDRState(_, _))
.RETURN(S_OK),

NAMED_ALLOW_CALL(adapter1, QueryInterface(IDXGIVkInteropAdapter::guid, _))
.LR_SIDE_EFFECT(*_2 = static_cast<IDXGIVkInteropAdapter*>(&adapter1))
.RETURN(S_OK),
Expand Down
4 changes: 2 additions & 2 deletions tests/resource_factory_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ void SetupResourceFactory(

void ResetGlobals();

[[nodiscard]] std::array<std::unique_ptr<trompeloeil::expectation>, 18> ConfigureDefaultTestEnvironment(
[[nodiscard]] std::array<std::unique_ptr<trompeloeil::expectation>, 21> ConfigureDefaultTestEnvironment(
DXGIDxvkFactoryMock& dxgiFactory,
VulkanMock& vulkan,
NvmlMock& nvml,
LfxMock& lfx,
DXGIDxvkAdapterMock& adapter,
DXGIOutput6Mock& output);

[[nodiscard]] std::array<std::unique_ptr<trompeloeil::expectation>, 33> ConfigureExtendedTestEnvironment(
[[nodiscard]] std::array<std::unique_ptr<trompeloeil::expectation>, 36> ConfigureExtendedTestEnvironment(
DXGIDxvkFactoryMock& dxgiFactory,
VulkanMock& vulkan,
NvmlMock& nvml,
Expand Down

0 comments on commit c3a1c48

Please sign in to comment.
  翻译: