NvDecoderImplTest.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "pch.h"
  2. #include "Codec/NvCodec/NvDecoderImpl.h"
  3. #include "GraphicsDevice/IGraphicsDevice.h"
  4. #include "GraphicsDeviceContainer.h"
  5. #include "NvCodecUtils.h"
  6. #include "VideoCodecTest.h"
  7. namespace unity
  8. {
  9. namespace webrtc
  10. {
  11. using namespace webrtc;
  12. using testing::Values;
  13. class NvDecoderImplTest : public testing::TestWithParam<UnityGfxRenderer>
  14. {
  15. public:
  16. NvDecoderImplTest()
  17. : container_(CreateGraphicsDeviceContainer(GetParam()))
  18. , device_(container_->device())
  19. {
  20. }
  21. ~NvDecoderImplTest() override { }
  22. void SetUp() override
  23. {
  24. if (!device_)
  25. GTEST_SKIP() << "The graphics driver is not installed on the device.";
  26. if (!device_->IsCudaSupport())
  27. GTEST_SKIP() << "CUDA is not supported on this device.";
  28. context_ = device_->GetCUcontext();
  29. }
  30. protected:
  31. CUcontext context_;
  32. std::unique_ptr<GraphicsDeviceContainer> container_;
  33. IGraphicsDevice* device_;
  34. };
  35. TEST_P(NvDecoderImplTest, CanInitializeWithDefaultParameters)
  36. {
  37. NvDecoderImpl decoder(context_, nullptr);
  38. VideoCodec codec_settings;
  39. SetDefaultSettings(&codec_settings);
  40. EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder.InitDecode(&codec_settings, 1));
  41. }
  42. INSTANTIATE_TEST_SUITE_P(GfxDevice, NvDecoderImplTest, testing::ValuesIn(supportedGfxDevices));
  43. } // end namespace webrtc
  44. } // end namespace unity