208 lines
7 KiB
C++
208 lines
7 KiB
C++
|
|
#include "stdafx.h"
|
|||
|
|
#include "DNUserSession.h"
|
|||
|
|
#include "DnBubbleSystem.h"
|
|||
|
|
#include "DnObserverEventMessage.h"
|
|||
|
|
#include "EtResourceMng.h"
|
|||
|
|
#include "DnPlayerActor.h"
|
|||
|
|
#include "DnGameRoom.h"
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if !defined( _FINAL_BUILD ) && !defined (__COVERITY__)
|
|||
|
|
|
|||
|
|
using namespace BubbleSystem;
|
|||
|
|
using namespace boost;
|
|||
|
|
|
|||
|
|
class BubbleSystem_unittest:public testing::Test
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
static CDnBubbleSystem* s_pBubbleSystem;
|
|||
|
|
static CEtResourceMng* m_pResMng;
|
|||
|
|
static CDnPlayerActor* s_pPlayerActor;
|
|||
|
|
static CDNGameRoom* s_pRoom;
|
|||
|
|
|
|||
|
|
protected:
|
|||
|
|
virtual void SetUp()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
virtual void TearDown()
|
|||
|
|
{
|
|||
|
|
s_pBubbleSystem->RemoveAllBubbles();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
static void SetUpTestCase( void )
|
|||
|
|
{
|
|||
|
|
m_pResMng = new CEtResourceMng( false, true );
|
|||
|
|
m_pResMng->AddResourcePath( "r:\\gameres\\resource\\ext" );
|
|||
|
|
|
|||
|
|
CDnTableDB::GetInstance().CreateInstance();
|
|||
|
|
CDnTableDB::GetInstance().Initialize();
|
|||
|
|
|
|||
|
|
s_pBubbleSystem = new CDnBubbleSystem;
|
|||
|
|
|
|||
|
|
//// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>丮<EFBFBD><E4B8AE> <20>켱 <20><><EFBFBD><EFBFBD> ex <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD> ó<><C3B3><EFBFBD>Ѵ<EFBFBD>.
|
|||
|
|
//vector<int> vlJobHistory;
|
|||
|
|
//vlJobHistory.push_back( 4 ); // Ŭ<><C5AC><EFBFBD><EFBFBD>
|
|||
|
|
//vlJobHistory.push_back( 20 ); // <20>ȶ<EFBFBD><C8B6><EFBFBD>
|
|||
|
|
////vlJobHistory.push_back( ); // <20><><EFBFBD><EFBFBD> 2<><32> <20><><EFBFBD><EFBFBD> <20>Ƿ<F0B8A3B9> <20>ȶ<EFBFBD><C8B6><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵٰ<D1B4> <20><><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD> <20><><EFBFBD>̺<EFBFBD> <20>۾<EFBFBD> <20>ӽ÷<D3BD> <20>ص<EFBFBD>.
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD> CDnMonsterActor <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
MAGAReqRoomID Packet;
|
|||
|
|
memset( &Packet, 0, sizeof(Packet) );
|
|||
|
|
s_pRoom = new CDNGameRoom( NULL, 0, &Packet );
|
|||
|
|
|
|||
|
|
s_pPlayerActor = new CDnPlayerActor( s_pRoom, 1 );
|
|||
|
|
s_pPlayerActor->SetHP( 100 );
|
|||
|
|
s_pBubbleSystem->Initialize( s_pPlayerActor->GetActorHandle() );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
static void TearDownTestCase( void )
|
|||
|
|
{
|
|||
|
|
delete s_pBubbleSystem;
|
|||
|
|
delete s_pPlayerActor;
|
|||
|
|
delete s_pRoom;
|
|||
|
|
|
|||
|
|
CDnTableDB::GetInstance().Finalize();
|
|||
|
|
|
|||
|
|
delete m_pResMng;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
CDnBubbleSystem* BubbleSystem_unittest::s_pBubbleSystem = NULL;
|
|||
|
|
CEtResourceMng* BubbleSystem_unittest::m_pResMng = NULL;
|
|||
|
|
CDnPlayerActor* BubbleSystem_unittest::s_pPlayerActor = NULL;
|
|||
|
|
CDNGameRoom* BubbleSystem_unittest::s_pRoom = NULL;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><EFBFBD><DEBD><EFBFBD> ó<><C3B3> <20><EFBFBD>Ʈ.
|
|||
|
|
TEST_F( BubbleSystem_unittest, BLOCK_SUCCESS_TEST )
|
|||
|
|
{
|
|||
|
|
shared_ptr<IDnObserverNotifyEvent> pNotifyEvent( new CDnBlockSuccessMessage );
|
|||
|
|
shared_ptr<CDnBlockSuccessMessage> pBlockSuccessMessage = shared_polymorphic_downcast<CDnBlockSuccessMessage>( pNotifyEvent );
|
|||
|
|
|
|||
|
|
pBlockSuccessMessage->SetSkillID( 3301 );
|
|||
|
|
s_pBubbleSystem->OnEvent( pNotifyEvent );
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20>ϳ<EFBFBD> <20>߰<EFBFBD> <20><>.
|
|||
|
|
EXPECT_EQ( s_pBubbleSystem->GetBubbleCountByTypeID( 100 ), 1 );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>̻<EFBFBD><CCBB><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><D7BF><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ҹ<EFBFBD><D2B8>ϴ<EFBFBD> <20><>ų <20><><EFBFBD><EFBFBD> <20><EFBFBD>Ʈ.
|
|||
|
|
TEST_F( BubbleSystem_unittest, USE_SKILL_TEST )
|
|||
|
|
{
|
|||
|
|
shared_ptr<IDnObserverNotifyEvent> pNotifyEvent( new CDnUseSkillMessage );
|
|||
|
|
shared_ptr<CDnUseSkillMessage> pSkillUseEvent = shared_polymorphic_downcast<CDnUseSkillMessage>( pNotifyEvent );
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> <20><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD> <20><><EFBFBD><EFBFBD> 100<30><30> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 10<31><30> <20>ʿ<EFBFBD><CABF>ϵ<EFBFBD><CFB5><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
|
|||
|
|
// ó<><C3B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ų <20><><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD> <20><>ġ<EFBFBD>Ǵ<EFBFBD> <20>̺<EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD> <20>ƹ<EFBFBD> <20>ϵ<EFBFBD> <20>Ͼ<CFBE><EEB3AA> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
pSkillUseEvent->SetSkillID( 3028 ); // <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ο<EFBFBD>
|
|||
|
|
s_pBubbleSystem->OnEvent( pNotifyEvent );
|
|||
|
|
|
|||
|
|
// 100<30><30> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 5<><35> <20>߰<EFBFBD><DFB0>س<EFBFBD><D8B3><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
CDnBubbleSystem::S_CREATE_BUBBLE Info;
|
|||
|
|
Info.iBubbleTypeID = 100;
|
|||
|
|
Info.fDurationTime = 5.0f;
|
|||
|
|
s_pBubbleSystem->AddBubble( Info );
|
|||
|
|
s_pBubbleSystem->AddBubble( Info );
|
|||
|
|
s_pBubbleSystem->AddBubble( Info );
|
|||
|
|
s_pBubbleSystem->AddBubble( Info );
|
|||
|
|
s_pBubbleSystem->AddBubble( Info );
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD> <20><>ġ<EFBFBD>Ǵ<EFBFBD> <20><>ų<EFBFBD><C5B3> <20><><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD> <20>߰<EFBFBD> <20>Ǿ<EFBFBD> <20>ִ´<D6B4><C2B4><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ҹ<EFBFBD> <20>Ǹ<EFBFBD> <20><>ų <20><><EFBFBD><EFBFBD>.
|
|||
|
|
pSkillUseEvent->SetSkillID( 3302 ); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
|
s_pBubbleSystem->OnEvent( pNotifyEvent );
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ƿ<EFBFBD> 5<><35><EFBFBD><EFBFBD> <20>״<EFBFBD><D7B4><EFBFBD> <20><><EFBFBD>´<EFBFBD>.
|
|||
|
|
EXPECT_EQ( s_pBubbleSystem->GetBubbleCountByTypeID( 100 ), 5 );
|
|||
|
|
|
|||
|
|
// 100<30><30> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 5<><35> <20><> <20>߰<EFBFBD><DFB0>ؼ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ų <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
// 100<30><30> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 5<><35> <20>߰<EFBFBD><DFB0>س<EFBFBD><D8B3><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
s_pBubbleSystem->AddBubble( Info );
|
|||
|
|
s_pBubbleSystem->AddBubble( Info );
|
|||
|
|
s_pBubbleSystem->AddBubble( Info );
|
|||
|
|
s_pBubbleSystem->AddBubble( Info );
|
|||
|
|
s_pBubbleSystem->AddBubble( Info );
|
|||
|
|
|
|||
|
|
pSkillUseEvent->SetSkillID( 3302 ); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
|
s_pBubbleSystem->OnEvent( pNotifyEvent );
|
|||
|
|
EXPECT_EQ( s_pBubbleSystem->GetBubbleCountByTypeID( 100 ), 0 );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Ư<><C6AF> <20><>ų<EFBFBD><C5B3> <20><><EFBFBD><EFBFBD> <20>ִ<EFBFBD> <20><><EFBFBD>¿<EFBFBD><C2BF><EFBFBD> <20>ٸ<EFBFBD> <20><>ų<EFBFBD><C5B3> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ȹ<><C8B9><EFBFBD>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><EFBFBD>Ʈ,
|
|||
|
|
TEST_F( BubbleSystem_unittest, OWN_THIS_SKILL_TEST )
|
|||
|
|
{
|
|||
|
|
// 3301 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> EX <20><> ȹ<><C8B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> 3021 <20><><EFBFBD><EFBFBD> <20><>ų<EFBFBD><C5B3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> Ư<><C6AF> <20><><EFBFBD><EFBFBD> <20>߰<EFBFBD>.
|
|||
|
|
shared_ptr<IDnObserverNotifyEvent> pNotifyEvent( new CDnBlockSuccessMessage );
|
|||
|
|
shared_ptr<CDnBlockSuccessMessage> pBlockSuccessMessage = shared_polymorphic_downcast<CDnBlockSuccessMessage>( pNotifyEvent );
|
|||
|
|
|
|||
|
|
// <20>׳<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>. <20>ƹ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
pBlockSuccessMessage->SetSkillID( 3021 );
|
|||
|
|
s_pBubbleSystem->OnEvent( pNotifyEvent );
|
|||
|
|
EXPECT_EQ( s_pBubbleSystem->GetBubbleCountByTypeID( 100 ), 0 );
|
|||
|
|
|
|||
|
|
// 3301 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> EX <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
// 100<30><30> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ȹ<><C8B9><EFBFBD>Ѵ<EFBFBD>.
|
|||
|
|
s_pPlayerActor->MASkillUser::AddSkill( 3301, 1, CDnSkill::PVE );
|
|||
|
|
s_pBubbleSystem->OnEvent( pNotifyEvent );
|
|||
|
|
EXPECT_EQ( s_pBubbleSystem->GetBubbleCountByTypeID( 100 ), 1 );
|
|||
|
|
|
|||
|
|
// 3301 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> EX <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20>и<EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
pNotifyEvent.reset( new CDnParringSuccessMessage );
|
|||
|
|
shared_ptr<CDnParringSuccessMessage> pParringSuccessMessage = shared_polymorphic_downcast<CDnParringSuccessMessage>( pNotifyEvent );
|
|||
|
|
pParringSuccessMessage->SetSkillID( 3221 ); // <20><><EFBFBD>Ľ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>̽<EFBFBD>
|
|||
|
|
s_pBubbleSystem->OnEvent( pParringSuccessMessage );
|
|||
|
|
EXPECT_EQ( s_pBubbleSystem->GetBubbleCountByTypeID( 100 ), 2 );
|
|||
|
|
|
|||
|
|
// 3301 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> EX <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><>Ÿ<EFBFBD><C5B8> <20>и<EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
pNotifyEvent.reset( new CDnCooltimeParringSuccessMessage );
|
|||
|
|
shared_ptr<CDnCooltimeParringSuccessMessage> pCooltimeParringSuccessMessage = shared_polymorphic_downcast<CDnCooltimeParringSuccessMessage>( pNotifyEvent );
|
|||
|
|
pCooltimeParringSuccessMessage->SetSkillID( 3220 ); // <20><><EFBFBD><EFBFBD><EEB8AE> <20><><EFBFBD><EFBFBD>
|
|||
|
|
s_pBubbleSystem->OnEvent( pCooltimeParringSuccessMessage );
|
|||
|
|
EXPECT_EQ( s_pBubbleSystem->GetBubbleCountByTypeID( 100 ), 3 );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
// <20>߰<EFBFBD><DFB0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ð<EFBFBD> <20><><EFBFBD>μ<EFBFBD><CEBC><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>鼭 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD>Ʈ.
|
|||
|
|
TEST_F( BubbleSystem_unittest, BUBBLE_PROCESS_TEST )
|
|||
|
|
{
|
|||
|
|
CDnBubbleSystem::S_CREATE_BUBBLE Info;
|
|||
|
|
Info.iBubbleTypeID = 100;
|
|||
|
|
Info.fDurationTime = 3.0f;
|
|||
|
|
s_pBubbleSystem->AddBubble( Info );
|
|||
|
|
s_pBubbleSystem->AddBubble( Info );
|
|||
|
|
|
|||
|
|
Info.iBubbleTypeID = 101;
|
|||
|
|
s_pBubbleSystem->AddBubble( Info );
|
|||
|
|
Info.fDurationTime = 5.0f;
|
|||
|
|
s_pBubbleSystem->AddBubble( Info );
|
|||
|
|
Info.fDurationTime = 7.0f;
|
|||
|
|
s_pBubbleSystem->AddBubble( Info );
|
|||
|
|
|
|||
|
|
Info.iBubbleTypeID = 102;
|
|||
|
|
Info.fDurationTime = 3.0f;
|
|||
|
|
s_pBubbleSystem->AddBubble( Info );
|
|||
|
|
Info.fDurationTime = 4.0f;
|
|||
|
|
s_pBubbleSystem->AddBubble( Info );
|
|||
|
|
|
|||
|
|
// 10<31>ʰ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
LOCAL_TIME StartTime = timeGetTime();
|
|||
|
|
LOCAL_TIME PrevTime = 0;
|
|||
|
|
while( true )
|
|||
|
|
{
|
|||
|
|
LOCAL_TIME LocalTime = timeGetTime()-StartTime;
|
|||
|
|
float fDelta = float(StartTime - PrevTime) / 1000.0f;
|
|||
|
|
s_pBubbleSystem->Process( LocalTime, fDelta );
|
|||
|
|
if( 10000 < timeGetTime() - StartTime )
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
PrevTime = LocalTime;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
EXPECT_EQ( s_pBubbleSystem->GetBubbleCountByTypeID( 100 ), 0 );
|
|||
|
|
EXPECT_EQ( s_pBubbleSystem->GetBubbleCountByTypeID( 101 ), 0 );
|
|||
|
|
EXPECT_EQ( s_pBubbleSystem->GetBubbleCountByTypeID( 102 ), 0 );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endif // #if !defined( _FINAL_BUILD )
|