98 lines
3.7 KiB
C++
98 lines
3.7 KiB
C++
#pragma once
|
|
#include "../src/Rendering/IVideoRenderer.h"
|
|
#include <vector>
|
|
#include <memory>
|
|
|
|
namespace Vav2PlayerUnitTests {
|
|
|
|
// Mock implementation of IVideoRenderer for unit testing
|
|
// Provides controllable rendering behavior without actual D3D12/GPU operations
|
|
class MockVideoRenderer : public Vav2Player::IVideoRenderer {
|
|
public:
|
|
MockVideoRenderer();
|
|
virtual ~MockVideoRenderer() = default;
|
|
|
|
// IVideoRenderer interface implementation
|
|
HRESULT Initialize(uint32_t width, uint32_t height) override;
|
|
void Shutdown() override;
|
|
bool IsInitialized() const override;
|
|
|
|
HRESULT RenderVideoFrame(const Vav2Player::VideoFrame& frame) override;
|
|
bool TryRenderFrame(const Vav2Player::VideoFrame& frame) override;
|
|
HRESULT Present() override;
|
|
|
|
HRESULT Resize(uint32_t width, uint32_t height) override;
|
|
uint32_t GetWidth() const override;
|
|
uint32_t GetHeight() const override;
|
|
|
|
void SetAspectFitMode(bool enabled) override;
|
|
void UpdateContainerSize(uint32_t container_width, uint32_t container_height) override;
|
|
|
|
// Mock-specific control methods for testing
|
|
void SetInitializeResult(HRESULT result);
|
|
void SetRenderFrameResult(HRESULT result);
|
|
void SetTryRenderFrameResult(bool success);
|
|
void SetPresentResult(HRESULT result);
|
|
void SetResizeResult(HRESULT result);
|
|
|
|
void SimulateInitializationFailure(bool fail = true);
|
|
void SimulateRenderingFailure(bool fail = true);
|
|
|
|
// Test verification methods
|
|
uint32_t GetInitializeCallCount() const { return m_initializeCallCount; }
|
|
uint32_t GetRenderFrameCallCount() const { return m_renderFrameCallCount; }
|
|
uint32_t GetTryRenderFrameCallCount() const { return m_tryRenderFrameCallCount; }
|
|
uint32_t GetPresentCallCount() const { return m_presentCallCount; }
|
|
uint32_t GetResizeCallCount() const { return m_resizeCallCount; }
|
|
|
|
uint32_t GetLastInitializeWidth() const { return m_lastInitializeWidth; }
|
|
uint32_t GetLastInitializeHeight() const { return m_lastInitializeHeight; }
|
|
|
|
const std::vector<Vav2Player::VideoFrame>& GetRenderedFrames() const { return m_renderedFrames; }
|
|
uint32_t GetTotalRenderedFrames() const { return static_cast<uint32_t>(m_renderedFrames.size()); }
|
|
|
|
bool GetAspectFitMode() const { return m_aspectFitEnabled; }
|
|
uint32_t GetContainerWidth() const { return m_containerWidth; }
|
|
uint32_t GetContainerHeight() const { return m_containerHeight; }
|
|
|
|
// Performance simulation
|
|
void SetRenderDelay(uint32_t milliseconds) { m_renderDelayMs = milliseconds; }
|
|
uint64_t GetTotalRenderTime() const { return m_totalRenderTimeMs; }
|
|
|
|
private:
|
|
// Mock state
|
|
bool m_initialized = false;
|
|
uint32_t m_width = 0;
|
|
uint32_t m_height = 0;
|
|
bool m_aspectFitEnabled = false;
|
|
uint32_t m_containerWidth = 0;
|
|
uint32_t m_containerHeight = 0;
|
|
|
|
// Mock behavior control
|
|
HRESULT m_initializeResult = S_OK;
|
|
HRESULT m_renderFrameResult = S_OK;
|
|
bool m_tryRenderFrameResult = true;
|
|
HRESULT m_presentResult = S_OK;
|
|
HRESULT m_resizeResult = S_OK;
|
|
uint32_t m_renderDelayMs = 0;
|
|
|
|
// Call tracking for test verification
|
|
mutable uint32_t m_initializeCallCount = 0;
|
|
mutable uint32_t m_renderFrameCallCount = 0;
|
|
mutable uint32_t m_tryRenderFrameCallCount = 0;
|
|
mutable uint32_t m_presentCallCount = 0;
|
|
mutable uint32_t m_resizeCallCount = 0;
|
|
|
|
uint32_t m_lastInitializeWidth = 0;
|
|
uint32_t m_lastInitializeHeight = 0;
|
|
|
|
// Frame storage for test verification
|
|
std::vector<Vav2Player::VideoFrame> m_renderedFrames;
|
|
uint64_t m_totalRenderTimeMs = 0;
|
|
|
|
// Helper methods
|
|
void CopyFrame(const Vav2Player::VideoFrame& source, Vav2Player::VideoFrame& dest);
|
|
void SimulateRenderDelay();
|
|
};
|
|
|
|
} // namespace Vav2PlayerUnitTests
|