From dfe58a5ed49d473699dc467211947d39d4d4bc7f Mon Sep 17 00:00:00 2001 From: Seiji Emery Date: Mon, 22 Jun 2015 17:42:07 -0700 Subject: [PATCH] Disabled Model (entity) Tests, as they are waaay out of date and will not run with the current codebase. These should get reimplemented at some point. --- libraries/entities/src/EntityTree.cpp | 2 +- tests/octree/src/AABoxCubeTests.cpp | 129 ++++++++++---------------- tests/octree/src/AABoxCubeTests.h | 18 +++- tests/octree/src/ModelTests.cpp | 5 +- tests/octree/src/ModelTests.h | 17 +++- tests/octree/src/OctreeTests.cpp | 22 +++-- tests/octree/src/OctreeTests.h | 16 ++-- 7 files changed, 107 insertions(+), 102 deletions(-) diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 363f3c56d7..b3d69cb508 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -229,7 +229,7 @@ EntityItemPointer EntityTree::addEntity(const EntityItemID& entityID, const Enti if (getIsClient()) { // if our Node isn't allowed to create entities in this domain, don't try. auto nodeList = DependencyManager::get(); - if (!nodeList->getThisNodeCanRez()) { + if (nodeList && !nodeList->getThisNodeCanRez()) { return NULL; } } diff --git a/tests/octree/src/AABoxCubeTests.cpp b/tests/octree/src/AABoxCubeTests.cpp index 7318c40657..33bdc350a8 100644 --- a/tests/octree/src/AABoxCubeTests.cpp +++ b/tests/octree/src/AABoxCubeTests.cpp @@ -9,92 +9,65 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include +//#include #include #include #include "AABoxCubeTests.h" -void AABoxCubeTests::AABoxCubeTests(bool verbose) { - qDebug() << "******************************************************************************************"; - qDebug() << "AABoxCubeTests::AABoxCubeTests()"; +QTEST_MAIN(AABoxCubeTests) - { - qDebug() << "Test 1: AABox.findRayIntersection() inside out MIN_X_FACE"; +void AABoxCubeTests::raycastOutHitsXMinFace() { + // Raycast inside out + glm::vec3 corner(0.0f, 0.0f, 0.0f); + float size = 1.0f; + + AABox box(corner, size); + glm::vec3 origin(0.5f, 0.5f, 0.5f); + glm::vec3 direction(-1.0f, 0.0f, 0.0f); + float distance; + BoxFace face; - glm::vec3 corner(0.0f, 0.0f, 0.0f); - float size = 1.0f; - - AABox box(corner, size); - glm::vec3 origin(0.5f, 0.5f, 0.5f); - glm::vec3 direction(-1.0f, 0.0f, 0.0f); - float distance; - BoxFace face; - - bool intersects = box.findRayIntersection(origin, direction, distance, face); - - if (intersects && distance == 0.5f && face == MIN_X_FACE) { - qDebug() << "Test 1: PASSED"; - } else { - qDebug() << "intersects=" << intersects << "expected=" << true; - qDebug() << "distance=" << distance << "expected=" << 0.5f; - qDebug() << "face=" << face << "expected=" << MIN_X_FACE; - - } - } - - { - qDebug() << "Test 2: AABox.findRayIntersection() inside out MAX_X_FACE"; - - glm::vec3 corner(0.0f, 0.0f, 0.0f); - float size = 1.0f; - - AABox box(corner, size); - glm::vec3 origin(0.5f, 0.5f, 0.5f); - glm::vec3 direction(1.0f, 0.0f, 0.0f); - float distance; - BoxFace face; - - bool intersects = box.findRayIntersection(origin, direction, distance, face); - - if (intersects && distance == 0.5f && face == MAX_X_FACE) { - qDebug() << "Test 2: PASSED"; - } else { - qDebug() << "intersects=" << intersects << "expected=" << true; - qDebug() << "distance=" << distance << "expected=" << 0.5f; - qDebug() << "face=" << face << "expected=" << MAX_X_FACE; - - } - } - - { - qDebug() << "Test 3: AABox.findRayIntersection() outside in"; - - glm::vec3 corner(0.5f, 0.0f, 0.0f); - float size = 0.5f; - - AABox box(corner, size); - glm::vec3 origin(0.25f, 0.25f, 0.25f); - glm::vec3 direction(1.0f, 0.0f, 0.0f); - float distance; - BoxFace face; - - bool intersects = box.findRayIntersection(origin, direction, distance, face); - - if (intersects && distance == 0.25f && face == MIN_X_FACE) { - qDebug() << "Test 3: PASSED"; - } else { - qDebug() << "intersects=" << intersects << "expected=" << true; - qDebug() << "distance=" << distance << "expected=" << 0.5f; - qDebug() << "face=" << face << "expected=" << MIN_X_FACE; - - } - } - - qDebug() << "******************************************************************************************"; + bool intersects = box.findRayIntersection(origin, direction, distance, face); + + QCOMPARE(intersects, true); + QCOMPARE(distance, 0.5f); + QCOMPARE(face, MIN_X_FACE); } -void AABoxCubeTests::runAllTests(bool verbose) { - AABoxCubeTests(verbose); +void AABoxCubeTests::raycastOutHitsXMaxFace () { + // Raycast inside out + glm::vec3 corner(0.0f, 0.0f, 0.0f); + float size = 1.0f; + + AABox box(corner, size); + glm::vec3 origin(0.5f, 0.5f, 0.5f); + glm::vec3 direction(1.0f, 0.0f, 0.0f); + float distance; + BoxFace face; + + bool intersects = box.findRayIntersection(origin, direction, distance, face); + + QCOMPARE(intersects, true); + QCOMPARE(distance, 0.5f); + QCOMPARE(face, MAX_X_FACE); } +void AABoxCubeTests::raycastInHitsXMinFace () { + // Raycast outside in + glm::vec3 corner(0.5f, 0.0f, 0.0f); + float size = 0.5f; + + AABox box(corner, size); + glm::vec3 origin(0.25f, 0.25f, 0.25f); + glm::vec3 direction(1.0f, 0.0f, 0.0f); + float distance; + BoxFace face; + + bool intersects = box.findRayIntersection(origin, direction, distance, face); + + QCOMPARE(intersects, true); + QCOMPARE(distance, 0.5f); + QCOMPARE(face, MIN_X_FACE); +} + diff --git a/tests/octree/src/AABoxCubeTests.h b/tests/octree/src/AABoxCubeTests.h index 7f5ff05ed9..7cb468449f 100644 --- a/tests/octree/src/AABoxCubeTests.h +++ b/tests/octree/src/AABoxCubeTests.h @@ -12,9 +12,19 @@ #ifndef hifi_AABoxCubeTests_h #define hifi_AABoxCubeTests_h -namespace AABoxCubeTests { - void AABoxCubeTests(bool verbose); - void runAllTests(bool verbose); -} +#include + + +class AABoxCubeTests : public QObject { + Q_OBJECT + +private slots: + void raycastOutHitsXMinFace (); + void raycastOutHitsXMaxFace (); + void raycastInHitsXMinFace (); + + // TODO: Add more unit tests! + // (eg. no test for failed intersection or non-orthogonal ray) +}; #endif // hifi_AABoxCubeTests_h diff --git a/tests/octree/src/ModelTests.cpp b/tests/octree/src/ModelTests.cpp index 4fe43d10bd..c2d170da9a 100644 --- a/tests/octree/src/ModelTests.cpp +++ b/tests/octree/src/ModelTests.cpp @@ -25,6 +25,9 @@ //#include "EntityTests.h" #include "ModelTests.h" // needs to be EntityTests.h soon +QTEST_MAIN(EntityTests) + +/* void EntityTests::entityTreeTests(bool verbose) { bool extraVerbose = false; @@ -508,4 +511,4 @@ void EntityTests::entityTreeTests(bool verbose) { void EntityTests::runAllTests(bool verbose) { entityTreeTests(verbose); } - +*/ diff --git a/tests/octree/src/ModelTests.h b/tests/octree/src/ModelTests.h index bd19356b5f..e287112b04 100644 --- a/tests/octree/src/ModelTests.h +++ b/tests/octree/src/ModelTests.h @@ -12,9 +12,18 @@ #ifndef hifi_EntityTests_h #define hifi_EntityTests_h -namespace EntityTests { - void entityTreeTests(bool verbose = false); - void runAllTests(bool verbose = false); -} +#include + +// +// TODO: These are waaay out of date with the current codebase, and should be reimplemented at some point. +// + +class EntityTests : public QObject { + Q_OBJECT + +private slots: +// void entityTreeTests(bool verbose = false); +// void runAllTests(bool verbose = false); +}; #endif // hifi_EntityTests_h diff --git a/tests/octree/src/OctreeTests.cpp b/tests/octree/src/OctreeTests.cpp index 4cfadbccfc..857fbb51f1 100644 --- a/tests/octree/src/OctreeTests.cpp +++ b/tests/octree/src/OctreeTests.cpp @@ -51,8 +51,11 @@ enum ExamplePropertyList { typedef PropertyFlags ExamplePropertyFlags; +QTEST_MAIN(OctreeTests) -void OctreeTests::propertyFlagsTests(bool verbose) { +void OctreeTests::propertyFlagsTests() { + bool verbose = true; + int testsTaken = 0; int testsPassed = 0; int testsFailed = 0; @@ -891,7 +894,9 @@ typedef ByteCountCoded ByteCountCodedQUINT64; typedef ByteCountCoded ByteCountCodedINT; -void OctreeTests::byteCountCodingTests(bool verbose) { +void OctreeTests::byteCountCodingTests() { + bool verbose = true; + int testsTaken = 0; int testsPassed = 0; int testsFailed = 0; @@ -1268,7 +1273,8 @@ void OctreeTests::byteCountCodingTests(bool verbose) { } } -void OctreeTests::modelItemTests(bool verbose) { +void OctreeTests::modelItemTests() { + bool verbose = true; #if 0 // TODO - repair/replace these @@ -1440,9 +1446,9 @@ void OctreeTests::modelItemTests(bool verbose) { } -void OctreeTests::runAllTests(bool verbose) { - propertyFlagsTests(verbose); - byteCountCodingTests(verbose); - modelItemTests(verbose); -} +//void OctreeTests::runAllTests(bool verbose) { +// propertyFlagsTests(verbose); +// byteCountCodingTests(verbose); +// modelItemTests(verbose); +//} diff --git a/tests/octree/src/OctreeTests.h b/tests/octree/src/OctreeTests.h index 11d61b3fe5..7d24ad3590 100644 --- a/tests/octree/src/OctreeTests.h +++ b/tests/octree/src/OctreeTests.h @@ -12,13 +12,17 @@ #ifndef hifi_OctreeTests_h #define hifi_OctreeTests_h -namespace OctreeTests { +#include - void propertyFlagsTests(bool verbose); - void byteCountCodingTests(bool verbose); - void modelItemTests(bool verbose); +class OctreeTests : public QObject { + Q_OBJECT + +private slots: + void propertyFlagsTests(); + void byteCountCodingTests(); + void modelItemTests(); - void runAllTests(bool verbose); -} +// void runAllTests(bool verbose); +}; #endif // hifi_OctreeTests_h