-
Notifications
You must be signed in to change notification settings - Fork 1
Increase test coverage with 71 new tests and in-memory helpers #171
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 |
|---|---|---|
|
|
@@ -587,11 +587,117 @@ TEST_F(ManagerHeadlessTest, HasAnimationNameNoSkeleton) | |
|
|
||
| auto cubeNode = PrimitiveObject::createCube("AnimNameCube"); | ||
| ASSERT_FALSE(mgr->getEntities().isEmpty()); | ||
| Ogre::Entity* entity = mgr->getEntities().last(); | ||
| // Filter by movable type to avoid casting ManualObjects to Entity | ||
| Ogre::Entity* entity = nullptr; | ||
| for (auto* obj : mgr->getEntities()) { | ||
| if (obj->getMovableType() == "Entity") { | ||
| entity = static_cast<Ogre::Entity*>(obj); | ||
| } | ||
| } | ||
| ASSERT_NE(entity, nullptr); | ||
|
|
||
| // Primitives have no skeleton, so hasAnimationName should return false | ||
| EXPECT_FALSE(mgr->hasAnimationName(entity, "Walk")); | ||
| EXPECT_FALSE(mgr->hasAnimationName(entity, "")); | ||
|
|
||
| mgr->destroySceneNode(cubeNode); | ||
| } | ||
|
|
||
| // --- In-memory entity tests --- | ||
|
|
||
| TEST_F(ManagerHeadlessTest, CreateInMemoryEntity) | ||
| { | ||
| if (!canLoadMeshFiles()) { GTEST_SKIP() << "Skipping: entity creation not supported without render window"; } | ||
| auto* mgr = Manager::getSingletonPtr(); | ||
| ASSERT_NE(mgr, nullptr); | ||
|
|
||
| auto mesh = createInMemoryTriangleMesh("MgrInMemTriangle"); | ||
| auto* sceneMgr = mgr->getSceneMgr(); | ||
| auto* node = mgr->addSceneNode("MgrInMemNode"); | ||
| auto* entity = sceneMgr->createEntity("MgrInMemEntity", mesh); | ||
| node->attachObject(entity); | ||
|
|
||
| EXPECT_TRUE(mgr->hasSceneNode("MgrInMemNode")); | ||
| EXPECT_FALSE(mgr->getEntities().isEmpty()); | ||
| } | ||
|
|
||
| TEST_F(ManagerHeadlessTest, CreateInMemorySkeletonEntity) | ||
| { | ||
| if (!canLoadMeshFiles()) { GTEST_SKIP() << "Skipping: entity creation not supported without render window"; } | ||
| auto* mgr = Manager::getSingletonPtr(); | ||
| ASSERT_NE(mgr, nullptr); | ||
|
|
||
| auto mesh = createInMemorySkeletonMesh("MgrSkelMesh"); | ||
| auto* sceneMgr = mgr->getSceneMgr(); | ||
| auto* node = mgr->addSceneNode("MgrSkelNode"); | ||
| auto* entity = sceneMgr->createEntity("MgrSkelEntity", mesh); | ||
| node->attachObject(entity); | ||
|
|
||
| EXPECT_TRUE(entity->hasSkeleton()); | ||
| EXPECT_EQ(entity->getSkeleton()->getNumBones(), 2u); | ||
| } | ||
|
Comment on lines
+636
to
+638
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. 🧩 Analysis chain🏁 Script executed: head -n 670 src/Manager_test.cpp | tail -n 45Repository: fernandotonon/QtMeshEditor Length of output: 1680 🏁 Script executed: rg -n "EXPECT_TRUE\(entity->has(Skeleton|AnimationState)" src/Manager_test.cpp -A 2 -B 1Repository: fernandotonon/QtMeshEditor Length of output: 363 Use At lines 636–637, Proposed fix- EXPECT_TRUE(entity->hasSkeleton());
- EXPECT_EQ(entity->getSkeleton()->getNumBones(), 2u);
+ ASSERT_TRUE(entity->hasSkeleton());
+ ASSERT_NE(entity->getSkeleton(), nullptr);
+ EXPECT_EQ(entity->getSkeleton()->getNumBones(), 2u);
...
- EXPECT_TRUE(entity->hasSkeleton());
- EXPECT_TRUE(entity->hasAnimationState("TestAnim"));
-
- auto* state = entity->getAnimationState("TestAnim");
+ ASSERT_TRUE(entity->hasSkeleton());
+ ASSERT_TRUE(entity->hasAnimationState("TestAnim"));
+ auto* state = entity->getAnimationState("TestAnim");
+ ASSERT_NE(state, nullptr);
EXPECT_NEAR(state->getLength(), 1.0f, 0.01f);Also applies to: 649–653 🤖 Prompt for AI Agents |
||
|
|
||
| TEST_F(ManagerHeadlessTest, CreateAnimatedEntity) | ||
| { | ||
| if (!canLoadMeshFiles()) { GTEST_SKIP() << "Skipping: entity creation not supported without render window"; } | ||
| auto* mgr = Manager::getSingletonPtr(); | ||
| ASSERT_NE(mgr, nullptr); | ||
|
|
||
| auto* entity = createAnimatedTestEntity("MgrAnimEntity"); | ||
| ASSERT_NE(entity, nullptr); | ||
|
|
||
| EXPECT_TRUE(entity->hasSkeleton()); | ||
| EXPECT_TRUE(entity->hasAnimationState("TestAnim")); | ||
|
|
||
| auto* state = entity->getAnimationState("TestAnim"); | ||
| EXPECT_NEAR(state->getLength(), 1.0f, 0.01f); | ||
| } | ||
|
|
||
| TEST_F(ManagerHeadlessTest, HasAnimationNameWithSkeleton) | ||
| { | ||
| if (!canLoadMeshFiles()) { GTEST_SKIP() << "Skipping: entity creation not supported without render window"; } | ||
| auto* mgr = Manager::getSingletonPtr(); | ||
| ASSERT_NE(mgr, nullptr); | ||
|
|
||
| auto* entity = createAnimatedTestEntity("MgrAnimNameEntity"); | ||
| ASSERT_NE(entity, nullptr); | ||
|
|
||
| EXPECT_TRUE(mgr->hasAnimationName(entity, "TestAnim")); | ||
| EXPECT_FALSE(mgr->hasAnimationName(entity, "NonExistentAnim")); | ||
| } | ||
|
|
||
| TEST_F(ManagerHeadlessTest, DestroyInMemoryEntity) | ||
| { | ||
| if (!canLoadMeshFiles()) { GTEST_SKIP() << "Skipping: entity creation not supported without render window"; } | ||
| auto* mgr = Manager::getSingletonPtr(); | ||
| ASSERT_NE(mgr, nullptr); | ||
|
|
||
| auto mesh = createInMemoryTriangleMesh("MgrDestroyTriangle"); | ||
| auto* sceneMgr = mgr->getSceneMgr(); | ||
| auto* node = mgr->addSceneNode("MgrDestroyNode"); | ||
| auto* entity = sceneMgr->createEntity("MgrDestroyEntity", mesh); | ||
| node->attachObject(entity); | ||
|
|
||
| ASSERT_TRUE(mgr->hasSceneNode("MgrDestroyNode")); | ||
| mgr->destroySceneNode("MgrDestroyNode"); | ||
| EXPECT_FALSE(mgr->hasSceneNode("MgrDestroyNode")); | ||
| } | ||
|
|
||
| TEST_F(ManagerHeadlessTest, SceneNodeParenting) | ||
| { | ||
| auto* mgr = Manager::getSingletonPtr(); | ||
| ASSERT_NE(mgr, nullptr); | ||
|
|
||
| auto* parent = mgr->addSceneNode("ParentNode"); | ||
| ASSERT_NE(parent, nullptr); | ||
|
|
||
| auto* child = mgr->getSceneMgr()->getRootSceneNode()->createChildSceneNode("ChildNode"); | ||
| ASSERT_NE(child, nullptr); | ||
|
|
||
| // Move child under parent | ||
| mgr->getSceneMgr()->getRootSceneNode()->removeChild(child); | ||
| parent->addChild(child); | ||
|
|
||
| EXPECT_EQ(child->getParentSceneNode(), parent); | ||
| EXPECT_EQ(parent->numChildren(), 1u); | ||
| } | ||
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.
🧩 Analysis chain
🏁 Script executed:
Repository: fernandotonon/QtMeshEditor
Length of output: 912
🏁 Script executed:
# Check the include section to see what's already included head -20 src/MCPServer_test.cppRepository: fernandotonon/QtMeshEditor
Length of output: 572
🏁 Script executed:
Repository: fernandotonon/QtMeshEditor
Length of output: 161
🏁 Script executed:
Repository: fernandotonon/QtMeshEditor
Length of output: 52
🏁 Script executed:
Repository: fernandotonon/QtMeshEditor
Length of output: 765
Use unique temporary directories to avoid test file collisions.
Line 2325 uses a fixed basename in the shared system temp directory. Concurrent or repeated test runs can cause file conflicts. Use
QTemporaryDirto create a unique per-test directory instead.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents