Skip to content

Commit 86dfd10

Browse files
committed
Replace all HVT_TEST_DEFAULT_BACKEND's with HVT_TEST.
1 parent 8ec380e commit 86dfd10

File tree

5 files changed

+57
-85
lines changed

5 files changed

+57
-85
lines changed

test/RenderingFramework/TestFlags.h

Lines changed: 30 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -12,55 +12,36 @@
1212
#include <gtest/gtest.h>
1313
#include <string>
1414

15-
#define HVT_TEST_DEFAULT_BACKEND(TestSuiteName, TestName) \
16-
void HVTTestDefaultBackend##TestName(); \
17-
TEST(TestSuiteName, TestName) \
18-
{ \
19-
TestHelpers::gParameterizedTests = false; \
20-
TestHelpers::gTestNames = \
21-
TestHelpers::getTestNames(::testing::UnitTest::GetInstance()->current_test_info()); \
22-
HVTTestDefaultBackend##TestName(); \
23-
} \
24-
void HVTTestDefaultBackend##TestName()
25-
26-
#if defined(ENABLE_VULKAN) && defined(WIN32)
27-
28-
#define HVT_TEST(TestSuiteName, TestName) \
29-
std::string ParamTestName##TestName(const testing::TestParamInfo<std::string>& info) \
30-
{ \
31-
return info.param; \
32-
} \
33-
class TestName : public ::testing::TestWithParam<std::string> \
34-
{ \
35-
public: \
36-
void HVTTest##TestName( \
37-
[[maybe_unused]] const std::string& computedImageName, \
38-
[[maybe_unused]] const std::string& imageFile); \
39-
}; \
40-
/* TODO: Enable "Vulkan" backend when Vulkan support is complete and stable. \
41-
Currently, only "OpenGL" is enabled for testing. */ \
42-
INSTANTIATE_TEST_SUITE_P(TestSuiteName, TestName, ::testing::Values(/*"Vulkan",*/ "OpenGL"), \
43-
ParamTestName##TestName); \
44-
TEST_P(TestName, TestName) \
45-
{ \
46-
TestHelpers::gRunVulkanTests = (GetParam() == "Vulkan"); \
47-
TestHelpers::gParameterizedTests = true; \
48-
TestHelpers::gTestNames = TestHelpers::getTestNames( \
49-
::testing::UnitTest::GetInstance()->current_test_info()); \
50-
const std::string imageFile = TestHelpers::gTestNames.suiteName + \
51-
std::string("/") + TestHelpers::gTestNames.fixtureName; \
52-
const std::string computedImageName = TestHelpers::appendParamToImageFile(imageFile); \
53-
HVTTest##TestName(computedImageName, imageFile); \
54-
} \
55-
void TestName::HVTTest##TestName( \
56-
[[maybe_unused]] const std::string& computedImageName, \
57-
[[maybe_unused]] const std::string& imageFile)
58-
59-
#else
60-
61-
#define HVT_TEST(TestSuiteName, TestName) HVT_TEST_DEFAULT_BACKEND(TestSuiteName, TestName)
62-
63-
#endif
15+
#define HVT_TEST(TestSuiteName, TestName) \
16+
std::string ParamTestName##TestName(const testing::TestParamInfo<std::string>& info) \
17+
{ \
18+
return info.param; \
19+
} \
20+
class TestName : public ::testing::TestWithParam<std::string> \
21+
{ \
22+
public: \
23+
void HVTTest##TestName( \
24+
[[maybe_unused]] const std::string& computedImageName, \
25+
[[maybe_unused]] const std::string& imageFile); \
26+
}; \
27+
/* TODO: Enable "Vulkan" backend when Vulkan support is complete and stable. \
28+
Currently, only "OpenGL" is enabled for testing. */ \
29+
INSTANTIATE_TEST_SUITE_P(TestSuiteName, TestName, ::testing::Values(/*"Vulkan",*/ "OpenGL"), \
30+
ParamTestName##TestName); \
31+
TEST_P(TestName, TestName) \
32+
{ \
33+
TestHelpers::gRunVulkanTests = (GetParam() == "Vulkan"); \
34+
TestHelpers::gParameterizedTests = true; \
35+
TestHelpers::gTestNames = TestHelpers::getTestNames( \
36+
::testing::UnitTest::GetInstance()->current_test_info()); \
37+
const std::string imageFile = TestHelpers::gTestNames.suiteName + \
38+
std::string("/") + TestHelpers::gTestNames.fixtureName; \
39+
const std::string computedImageName = TestHelpers::appendParamToImageFile(imageFile); \
40+
HVTTest##TestName(computedImageName, imageFile); \
41+
} \
42+
void TestName::HVTTest##TestName( \
43+
[[maybe_unused]] const std::string& computedImageName, \
44+
[[maybe_unused]] const std::string& imageFile)
6445

6546
namespace TestHelpers
6647
{

test/tests/testFramePass.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,13 @@ void TestDynamicFramePassParams(
234234
// Saves the rendered image and compares results.
235235

236236
const std::string computedImageName = TestHelpers::appendParamToImageFile(imageFile);
237-
ASSERT_TRUE(context->_backend->saveImage(computedImageName));
238-
ASSERT_TRUE(context->_backend->compareImage(computedImageName, imageFile));
237+
ASSERT_TRUE(context->validateImages(computedImageName, imageFile));
239238
}
240239

241240
#if defined(__ANDROID__) || TARGET_OS_IPHONE == 1
242-
HVT_TEST_DEFAULT_BACKEND(TestViewportToolbox, DISABLED_testDynamicCameraAndLights)
241+
HVT_TEST(TestViewportToolbox, DISABLED_testDynamicCameraAndLights)
243242
#else
244-
HVT_TEST_DEFAULT_BACKEND(TestViewportToolbox, testDynamicCameraAndLights)
243+
HVT_TEST(TestViewportToolbox, testDynamicCameraAndLights)
245244
#endif
246245
{
247246
// Use a fixed resolution (the image width/height do not change).

test/tests/testFramePasses.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,16 @@ HVT_TEST(TestViewportToolbox, TestFramePasses_MainOnly)
100100

101101
// Validate the rendering result.
102102

103-
const std::string computedFileName = TestHelpers::getComputedImagePath();
104-
ASSERT_TRUE(context->validateImages(computedFileName, TestHelpers::gTestNames.fixtureName));
103+
const std::string computedImagePath = TestHelpers::getComputedImagePath();
104+
ASSERT_TRUE(context->validateImages(computedImagePath, TestHelpers::gTestNames.fixtureName));
105105
}
106106

107107
// FIXME: The result image is not stable between runs on macOS. Refer to OGSMOD-4820.
108108
// Note: As Android is now built on macOS platform, the same challenge exists!
109109
#if defined(__APPLE__) || defined(__ANDROID__)
110-
HVT_TEST_DEFAULT_BACKEND(TestViewportToolbox, DISABLED_TestFramePasses_MainWithBlur)
110+
HVT_TEST(TestViewportToolbox, DISABLED_TestFramePasses_MainWithBlur)
111111
#else
112-
HVT_TEST_DEFAULT_BACKEND(TestViewportToolbox, TestFramePasses_MainWithBlur)
112+
HVT_TEST(TestViewportToolbox, TestFramePasses_MainWithBlur)
113113
#endif
114114
{
115115
auto context = TestHelpers::CreateTestContext();
@@ -206,8 +206,8 @@ HVT_TEST_DEFAULT_BACKEND(TestViewportToolbox, TestFramePasses_MainWithBlur)
206206
// Run the render loop.
207207
context->run(render, _sceneFramePass.get());
208208

209-
const std::string computedFileName = TestHelpers::getComputedImagePath();
210-
ASSERT_TRUE(context->validateImages(computedFileName, TestHelpers::gTestNames.fixtureName));
209+
const std::string computedImagePath = TestHelpers::getComputedImagePath();
210+
ASSERT_TRUE(context->validateImages(computedImagePath, TestHelpers::gTestNames.fixtureName));
211211
}
212212

213213
// FIXME: The result image is not stable between runs on macOS. Refer to OGSMOD-4820.
@@ -316,8 +316,8 @@ HVT_TEST(TestViewportToolbox, TestFramePasses_MainWithFxaa)
316316
// Run the render loop.
317317
context->run(render, _sceneFramePass.get());
318318

319-
const std::string computedFileName = TestHelpers::getComputedImagePath();
320-
ASSERT_TRUE(context->validateImages(computedFileName, TestHelpers::gTestNames.fixtureName));
319+
const std::string computedImagePath = TestHelpers::getComputedImagePath();
320+
ASSERT_TRUE(context->validateImages(computedImagePath, TestHelpers::gTestNames.fixtureName));
321321
}
322322

323323
//
@@ -409,8 +409,8 @@ HVT_TEST(TestViewportToolbox, TestFramePasses_SceneIndex)
409409

410410
// Step 6 - Validate the expected result.
411411

412-
const std::string computedFileName = TestHelpers::getComputedImagePath();
413-
ASSERT_TRUE(context->validateImages(computedFileName, TestHelpers::gTestNames.fixtureName));
412+
const std::string computedImagePath = TestHelpers::getComputedImagePath();
413+
ASSERT_TRUE(context->validateImages(computedImagePath, TestHelpers::gTestNames.fixtureName));
414414
}
415415

416416
// Note: The second frame pass is not displayed on Android. Refer to OGSMOD-7277.

test/tests/testSearches.cpp

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,14 @@ HVT_TEST(TestViewportToolbox, TestSearchPrims)
169169

170170
// Validates the rendering result.
171171

172-
const std::string computedFileName = TestHelpers::getComputedImagePath();
173-
ASSERT_TRUE(context->_backend->saveImage(computedFileName));
174-
ASSERT_TRUE(
175-
context->_backend->compareImage(computedFileName, TestHelpers::gTestNames.fixtureName));
172+
const std::string computedImagePath = TestHelpers::getComputedImagePath();
173+
ASSERT_TRUE(context->validateImages(computedImagePath, TestHelpers::gTestNames.fixtureName));
176174
}
177175

178176
#if TARGET_OS_IPHONE == 1
179-
HVT_TEST_DEFAULT_BACKEND(TestViewportToolbox, DISABLED_TestSearchFaces)
177+
HVT_TEST(TestViewportToolbox, DISABLED_TestSearchFaces)
180178
#else
181-
HVT_TEST_DEFAULT_BACKEND(TestViewportToolbox, TestSearchFaces)
179+
HVT_TEST(TestViewportToolbox, TestSearchFaces)
182180
#endif
183181
{
184182
// The unit test searches for some faces and highlights them.
@@ -247,18 +245,16 @@ HVT_TEST_DEFAULT_BACKEND(TestViewportToolbox, TestSearchFaces)
247245
computedFileName = "origin_dev/02505/" + computedFileName;
248246
#endif
249247

250-
ASSERT_TRUE(context->_backend->saveImage(computedFileName));
251-
ASSERT_TRUE(
252-
context->_backend->compareImage(computedFileName, TestHelpers::gTestNames.fixtureName));
248+
ASSERT_TRUE(context->validateImages(computedImageName, TestHelpers::gTestNames.fixtureName));
253249
}
254250

255251
// FIXME: Android unit test framework does not report the error message, make it impossible to fix
256252
// issues. Refer to OGSMOD-5546.
257253
//
258254
#if defined(__ANDROID__) || TARGET_OS_IPHONE == 1
259-
HVT_TEST_DEFAULT_BACKEND(TestViewportToolbox, DISABLED_TestSearchEdges)
255+
HVT_TEST(TestViewportToolbox, DISABLED_TestSearchEdges)
260256
#else
261-
HVT_TEST_DEFAULT_BACKEND(TestViewportToolbox, TestSearchEdges)
257+
HVT_TEST(TestViewportToolbox, TestSearchEdges)
262258
#endif
263259
{
264260
// The unit test searches for some edges.
@@ -344,11 +340,8 @@ HVT_TEST_DEFAULT_BACKEND(TestViewportToolbox, TestSearchEdges)
344340
// Validates the rendering result.
345341

346342
// As the edge selection should do nothing use an existing baseline image.
347-
const std::string imageFile = std::string("TestFramePasses_MainOnly");
348-
const std::string computedImageName = TestHelpers::appendParamToImageFile(imageFile);
349-
350-
ASSERT_TRUE(context->_backend->saveImage(computedImageName));
351-
ASSERT_TRUE(context->_backend->compareImage(computedImageName, imageFile));
343+
const std::string imageFilename = std::string("TestFramePasses_MainOnly");
344+
ASSERT_TRUE(context->validateImages(computedImageName, imageFilename));
352345
}
353346

354347
// FIXME: Android unit test framework does not report the error message, make it impossible to fix

test/tests/testTaskManager.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ PXR_NAMESPACE_USING_DIRECTIVE
4949
#include <pxr/usd/sdf/path.h>
5050

5151
#if defined(__ANDROID__) || TARGET_OS_IPHONE == 1
52-
HVT_TEST_DEFAULT_BACKEND(TestViewportToolbox, DISABLED_TestTaskManager)
52+
HVT_TEST(TestViewportToolbox, DISABLED_TestTaskManager)
5353
#else
54-
HVT_TEST_DEFAULT_BACKEND(TestViewportToolbox, TestTaskManager)
54+
HVT_TEST(TestViewportToolbox, TestTaskManager)
5555
#endif
5656
{
5757
// The goal of the unit test is to validate the "TaskManager" and "FramePass" classes working
@@ -180,9 +180,8 @@ HVT_TEST_DEFAULT_BACKEND(TestViewportToolbox, TestTaskManager)
180180
// Validates the rendering result.
181181

182182
const std::string computedFileName = TestHelpers::getComputedImagePath();
183-
ASSERT_TRUE(testContext->_backend->saveImage(computedFileName));
184-
ASSERT_TRUE(testContext->_backend->compareImage(
185-
computedFileName, TestHelpers::gTestNames.fixtureName, 1));
183+
ASSERT_TRUE(
184+
testContext->validateImages(computedImageName, TestHelpers::gTestNames.fixtureName, 1));
186185
}
187186

188187
namespace
@@ -294,7 +293,7 @@ HVT_TEST(TestViewportToolbox, TestTaskManagerCommitFn)
294293
ASSERT_EQ(params.blurAmount, 12.0f);
295294

296295
// Override the existing task commit function with a new function.
297-
constexpr float kNewBlurValue = 777.7;
296+
constexpr float kNewBlurValue = 777.7f;
298297
taskManager->SetTaskCommitFn(pathBlur,
299298
[&](hvt::TaskManager::GetTaskValueFn const& /*fnGetValue*/,
300299
hvt::TaskManager::SetTaskValueFn const& fnSetValue)

0 commit comments

Comments
 (0)