-
Notifications
You must be signed in to change notification settings - Fork 0
OGSMOD-7812 - Centralize the asset access for unit tests #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,7 +99,7 @@ void VulkanRendererContext::waitForGPUIdle() | |
|
|
||
| bool VulkanRendererContext::saveImage(const std::string& fileName) | ||
| { | ||
| static const std::filesystem::path filePath = TestHelpers::getOutputDataFolder(); | ||
| const std::filesystem::path filePath = TestHelpers::getOutputDataFolder(); | ||
| const std::filesystem::path screenShotPath = getFilename(filePath, fileName + "_computed"); | ||
| const std::filesystem::path directory = screenShotPath.parent_path(); | ||
| if (!std::filesystem::exists(directory)) | ||
|
|
@@ -329,17 +329,14 @@ AndroidTestContext::AndroidTestContext(int w, int h) : TestContext(w, h) | |
|
|
||
| void AndroidTestContext::init() | ||
| { | ||
| std::string localAppPath = getenv("HVT_TEST_ASSETS"); | ||
| _sceneFilepath = localAppPath + "/usd/test_fixed.usda"; | ||
| _sceneFilepath = (TestHelpers::getAssetsDataFolder() / "usd/test_fixed.usda").string(); | ||
|
|
||
| // Create the renderer context required for Hydra. | ||
| _backend = std::make_shared<TestHelpers::VulkanRendererContext>(_width, _height); | ||
| if (!_backend) | ||
| { | ||
| throw std::runtime_error("Failed to initialize the unit test backend!"); | ||
| } | ||
|
|
||
| _backend->setDataPath(localAppPath); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously this was a scoping-like action (should've been RAII). If we no longer need it, great, but sanity check that its all good.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed, validated locally on macOS & Windows. |
||
| } | ||
|
|
||
| } // namespace TestHelpers | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -296,8 +296,7 @@ void OpenGLRendererContext::run( | |
|
|
||
| bool OpenGLRendererContext::saveImage(const std::string& fileName) | ||
| { | ||
| static const std::filesystem::path filePath = TestHelpers::getOutputDataFolder(); | ||
|
|
||
| const std::filesystem::path filePath = TestHelpers::getOutputDataFolder(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No |
||
| const std::filesystem::path screenShotPath = getFilename(filePath, fileName + "_computed"); | ||
|
|
||
| // Make sure the parent directory exists. | ||
|
|
@@ -308,6 +307,7 @@ bool OpenGLRendererContext::saveImage(const std::string& fileName) | |
|
|
||
| std::vector<unsigned char> image(width() * height() * 4, 100); | ||
| glReadPixels(0, 0, width(), height(), GL_RGBA, GL_UNSIGNED_BYTE, image.data()); | ||
|
|
||
| // Write image. | ||
|
|
||
| std::filesystem::remove(screenShotPath); | ||
|
|
@@ -333,21 +333,14 @@ OpenGLTestContext::OpenGLTestContext(int w, int h) : TestContext(w, h) | |
|
|
||
| void OpenGLTestContext::init() | ||
| { | ||
| namespace fs = std::filesystem; | ||
|
|
||
| _sceneFilepath = TOSTRING(HVT_TEST_DATA_PATH) + "/data/assets/usd/test_fixed.usda"; | ||
| _sceneFilepath = (TestHelpers::getAssetsDataFolder() / "usd/test_fixed.usda").string(); | ||
|
|
||
| // Create the renderer context required for Hydra. | ||
| _backend = std::make_shared<TestHelpers::OpenGLRendererContext>(_width, _height); | ||
| if (!_backend) | ||
| { | ||
| throw std::runtime_error("Failed to initialize the unit test backend!"); | ||
| } | ||
|
|
||
| fs::path dataPath = | ||
| std::filesystem::path(TOSTRING(HVT_TEST_DATA_PATH), fs::path::native_format); | ||
| dataPath.append("data/assets"); | ||
| _backend->setDataPath(dataPath); | ||
| } | ||
|
|
||
| } // namespace TestHelpers | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,9 +142,6 @@ class HydraRendererContext | |
| virtual bool compareOutputImages(const std::string& fileName1, const std::string& fileName2, | ||
| const uint8_t threshold = 1, const uint16_t pixelCountThreshold = 0); | ||
|
|
||
| virtual void setDataPath(const std::filesystem::path& path) { _dataPath = path; } | ||
| virtual const std::filesystem::path& dataPath() const { return _dataPath; } | ||
|
|
||
| protected: | ||
| pxr::HgiUniquePtr _hgi; | ||
| bool _presentationEnabled = true; | ||
|
|
@@ -168,8 +165,6 @@ class HydraRendererContext | |
| int _width = 1; | ||
| int _height = 1; | ||
|
|
||
| std::filesystem::path _dataPath; | ||
|
|
||
| pxr::HdDriver _hgiDriver; | ||
| }; | ||
|
|
||
|
|
@@ -241,7 +236,6 @@ class TestContext | |
| int width() const { return _width; } | ||
| int height() const { return _height; } | ||
| bool presentationEnabled() const { return _usePresentationTask; } | ||
| const std::filesystem::path& dataPath() const { return _backend->dataPath(); } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not used. |
||
| std::shared_ptr<TestHelpers::HydraRendererContext>& backend() { return _backend; } | ||
|
|
||
| // Render a single frame pass. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously android impl had been using symlinks - not sure if this is what that was. If things work now, great! Thanks for tidying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TestHelpers::getAssetsDataFolder()is doing that.