From 4ea5ac86594d8beaf51e65dd1600824329ff8c19 Mon Sep 17 00:00:00 2001 From: Daniel Buckmaster Date: Sat, 7 Feb 2015 14:07:30 +1100 Subject: [PATCH 1/5] Default navigation module on in CMake --- Tools/CMake/modules/module_navigation.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Tools/CMake/modules/module_navigation.cmake b/Tools/CMake/modules/module_navigation.cmake index e4e123083..394268214 100644 --- a/Tools/CMake/modules/module_navigation.cmake +++ b/Tools/CMake/modules/module_navigation.cmake @@ -21,8 +21,7 @@ # ----------------------------------------------------------------------------- # Navigation module -option(TORQUE_NAVIGATION "Enable Navigation module" OFF) -#mark_as_advanced(TORQUE_NAVIGATION) +option(TORQUE_NAVIGATION "Enable Navigation module" ON) if(TORQUE_NAVIGATION) addDef( "TORQUE_NAVIGATION_ENABLED" ) From 57698599e07a86bbbde9364421f7e6c645abb5ae Mon Sep 17 00:00:00 2001 From: LuisAntonRebollo Date: Sat, 7 Feb 2015 18:37:58 +0100 Subject: [PATCH 2/5] Add missing and --- Engine/source/T3D/aiPlayer.cpp | 2 ++ Engine/source/navigation/navPath.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/Engine/source/T3D/aiPlayer.cpp b/Engine/source/T3D/aiPlayer.cpp index 4a8e3b955..577422674 100644 --- a/Engine/source/T3D/aiPlayer.cpp +++ b/Engine/source/T3D/aiPlayer.cpp @@ -28,6 +28,8 @@ #include "T3D/gameBase/moveManager.h" #include "console/engineAPI.h" +#include + static U32 sAIPlayerLoSMask = TerrainObjectType | StaticShapeObjectType | StaticObjectType; IMPLEMENT_CO_NETOBJECT_V1(AIPlayer); diff --git a/Engine/source/navigation/navPath.cpp b/Engine/source/navigation/navPath.cpp index dfc3e1512..72ce494c7 100644 --- a/Engine/source/navigation/navPath.cpp +++ b/Engine/source/navigation/navPath.cpp @@ -37,6 +37,7 @@ #include "math/mathIO.h" #include +#include extern bool gEditingMission; From f821898857f536a9fc2d8017735c81af5cd0018b Mon Sep 17 00:00:00 2001 From: Daniel Buckmaster Date: Sun, 8 Feb 2015 17:57:27 +1100 Subject: [PATCH 3/5] Also turn unit tests on --- Tools/CMake/modules/module_testing.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tools/CMake/modules/module_testing.cmake b/Tools/CMake/modules/module_testing.cmake index e9fe754a6..917b00622 100644 --- a/Tools/CMake/modules/module_testing.cmake +++ b/Tools/CMake/modules/module_testing.cmake @@ -20,7 +20,7 @@ # IN THE SOFTWARE. # ----------------------------------------------------------------------------- -option(TORQUE_TESTING "Enable unit test module" OFF) +option(TORQUE_TESTING "Enable unit test module" ON) mark_as_advanced(TORQUE_TESTING) if(TORQUE_TESTING) @@ -35,4 +35,4 @@ if(TORQUE_TESTING) # Add include paths addInclude( "${libDir}/gtest/fused-src/" ) -endif() \ No newline at end of file +endif() From a2ca161024c9b900e2b0f41eb90b406c62527cf0 Mon Sep 17 00:00:00 2001 From: Daniel Buckmaster Date: Sun, 8 Feb 2015 20:10:00 +1100 Subject: [PATCH 4/5] Defaults in project manager 2.2 --- projects.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects.xml b/projects.xml index a02f993e1..18ace6299 100644 --- a/projects.xml +++ b/projects.xml @@ -34,8 +34,8 @@ Here are some examples: Razer Hydra Controller Oculus VR Devices Web Deployment - Recast Navigation - Unit testing + Recast Navigation + Unit testing Torque Physics PhysX 2.8 Physics Library From ec06dd78f9aa7f9a674ed9146e0721656397f2c5 Mon Sep 17 00:00:00 2001 From: Daniel Buckmaster Date: Wed, 11 Feb 2015 10:17:19 +1100 Subject: [PATCH 5/5] Fix unit tests. --- Engine/source/math/test/mMatrixTest.cpp | 4 +- Engine/source/platform/test/netTest.cpp | 224 +++++++++--------- .../platform/test/platformFileIOTest.cpp | 4 +- .../platform/test/platformTimerTest.cpp | 34 +-- Engine/source/platform/test/profilerTest.cpp | 4 +- 5 files changed, 138 insertions(+), 132 deletions(-) diff --git a/Engine/source/math/test/mMatrixTest.cpp b/Engine/source/math/test/mMatrixTest.cpp index c582c0932..2efa04ffd 100644 --- a/Engine/source/math/test/mMatrixTest.cpp +++ b/Engine/source/math/test/mMatrixTest.cpp @@ -30,7 +30,7 @@ extern void default_matF_x_matF_C(const F32 *a, const F32 *b, F32 *mresult); extern void mInstallLibrary_ASM(); // If we're x86 and not Mac, then include these. There's probably a better way to do this. -#if defined(TORQUE_CPU_X86) && !defined(TORQUE_OS_MAC) +#if defined(WIN32) && defined(TORQUE_CPU_X86) extern "C" void Athlon_MatrixF_x_MatrixF(const F32 *matA, const F32 *matB, F32 *result); extern "C" void SSE_MatrixF_x_MatrixF(const F32 *matA, const F32 *matB, F32 *result); #endif @@ -55,7 +55,7 @@ TEST(MatrixF, MultiplyImplmentations) // C will be the baseline default_matF_x_matF_C(m1, m2, mrC); -#if defined(TORQUE_CPU_X86) && !defined(TORQUE_OS_MAC) +#if defined(WIN32) && defined(TORQUE_CPU_X86) // Check the CPU info U32 cpuProperties = Platform::SystemInfo.processor.properties; bool same; diff --git a/Engine/source/platform/test/netTest.cpp b/Engine/source/platform/test/netTest.cpp index 63c38229a..3765a79c2 100644 --- a/Engine/source/platform/test/netTest.cpp +++ b/Engine/source/platform/test/netTest.cpp @@ -25,57 +25,59 @@ #include "platform/platformNet.h" #include "core/util/journal/process.h" +struct TcpHandle +{ + NetSocket mSocket; + S32 mDataReceived; + + void notify(NetSocket sock, U32 state) + { + // Only consider our own socket. + if(mSocket != sock) + return; + + // Ok - what's the state? We do some dumb responses to given states + // in order to fulfill the request. + if(state == Net::Connected) + { + U8 reqBuffer[] = { + "GET / HTTP/1.0\nUser-Agent: Torque/1.0\n\n" + }; + + Net::Error e = Net::sendtoSocket(mSocket, reqBuffer, sizeof(reqBuffer)); + + ASSERT_EQ(Net::NoError, e) + << "Got an error sending our HTTP request!"; + } + else + { + Process::requestShutdown(); + mSocket = NULL; + ASSERT_EQ(Net::Disconnected, state) + << "Ended with a network error!"; + } + } + + void receive(NetSocket sock, RawData incomingData) + { + // Only consider our own socket. + if(mSocket != sock) + return; + + mDataReceived += incomingData.size; + } +}; + TEST(Net, TCPRequest) { - struct handle - { - NetSocket mSocket; - S32 mDataReceived; - - void notify(NetSocket sock, U32 state) - { - // Only consider our own socket. - if(mSocket != sock) - return; - - // Ok - what's the state? We do some dumb responses to given states - // in order to fulfill the request. - if(state == Net::Connected) - { - U8 reqBuffer[] = { - "GET / HTTP/1.0\nUser-Agent: Torque/1.0\n\n" - }; - - Net::Error e = Net::sendtoSocket(mSocket, reqBuffer, sizeof(reqBuffer)); - - ASSERT_EQ(Net::NoError, e) - << "Got an error sending our HTTP request!"; - } - else - { - Process::requestShutdown(); - mSocket = NULL; - ASSERT_EQ(Net::Disconnected, state) - << "Ended with a network error!"; - } - } - - void receive(NetSocket sock, RawData incomingData) - { - // Only consider our own socket. - if(mSocket != sock) - return; - - mDataReceived += incomingData.size; - } - } handler; + TcpHandle handler; handler.mSocket = InvalidSocket; handler.mDataReceived = 0; // Hook into the signals. - Net::smConnectionNotify. notify(&handler, &handle::notify); - Net::smConnectionReceive.notify(&handler, &handle::receive); + Net::smConnectionNotify .notify(&handler, &TcpHandle::notify); + Net::smConnectionReceive.notify(&handler, &TcpHandle::receive); // Open a TCP connection to garagegames.com handler.mSocket = Net::openConnectTo("72.246.107.193:80"); @@ -83,79 +85,81 @@ TEST(Net, TCPRequest) while(Process::processEvents() && (Platform::getRealMilliseconds() < limit) ) {} // Unhook from the signals. - Net::smConnectionNotify. remove(&handler, &handle::notify); - Net::smConnectionReceive.remove(&handler, &handle::receive); + Net::smConnectionNotify .remove(&handler, &TcpHandle::notify); + Net::smConnectionReceive.remove(&handler, &TcpHandle::receive); EXPECT_GT(handler.mDataReceived, 0) << "Didn't get any data back!"; } +struct JournalHandle +{ + NetSocket mSocket; + S32 mDataReceived; + + void notify(NetSocket sock, U32 state) + { + // Only consider our own socket. + if(mSocket != sock) + return; + + // Ok - what's the state? We do some dumb responses to given states + // in order to fulfill the request. + if(state == Net::Connected) + { + U8 reqBuffer[] = { + "GET / HTTP/1.0\nUser-Agent: Torque/1.0\n\n" + }; + + Net::Error e = Net::sendtoSocket(mSocket, reqBuffer, sizeof(reqBuffer)); + + ASSERT_EQ(Net::NoError, e) + << "Got an error sending our HTTP request!"; + } + else + { + Process::requestShutdown(); + mSocket = NULL; + ASSERT_EQ(Net::Disconnected, state) + << "Ended with a network error!"; + } + } + + void receive(NetSocket sock, RawData incomingData) + { + // Only consider our own socket. + if(mSocket != sock) + return; + mDataReceived += incomingData.size; + } + + void makeRequest() + { + mSocket = InvalidSocket; + mDataReceived = 0; + + // Hook into the signals. + Net::smConnectionNotify .notify(this, &JournalHandle::notify); + Net::smConnectionReceive.notify(this, &JournalHandle::receive); + + // Open a TCP connection to garagegames.com + mSocket = Net::openConnectTo("72.246.107.193:80"); + + // Let the callbacks enable things to process. + while(Process::processEvents()) {} + + // Unhook from the signals. + Net::smConnectionNotify .remove(this, &JournalHandle::notify); + Net::smConnectionReceive.remove(this, &JournalHandle::receive); + + EXPECT_GT(mDataReceived, 0) + << "Didn't get any data back!"; + } +}; + TEST(Net, JournalTCPRequest) { - struct handle - { - NetSocket mSocket; - S32 mDataReceived; - - void notify(NetSocket sock, U32 state) - { - // Only consider our own socket. - if(mSocket != sock) - return; - - // Ok - what's the state? We do some dumb responses to given states - // in order to fulfill the request. - if(state == Net::Connected) - { - U8 reqBuffer[] = { - "GET / HTTP/1.0\nUser-Agent: Torque/1.0\n\n" - }; - - Net::Error e = Net::sendtoSocket(mSocket, reqBuffer, sizeof(reqBuffer)); - - ASSERT_EQ(Net::NoError, e) - << "Got an error sending our HTTP request!"; - } - else - { - Process::requestShutdown(); - mSocket = NULL; - ASSERT_EQ(Net::Disconnected, state) - << "Ended with a network error!"; - } - } - - void receive(NetSocket sock, RawData incomingData) - { - // Only consider our own socket. - if(mSocket != sock) - return; - mDataReceived += incomingData.size; - } - - void makeRequest() - { - mSocket = InvalidSocket; - mDataReceived = 0; - - // Hook into the signals. - Net::smConnectionNotify. notify(this, &handle::notify); - Net::smConnectionReceive.notify(this, &handle::receive); - - // Open a TCP connection to garagegames.com - mSocket = Net::openConnectTo("72.246.107.193:80"); - - // Let the callbacks enable things to process. - while(Process::processEvents()) {} - - // Unhook from the signals. - Net::smConnectionNotify. remove(this, &handle::notify); - Net::smConnectionReceive.remove(this, &handle::receive); - - EXPECT_GT(mDataReceived, 0) - << "Didn't get any data back!"; - } - } handler; + JournalHandle handler; Journal::Record("journalTCP.jrn"); ASSERT_TRUE(Journal::IsRecording()); diff --git a/Engine/source/platform/test/platformFileIOTest.cpp b/Engine/source/platform/test/platformFileIOTest.cpp index c27278431..198baca4f 100644 --- a/Engine/source/platform/test/platformFileIOTest.cpp +++ b/Engine/source/platform/test/platformFileIOTest.cpp @@ -97,8 +97,8 @@ TEST(File, TouchAndTime) << "Somehow failed to delete our test file."; }; -// Mac has no implementations for these functions, so we 'def it out for now. -#ifndef __MACOSX__ +// Mac/Linux have no implementations for these functions, so we 'def it out for now. +#ifdef WIN32 TEST(Platform, Volumes) { Vector names; diff --git a/Engine/source/platform/test/platformTimerTest.cpp b/Engine/source/platform/test/platformTimerTest.cpp index c8f4db09f..9dda0549b 100644 --- a/Engine/source/platform/test/platformTimerTest.cpp +++ b/Engine/source/platform/test/platformTimerTest.cpp @@ -44,24 +44,26 @@ TEST(Platform, Sleep) << "We didn't sleep at least as long as we requested!"; }; +struct handle +{ + S32 mElapsedTime; + S32 mNumberCalls; + + handle() : mElapsedTime(0), mNumberCalls(0) {} + + void timeEvent(S32 timeDelta) + { + mElapsedTime += timeDelta; + mNumberCalls++; + + if(mElapsedTime >= 1000) + Process::requestShutdown(); + } +}; + TEST(TimeManager, BasicAPI) { - struct handle - { - S32 mElapsedTime; - S32 mNumberCalls; - - void timeEvent(S32 timeDelta) - { - mElapsedTime += timeDelta; - mNumberCalls++; - - if(mElapsedTime >= 1000) - Process::requestShutdown(); - } - } handler; - - handler.mElapsedTime = handler.mNumberCalls = 0; + handle handler; // Initialize the time manager... TimeManager time; diff --git a/Engine/source/platform/test/profilerTest.cpp b/Engine/source/platform/test/profilerTest.cpp index 64ccc36d3..e82e5384f 100644 --- a/Engine/source/platform/test/profilerTest.cpp +++ b/Engine/source/platform/test/profilerTest.cpp @@ -33,10 +33,10 @@ TEST(Profiler, ProfileStartEnd) // Do work. if(true) { - PROFILE_END(ProfileStartEndTest); + PROFILE_END(); return; } - PROFILE_END(ProfileStartEndTest); + PROFILE_END(); } TEST(Profiler, ProfileScope)