Skip to content

Commit

Permalink
WIP started cesium object tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattelser committed Oct 18, 2023
1 parent b3a1bd5 commit b2661eb
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tests/src/ExampleTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ TEST_SUITE("Example Tests") {
x -= 1;
CHECK(x == 0);
}

// Flow returns here after each independant subcase, so we can test
// shared effects here
CHECK(x != 1);
}
// A few notes on subcases:
// - You can nest subcases
Expand Down
84 changes: 83 additions & 1 deletion tests/src/UsdUtilTests.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "testUtils.h"

#include "cesium/omniverse/Context.h"
#include "cesium/omniverse/LoggerSink.h"
#include "cesium/omniverse/UsdUtil.h"
Expand Down Expand Up @@ -60,7 +62,7 @@ TEST_SUITE("UsdUtil tests") {
TEST_CASE("Test UTF-8 path names") {
auto stage = getUsdStage();

for (int i = 0; i < 32; i++) {
for (int i = 0; i < NUM_TEST_REPETITIONS; i++) {
std::string randomUTF8String = "safe_name_test";

randomUTF8String.reserve(64);
Expand All @@ -78,5 +80,85 @@ TEST_SUITE("UsdUtil tests") {
CHECK_FALSE(primExists(safeUniquePath));
}
}

TEST_CASE("Cesium helper functions") {

auto stage = getUsdStage();
auto dataPath = getPathUnique(getRootPath(), "CesiumTestPrim");
auto sessionPath = getPathUnique(getRootPath(), "CesiumTestPrim");
auto georeferencePath = getPathUnique(getRootPath(), "CesiumTestPrim");
auto tilesetPath = getPathUnique(getRootPath(), "CesiumTestPrim");
auto imageryPath = getPathUnique(getRootPath(), "CesiumTestPrim");
auto globeAnchorPath = getPathUnique(getRootPath(), "CesiumTestPrim");

// SUBCASE("Define Cesium objects") {
defineCesiumData(dataPath);
defineCesiumSession(sessionPath);
defineCesiumGeoreference(georeferencePath);
defineCesiumTileset(tilesetPath);
defineCesiumImagery(imageryPath);
defineGlobeAnchor(globeAnchorPath);
// }

// SUBCASE("Define Cesium objects") {
// // getOrCreateCesiumData();
// // getOrCreateCesiumSession();
// // getOrCreateCesiumGeoreference();
// // getCesiumGeoreference(const pxr::SdfPath& path);
// // getCesiumTileset(const pxr::SdfPath& path);
// // getCesiumImagery(const pxr::SdfPath& path);
// // getChildCesiumImageryPrims(const pxr::SdfPath& path);
// // getCesiumGlobeAnchor(const pxr::SdfPath& path);
// }

CHECK(isCesiumData(dataPath));
CHECK(isCesiumSession(sessionPath));
CHECK(isCesiumGeoreference(georeferencePath));
CHECK(isCesiumTileset(tilesetPath));
CHECK(isCesiumImagery(imageryPath));
CHECK(hasCesiumGlobeAnchor(globeAnchorPath));
}

TEST_CASE("Smoke tests") {
// functions for which we do not yet have better tests,
// but we can at least verify they don't throw
CHECK_NOTHROW(getDynamicTextureProviderAssetPathToken("foo"));
CHECK_NOTHROW(getFabricStageReaderWriter());
CHECK_NOTHROW(getFabricStageReaderWriterId());

// hasStage();
// usdToGlmVector(const pxr::GfVec3d& vector);
// glmToUsdVector(const glm::dvec3& vector);
// glmToUsdVector(const glm::fvec2& vector);
// glmToUsdVector(const glm::fvec3& vector);
// glmToUsdRange(const std::array<glm::dvec3, 2>& range);
// glmToUsdQuat(const glm::dquat& quat);
// glmToUsdMatrixDecomposed(const glm::dmat4& matrix);
// computeUsdWorldToLocalTransform(const pxr::SdfPath& path);
// getUsdUpAxis();
// getUsdMetersPerUnit();
// computeEcefToUsdLocalTransform(const CesiumGeospatial::Cartographic& origin);
// computeEcefToUsdWorldTransformForPrim(
// const CesiumGeospatial::Cartographic& origin, const pxr::SdfPath& primPath);
// computeUsdWorldToEcefTransformForPrim(
// const CesiumGeospatial::Cartographic& origin, const pxr::SdfPath& primPath);
// computeEcefToUsdLocalTransformForPrim(
// const CesiumGeospatial::Cartographic& origin, const pxr::SdfPath& primPath);
// computeUsdLocalToEcefTransformForPrim(
// const CesiumGeospatial::Cartographic& origin, const pxr::SdfPath& primPath);
// computeViewState(
// const CesiumGeospatial::Cartographic& origin, const pxr::SdfPath& primPath, const Viewport& viewport);
// computeWorldExtent(const pxr::GfRange3d& localExtent, const glm::dmat4& localToUsdTransform);
// getEulerAnglesFromQuaternion(const pxr::GfQuatf& quaternion);

// primExists(const pxr::SdfPath& path);

// setGeoreferenceForTileset(const pxr::SdfPath& tilesetPath, const pxr::SdfPath& georeferencePath);

// addOrUpdateTransformOpForAnchor(const pxr::SdfPath& path, const glm::dmat4& transform);
// getCesiumTransformOpValueForPathIfExists(const pxr::SdfPath& path);
// getAnchorGeoreferencePath(const pxr::SdfPath& path);
// getCartographicOriginForAnchor(const pxr::SdfPath& path);
}
}
} // namespace cesium::omniverse::UsdUtil

0 comments on commit b2661eb

Please sign in to comment.