mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 00:24:40 +00:00
Merge pull request #594 from LuisAntonRebollo/unit-tests-without-crash
Increased stability Torque3D: unit-tests running without a crash.
This commit is contained in:
commit
feec36731e
18 changed files with 113 additions and 19 deletions
|
|
@ -511,6 +511,12 @@ bool Debris::onAdd()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !mDataBlock )
|
||||||
|
{
|
||||||
|
Con::errorf("Debris::onAdd - Fail - No datablock");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// create emitters
|
// create emitters
|
||||||
for( S32 i=0; i<DebrisData::DDC_NUM_EMITTERS; i++ )
|
for( S32 i=0; i<DebrisData::DDC_NUM_EMITTERS; i++ )
|
||||||
{
|
{
|
||||||
|
|
@ -653,8 +659,11 @@ void Debris::onRemove()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getSceneManager()->removeObjectFromScene(this);
|
if( getSceneManager() )
|
||||||
getContainer()->removeObject(this);
|
getSceneManager()->removeObjectFromScene(this);
|
||||||
|
|
||||||
|
if( getContainer() )
|
||||||
|
getContainer()->removeObject(this);
|
||||||
|
|
||||||
Parent::onRemove();
|
Parent::onRemove();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -784,6 +784,7 @@ bool ExplosionData::preload(bool server, String &errorStr)
|
||||||
//--------------------------------------
|
//--------------------------------------
|
||||||
//
|
//
|
||||||
Explosion::Explosion()
|
Explosion::Explosion()
|
||||||
|
: mDataBlock( NULL )
|
||||||
{
|
{
|
||||||
mTypeMask |= ExplosionObjectType | LightObjectType;
|
mTypeMask |= ExplosionObjectType | LightObjectType;
|
||||||
|
|
||||||
|
|
@ -844,6 +845,12 @@ bool Explosion::onAdd()
|
||||||
if ( !conn || !Parent::onAdd() )
|
if ( !conn || !Parent::onAdd() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if( !mDataBlock )
|
||||||
|
{
|
||||||
|
Con::errorf("Explosion::onAdd - Fail - No datablok");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mDelayMS = mDataBlock->delayMS + sgRandom.randI( -mDataBlock->delayVariance, mDataBlock->delayVariance );
|
mDelayMS = mDataBlock->delayMS + sgRandom.randI( -mDataBlock->delayVariance, mDataBlock->delayVariance );
|
||||||
mEndingMS = mDataBlock->lifetimeMS + sgRandom.randI( -mDataBlock->lifetimeVariance, mDataBlock->lifetimeVariance );
|
mEndingMS = mDataBlock->lifetimeMS + sgRandom.randI( -mDataBlock->lifetimeVariance, mDataBlock->lifetimeVariance );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -303,6 +303,7 @@ bool SplashData::preload(bool server, String &errorStr)
|
||||||
// Splash
|
// Splash
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
Splash::Splash()
|
Splash::Splash()
|
||||||
|
: mDataBlock( NULL )
|
||||||
{
|
{
|
||||||
dMemset( mEmitterList, 0, sizeof( mEmitterList ) );
|
dMemset( mEmitterList, 0, sizeof( mEmitterList ) );
|
||||||
|
|
||||||
|
|
@ -353,6 +354,12 @@ bool Splash::onAdd()
|
||||||
if(!conn || !Parent::onAdd())
|
if(!conn || !Parent::onAdd())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if( !mDataBlock )
|
||||||
|
{
|
||||||
|
Con::errorf("Splash::onAdd - Fail - No datablock");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mDelayMS = mDataBlock->delayMS + sgRandom.randI( -mDataBlock->delayVariance, mDataBlock->delayVariance );
|
mDelayMS = mDataBlock->delayMS + sgRandom.randI( -mDataBlock->delayVariance, mDataBlock->delayVariance );
|
||||||
mEndingMS = mDataBlock->lifetimeMS + sgRandom.randI( -mDataBlock->lifetimeVariance, mDataBlock->lifetimeVariance );
|
mEndingMS = mDataBlock->lifetimeMS + sgRandom.randI( -mDataBlock->lifetimeVariance, mDataBlock->lifetimeVariance );
|
||||||
|
|
||||||
|
|
@ -408,8 +415,11 @@ void Splash::onRemove()
|
||||||
|
|
||||||
ringList.clear();
|
ringList.clear();
|
||||||
|
|
||||||
getSceneManager()->removeObjectFromScene(this);
|
if( getSceneManager() )
|
||||||
getContainer()->removeObject(this);
|
getSceneManager()->removeObjectFromScene(this);
|
||||||
|
|
||||||
|
if( getContainer() )
|
||||||
|
getContainer()->removeObject(this);
|
||||||
|
|
||||||
Parent::onRemove();
|
Parent::onRemove();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -311,7 +311,8 @@ PhysicsDebris* PhysicsDebris::create( PhysicsDebrisData *datablock,
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicsDebris::PhysicsDebris()
|
PhysicsDebris::PhysicsDebris()
|
||||||
: mLifetime( 0.0f ),
|
: mDataBlock( NULL ),
|
||||||
|
mLifetime( 0.0f ),
|
||||||
mShapeInstance( NULL ),
|
mShapeInstance( NULL ),
|
||||||
mWorld( NULL ),
|
mWorld( NULL ),
|
||||||
mInitialLinVel( Point3F::Zero )
|
mInitialLinVel( Point3F::Zero )
|
||||||
|
|
@ -342,6 +343,12 @@ bool PhysicsDebris::onAdd()
|
||||||
if ( !Parent::onAdd() )
|
if ( !Parent::onAdd() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if( !mDataBlock )
|
||||||
|
{
|
||||||
|
Con::errorf("PhysicsDebris::onAdd - Fail - No datablock");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// If it has a fixed lifetime then calculate it.
|
// If it has a fixed lifetime then calculate it.
|
||||||
if ( mDataBlock->lifetime > 0.0f )
|
if ( mDataBlock->lifetime > 0.0f )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -550,6 +550,7 @@ S32 ProjectileData::scaleValue( S32 value, bool down )
|
||||||
//
|
//
|
||||||
Projectile::Projectile()
|
Projectile::Projectile()
|
||||||
: mPhysicsWorld( NULL ),
|
: mPhysicsWorld( NULL ),
|
||||||
|
mDataBlock( NULL ),
|
||||||
mCurrPosition( 0, 0, 0 ),
|
mCurrPosition( 0, 0, 0 ),
|
||||||
mCurrVelocity( 0, 0, 1 ),
|
mCurrVelocity( 0, 0, 1 ),
|
||||||
mSourceObjectId( -1 ),
|
mSourceObjectId( -1 ),
|
||||||
|
|
@ -697,6 +698,12 @@ bool Projectile::onAdd()
|
||||||
if(!Parent::onAdd())
|
if(!Parent::onAdd())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if( !mDataBlock )
|
||||||
|
{
|
||||||
|
Con::errorf("Projectile::onAdd - Fail - Not datablock");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (isServerObject())
|
if (isServerObject())
|
||||||
{
|
{
|
||||||
ShapeBase* ptr;
|
ShapeBase* ptr;
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,12 @@ bool VehicleBlocker::onAdd()
|
||||||
|
|
||||||
mObjBox.minExtents.set(-mDimensions.x, -mDimensions.y, 0);
|
mObjBox.minExtents.set(-mDimensions.x, -mDimensions.y, 0);
|
||||||
mObjBox.maxExtents.set( mDimensions.x, mDimensions.y, mDimensions.z);
|
mObjBox.maxExtents.set( mDimensions.x, mDimensions.y, mDimensions.z);
|
||||||
|
if( !mObjBox.isValidBox() )
|
||||||
|
{
|
||||||
|
Con::errorf("VehicleBlocker::onAdd - Fail - No valid object box");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
resetWorldBox();
|
resetWorldBox();
|
||||||
setRenderTransform(mObjToWorld);
|
setRenderTransform(mObjToWorld);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,12 @@ CreateUnitTest(TestsJournalRecordAndPlayback, "Journal/Basic")
|
||||||
// Initialize journal recording and fire off some events...
|
// Initialize journal recording and fire off some events...
|
||||||
Journal::Record("test.jrn");
|
Journal::Record("test.jrn");
|
||||||
|
|
||||||
|
if( !Journal::IsRecording() )
|
||||||
|
{
|
||||||
|
test(false, "Fail");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
testEvent.trigger(16);
|
testEvent.trigger(16);
|
||||||
testEvent.trigger(17);
|
testEvent.trigger(17);
|
||||||
testEvent.trigger(18);
|
testEvent.trigger(18);
|
||||||
|
|
@ -132,6 +138,12 @@ CreateUnitTest(TestsJournalDynamicSignals, "Journal/DynamicSignals")
|
||||||
// Initialize journal recording and fire off some events...
|
// Initialize journal recording and fire off some events...
|
||||||
Journal::Record("test.jrn");
|
Journal::Record("test.jrn");
|
||||||
|
|
||||||
|
if( !Journal::IsRecording() )
|
||||||
|
{
|
||||||
|
test(false, "Fail");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
testEvent.trigger(1);
|
testEvent.trigger(1);
|
||||||
dynamicA->trigger(8, 100);
|
dynamicA->trigger(8, 100);
|
||||||
testEvent.trigger(2);
|
testEvent.trigger(2);
|
||||||
|
|
|
||||||
|
|
@ -52,5 +52,7 @@ CreateUnitTest(TestingProcess, "Journal/Process")
|
||||||
for(S32 i=0; i<30; i++)
|
for(S32 i=0; i<30; i++)
|
||||||
test(Process::processEvents(), "Should quit after 30 ProcessEvents() calls - not before!");
|
test(Process::processEvents(), "Should quit after 30 ProcessEvents() calls - not before!");
|
||||||
test(!Process::processEvents(), "Should quit after the 30th ProcessEvent() call!");
|
test(!Process::processEvents(), "Should quit after the 30th ProcessEvent() call!");
|
||||||
|
|
||||||
|
Process::remove(this, &TestingProcess::process);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -98,6 +98,9 @@ static S32 QSORT_CALLBACK compareEntries(const void* a,const void* b)
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool GuiInspectorDynamicGroup::inspectGroup()
|
bool GuiInspectorDynamicGroup::inspectGroup()
|
||||||
{
|
{
|
||||||
|
if( !mParent )
|
||||||
|
return false;
|
||||||
|
|
||||||
// clear the first responder if it's set
|
// clear the first responder if it's set
|
||||||
mStack->clearFirstResponder();
|
mStack->clearFirstResponder();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -455,7 +455,7 @@ void GuiInspectorField::setInspectorProfile()
|
||||||
{
|
{
|
||||||
GuiControlProfile *profile = NULL;
|
GuiControlProfile *profile = NULL;
|
||||||
|
|
||||||
if( mInspector->getNumInspectObjects() > 1 )
|
if( mInspector && (mInspector->getNumInspectObjects() > 1) )
|
||||||
{
|
{
|
||||||
if( !hasSameValueInAllObjects() )
|
if( !hasSameValueInAllObjects() )
|
||||||
Sim::findObject( "GuiInspectorMultiFieldDifferentProfile", profile );
|
Sim::findObject( "GuiInspectorMultiFieldDifferentProfile", profile );
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ void GuiInspectorGroup::clearFields()
|
||||||
bool GuiInspectorGroup::inspectGroup()
|
bool GuiInspectorGroup::inspectGroup()
|
||||||
{
|
{
|
||||||
// We can't inspect a group without a target!
|
// We can't inspect a group without a target!
|
||||||
if( !mParent->getNumInspectObjects() )
|
if( !mParent || !mParent->getNumInspectObjects() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// to prevent crazy resizing, we'll just freeze our stack for a sec..
|
// to prevent crazy resizing, we'll just freeze our stack for a sec..
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,12 @@ GuiInspectorVariableField::~GuiInspectorVariableField()
|
||||||
|
|
||||||
bool GuiInspectorVariableField::onAdd()
|
bool GuiInspectorVariableField::onAdd()
|
||||||
{
|
{
|
||||||
|
if( !mInspector )
|
||||||
|
{
|
||||||
|
Con::errorf("GuiInspectorVariableField::onAdd - Fail - No inspector");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
setInspectorProfile();
|
setInspectorProfile();
|
||||||
|
|
||||||
// Hack: skip our immediate parent
|
// Hack: skip our immediate parent
|
||||||
|
|
|
||||||
|
|
@ -87,8 +87,8 @@ CreateUnitTest( TestTCPRequest, "Platform/Net/TCPRequest")
|
||||||
|
|
||||||
// Open a TCP connection to garagegames.com
|
// Open a TCP connection to garagegames.com
|
||||||
mSocket = Net::openConnectTo("ip:72.246.107.193:80");
|
mSocket = Net::openConnectTo("ip:72.246.107.193:80");
|
||||||
|
U32 limit = Platform::getRealMilliseconds() + (5*1000);
|
||||||
while(Process::processEvents())
|
while(Process::processEvents() && (Platform::getRealMilliseconds() < limit) )
|
||||||
;
|
;
|
||||||
|
|
||||||
// Unhook from the signals.
|
// Unhook from the signals.
|
||||||
|
|
@ -176,6 +176,12 @@ CreateUnitTest( TestTCPRequestJournal, "Platform/Net/JournalTCPRequest")
|
||||||
{
|
{
|
||||||
Journal::Record("journalTCP.jrn");
|
Journal::Record("journalTCP.jrn");
|
||||||
|
|
||||||
|
if( !Journal::IsRecording() )
|
||||||
|
{
|
||||||
|
test(0, "Failed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
makeRequest();
|
makeRequest();
|
||||||
|
|
||||||
S32 bytesRead = mDataRecved;
|
S32 bytesRead = mDataRecved;
|
||||||
|
|
|
||||||
|
|
@ -605,6 +605,7 @@ bool SceneManager::addObjectToScene( SceneObject* object )
|
||||||
|
|
||||||
void SceneManager::removeObjectFromScene( SceneObject* obj )
|
void SceneManager::removeObjectFromScene( SceneObject* obj )
|
||||||
{
|
{
|
||||||
|
AssertFatal( obj, "SceneManager::removeObjectFromScene - Object is not declared" );
|
||||||
AssertFatal( obj->getSceneManager() == this, "SceneManager::removeObjectFromScene - Object not part of SceneManager" );
|
AssertFatal( obj->getSceneManager() == this, "SceneManager::removeObjectFromScene - Object not part of SceneManager" );
|
||||||
|
|
||||||
// Notify the object.
|
// Notify the object.
|
||||||
|
|
@ -613,7 +614,8 @@ void SceneManager::removeObjectFromScene( SceneObject* obj )
|
||||||
|
|
||||||
// Remove the object from the container.
|
// Remove the object from the container.
|
||||||
|
|
||||||
getContainer()->removeObject( obj );
|
if( getContainer() )
|
||||||
|
getContainer()->removeObject( obj );
|
||||||
|
|
||||||
// Remove the object from the zoning system.
|
// Remove the object from the zoning system.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -434,7 +434,7 @@ class SFXSource : public SimGroup
|
||||||
virtual bool isVirtualized() const { return false; }
|
virtual bool isVirtualized() const { return false; }
|
||||||
|
|
||||||
/// Returns true if this is a looping source.
|
/// Returns true if this is a looping source.
|
||||||
bool isLooping() const { return mDescription->mIsLooping; }
|
bool isLooping() const { return mDescription.isValid() && mDescription->mIsLooping; }
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -686,7 +686,8 @@ void SFXSystem::_onRemoveSource( SFXSource* source )
|
||||||
if( dynamic_cast< SFXSound* >( source ) )
|
if( dynamic_cast< SFXSound* >( source ) )
|
||||||
{
|
{
|
||||||
SFXSoundVector::iterator iter = find( mSounds.begin(), mSounds.end(), static_cast< SFXSound* >( source ) );
|
SFXSoundVector::iterator iter = find( mSounds.begin(), mSounds.end(), static_cast< SFXSound* >( source ) );
|
||||||
mSounds.erase_fast( iter );
|
if( iter != mSounds.end() )
|
||||||
|
mSounds.erase_fast( iter );
|
||||||
|
|
||||||
mStatNumSounds = mSounds.size();
|
mStatNumSounds = mSounds.size();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@
|
||||||
|
|
||||||
#include "unit/test.h"
|
#include "unit/test.h"
|
||||||
|
|
||||||
|
#include "core/util/journal/process.h"
|
||||||
|
|
||||||
|
|
||||||
namespace UnitTesting
|
namespace UnitTesting
|
||||||
{
|
{
|
||||||
|
|
@ -275,6 +277,9 @@ bool TestRun::test(const char* module, bool skipInteractive)
|
||||||
|
|
||||||
Platform::setCurrentDirectory(cwdSave);
|
Platform::setCurrentDirectory(cwdSave);
|
||||||
|
|
||||||
|
// sanity check for avoid Process::requestShutdown() called on some tests
|
||||||
|
Process::processEvents();
|
||||||
|
|
||||||
// And indicate our failure situation in the return value.
|
// And indicate our failure situation in the return value.
|
||||||
return !_failureCount;
|
return !_failureCount;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,9 +91,17 @@ public:
|
||||||
// for this functionality later
|
// for this functionality later
|
||||||
void unit_test( UnitTest *test )
|
void unit_test( UnitTest *test )
|
||||||
{
|
{
|
||||||
|
AssertFatal(test, "CachedInterfaceExampleComponent::unit_test - NULL UnitTest");
|
||||||
|
|
||||||
|
if( !test )
|
||||||
|
return;
|
||||||
|
|
||||||
test->test( mpU32 != NULL, "Pointer to dependent interface is NULL" );
|
test->test( mpU32 != NULL, "Pointer to dependent interface is NULL" );
|
||||||
test->test( *(*mpU32) & ( 1 << 24 ), "Pointer to interface data is bogus." );
|
if( mpU32 )
|
||||||
test->test( *(*mpU32) != *mMyId, "Two of me have the same ID, bad!" );
|
{
|
||||||
|
test->test( *(*mpU32) & ( 1 << 24 ), "Pointer to interface data is bogus." );
|
||||||
|
test->test( *(*mpU32) != *mMyId, "Two of me have the same ID, bad!" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -130,13 +138,16 @@ CreateUnitTest(TestComponentInterfacing, "Components/Composition")
|
||||||
test( componentB->getOwner() == testComponent, "testComponent did not properly set the mOwner field of componentB to NULL." );
|
test( componentB->getOwner() == testComponent, "testComponent did not properly set the mOwner field of componentB to NULL." );
|
||||||
|
|
||||||
// Register the object with the simulation, kicking off the interface registration
|
// Register the object with the simulation, kicking off the interface registration
|
||||||
test( testComponent->registerObject(), "Failed to register testComponent" );
|
const bool registered = testComponent->registerObject();
|
||||||
|
test( registered, "Failed to register testComponent" );
|
||||||
|
|
||||||
// Interface tests
|
// Interface tests
|
||||||
componentA->unit_test( this );
|
if( registered )
|
||||||
componentB->unit_test( this );
|
{
|
||||||
|
componentA->unit_test( this );
|
||||||
testComponent->deleteObject();
|
componentB->unit_test( this );
|
||||||
|
testComponent->deleteObject();
|
||||||
|
}
|
||||||
|
|
||||||
test( m.check(), "Component composition test leaked memory." );
|
test( m.check(), "Component composition test leaked memory." );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue