Adding a GpuTestWithParamBase test class to support value parameterized tests

PiperOrigin-RevId: 583967017
This commit is contained in:
MediaPipe Team 2023-11-20 03:00:09 -08:00 committed by Copybara-Service
parent bd4be30b02
commit 5cd3037443

View File

@ -15,6 +15,9 @@
#ifndef MEDIAPIPE_GPU_GPU_TEST_BASE_H_ #ifndef MEDIAPIPE_GPU_GPU_TEST_BASE_H_
#define MEDIAPIPE_GPU_GPU_TEST_BASE_H_ #define MEDIAPIPE_GPU_GPU_TEST_BASE_H_
#include <functional>
#include <memory>
#include "mediapipe/framework/port/gmock.h" #include "mediapipe/framework/port/gmock.h"
#include "mediapipe/framework/port/gtest.h" #include "mediapipe/framework/port/gtest.h"
#include "mediapipe/gpu/gl_calculator_helper.h" #include "mediapipe/gpu/gl_calculator_helper.h"
@ -22,9 +25,9 @@
namespace mediapipe { namespace mediapipe {
class GpuTestBase : public ::testing::Test { class GpuTestEnvironment {
protected: protected:
GpuTestBase() { helper_.InitializeForTest(gpu_resources_.get()); } GpuTestEnvironment() { helper_.InitializeForTest(gpu_resources_.get()); }
void RunInGlContext(std::function<void(void)> gl_func) { void RunInGlContext(std::function<void(void)> gl_func) {
helper_.RunInGlContext(std::move(gl_func)); helper_.RunInGlContext(std::move(gl_func));
@ -35,6 +38,12 @@ class GpuTestBase : public ::testing::Test {
GlCalculatorHelper helper_; GlCalculatorHelper helper_;
}; };
class GpuTestBase : public testing::Test, public GpuTestEnvironment {};
template <typename T>
class GpuTestWithParamBase : public testing::TestWithParam<T>,
public GpuTestEnvironment {};
} // namespace mediapipe } // namespace mediapipe
#endif // MEDIAPIPE_GPU_GPU_TEST_BASE_H_ #endif // MEDIAPIPE_GPU_GPU_TEST_BASE_H_