diff --git a/.gitignore b/.gitignore
index 19d3b331..252219c3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,38 @@
+# Directories to ignore
+bin
+Debug
+Release
+/NetService/src/test/testRunner
+/Client/CppTest
-/NetService/Debug
-/NetService/bin
-/vnoc/Debug
-/C:/Users/tengda/Documents/GitHub/vnoc/VNOC/VNOC.sdf
-/VNOC/VNOC.sdf
-/netservice/Debug
-/netservice/Release
\ No newline at end of file
+# Files to ignore
+*.sdf
+*.obj
+*.tlog
+*.user
+*.log
+*.res
+*.pch
+*.lastbuildstate
+*.idb
+*.ipch
+*.suo
+*.pdb
+*.manifest
+*.opensdf
+*.cache
+*.lib
+*.o
+*.aps
+*.unsuccessfulbuild
+tags
+cpptestresults.xml
+
+!libmysql.lib
+!mysqlclient.lib
+
+/NetService/libmysql.dll
+/NetService/NetService.zip
+/NetService/server.exe
+/NetService/.project
+/NetService/.cproject
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 00000000..6b6355eb
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "NetService/dependencies/libmysql"]
+ path = NetService/dependencies/libmysql
+ url = git://github.com/Tydus/libmysql
diff --git a/Client/Client/Client.vcxproj b/Client/Client/Client.vcxproj
new file mode 100644
index 00000000..55634362
--- /dev/null
+++ b/Client/Client/Client.vcxproj
@@ -0,0 +1,329 @@
+
+
+
+
+ CppTest
+ Win32
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+
+ {8E8644B5-86CF-4286-9276-8710E6EE974C}
+ Win32Proj
+ Client
+
+
+
+ Application
+ true
+ v110
+ Unicode
+
+
+ Application
+ true
+ v110
+ Unicode
+
+
+ Application
+ false
+ v110
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ include;../../ThirdLibs;$(IncludePath);
+ ../../ThirdLibs;$(LibraryPath)
+ ../Temp/
+
+
+ true
+ include;..\..\cppunit-1.12.1\include;../../ThirdLibs;$(IncludePath)
+ ..\..\cppunit-1.12.1\lib;../../ThirdLibs;$(LibraryPath)
+ ../Temp/
+
+
+ false
+ include;../../ThirdLibs;$(IncludePath)
+ ../../ThirdLibs;$(LibraryPath)
+ ../Temp/
+
+
+
+ NotUsing
+ Level3
+ Disabled
+ WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
+
+
+ Windows
+ true
+
+
+
+
+
+
+ postDispatch.bat $(Configuration) $(Platform)
+
+
+ prelink.bat $(Configuration) $(Platform)
+
+
+
+
+ NotUsing
+ Level3
+ Disabled
+ WIN32;_DEBUG;_WINDOWS;CPPTEST;CONSOLE;%(PreprocessorDefinitions)
+
+
+ Console
+ true
+ cppunitd.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+ postDispatch.bat $(Configuration) $(Platform)
+
+
+ prelink.bat $(Configuration) $(Platform)
+
+
+
+
+ Level3
+ NotUsing
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
+
+
+ Windows
+ true
+ true
+ true
+
+
+
+
+
+
+ postDispatch.bat $(Configuration) $(Platform)
+
+
+ prelink.bat $(Configuration) $(Platform)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Client/Client/Client.vcxproj.filters b/Client/Client/Client.vcxproj.filters
new file mode 100644
index 00000000..33966720
--- /dev/null
+++ b/Client/Client/Client.vcxproj.filters
@@ -0,0 +1,604 @@
+
+
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+ {d0789c3a-68a6-4c02-a7e6-d94306dde427}
+
+
+ {ee804ca1-3800-4eb0-9a6c-211e434327a1}
+
+
+ {9e05fbaf-f4de-42fa-80d0-60c1306a4391}
+
+
+ {aa9e61af-0ed6-4e9d-9162-c9c2905669be}
+
+
+ {1f0044bc-9b7a-4c6f-9437-72aec3e2dd27}
+
+
+ {90bc5d2c-09b6-44e9-9ee8-0cfd76455bee}
+
+
+ {42bbda5d-e16c-4491-83db-975d02aeac2a}
+
+
+ {c8315cb1-8874-40b5-8ce8-8613e0e9c98b}
+
+
+ {fc85c714-2cb6-4c08-8c01-5db94e706643}
+
+
+ {cdc4c050-f912-4fad-8f7f-630dd0450988}
+
+
+ {5c89666e-35a4-49e0-81ae-f16bcf0a90ca}
+
+
+ {61949cca-7673-4e66-b8dc-001242bd142b}
+
+
+ {902b6711-eb72-4a08-96d3-f4f28892bd9b}
+
+
+ {d5ace8d4-93aa-4c84-a4fb-0e143fb8b252}
+
+
+ {2c1f7fac-6a46-4a9a-b8a8-b847694279af}
+
+
+ {564098b2-c8f6-4da3-a462-67c4223103ca}
+
+
+ {6f0b0f68-94bf-405b-9db6-5a1b587429a4}
+
+
+ {8f1ea992-fb89-4064-ae19-55c353722fe3}
+
+
+ {77586023-2e26-4c4b-936f-e4e0ef6341c5}
+
+
+ {75a3ef47-05a4-453f-9af2-822a9b0fe9e4}
+
+
+ {419fb8d3-fb14-43bb-9e57-07ada4a5de08}
+
+
+ {6bf85c6f-0f5b-4813-a78a-f17a43f45725}
+
+
+ {45e50712-9fac-4731-a388-90a224ccdb1a}
+
+
+ {331cbf62-e92c-4964-8105-34a937d88b39}
+
+
+
+
+ FrameWork
+
+
+ FrameWork
+
+
+ FrameWork
+
+
+ FrameWork
+
+
+ FrameWork
+
+
+ FrameWork
+
+
+ FrameWork
+
+
+ Util\Public
+
+
+ Util\Public
+
+
+ Util\Public
+
+
+ Util\Public
+
+
+ Util\Public
+
+
+ Util\Public
+
+
+ Util\Public
+
+
+ Util\Public
+
+
+ Util\Public
+
+
+ Util\Public
+
+
+ Util\Public
+
+
+ Util\Public
+
+
+ Config
+
+
+ Config
+
+
+ Config
+
+
+ Net
+
+
+ Net
+
+
+ Net\Socket
+
+
+ Net\Socket
+
+
+ Net\Socket
+
+
+ Net\Socket
+
+
+ Net\Socket
+
+
+ Config\TinyXML
+
+
+ Config\TinyXML
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Logic\room
+
+
+ Logic\room
+
+
+ Logic\room
+
+
+ Logic\users
+
+
+ Logic\users
+
+
+ Logic\users
+
+
+ UI\BKWin\Login
+
+
+ UI\BKWin\RoomList
+
+
+ UI\BKWin\Room
+
+
+ Include
+
+
+ Include
+
+
+ Include
+
+
+ Include
+
+
+ Include
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ UI\BKWin\BKWin
+
+
+ FrameWork
+
+
+ CppTest
+
+
+ CppTest
+
+
+ Net\NMessage\Message
+
+
+ Net\NMessage\Message
+
+
+ Net\NMessage\Message
+
+
+ Net\NMessage\Message
+
+
+ Net\NMessage\Message
+
+
+ Net\NMessage\Message
+
+
+ Net\NMessage\Message
+
+
+ Net\NMessage\Message
+
+
+ Net\NMessage\MsgDataValue
+
+
+ Net\NMessage\MsgDataValue
+
+
+ Net\NMessage\MsgDataValue
+
+
+ Net\NMessage\Message
+
+
+ Net\NMessage\MsgDataValue
+
+
+ Net\NMessage\MsgDataValue
+
+
+ Net\NMessage\Message
+
+
+ Net\NMessage\Message\Produce
+
+
+ Net\NMessage\Message\Produce
+
+
+ Net\NMessage\Message\Produce
+
+
+ Net\NMessage\Message\Produce
+
+
+ Net\NMessage\Message\Produce
+
+
+ Net\NMessage\Message\Produce
+
+
+ Net\NMessage\Message\Produce
+
+
+ Net\NMessage\Message\Produce
+
+
+ Net\NMessage\Message\Produce
+
+
+ Net\NMessage\Message\Produce
+
+
+ Net\NMessage\Message\Produce
+
+
+ Net\NMessage\Message\Produce
+
+
+ Net\NMessage\Message\Produce
+
+
+ Net\NMessage\Message\Produce
+
+
+
+
+ FrameWork
+
+
+ FrameWork
+
+
+ FrameWork
+
+
+ FrameWork
+
+
+ Util\Public
+
+
+ Util\Public
+
+
+ Util\Public
+
+
+ Util\Public
+
+
+ Util\Public
+
+
+ Util\Public
+
+
+ Config
+
+
+ Net
+
+
+ Net\Socket
+
+
+ Net\Socket
+
+
+ Net\Socket
+
+
+ Net\Socket
+
+
+ Config\TinyXML
+
+
+ Config\TinyXML
+
+
+ Config\TinyXML
+
+
+ Config\TinyXML
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Net\Message
+
+
+ Logic\room
+
+
+ Logic\room
+
+
+ Logic\users
+
+
+ UI\BKWin\Login
+
+
+ UI\BKWin\RoomList
+
+
+ UI\BKWin\Room
+
+
+ UI\BKWin\BKWin
+
+
+ FrameWork
+
+
+ CppTest
+
+
+ Net\NMessage\Message
+
+
+ Net\NMessage\Message
+
+
+ Net\NMessage\Message
+
+
+ Net\NMessage\Message
+
+
+ Net\NMessage\MsgDataValue
+
+
+ Net\NMessage\MsgDataValue
+
+
+ Net\NMessage\MsgDataValue
+
+
+ Logic\room
+
+
+ Net\NMessage
+
+
+ Net\NMessage
+
+
+ Logic\users
+
+
+ Net\NMessage\Message
+
+
+ Net\NMessage\Message
+
+
+ Net\NMessage
+
+
+
+
+ Util\Public
+
+
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+
\ No newline at end of file
diff --git a/Client/Client/CppUnitTest/MSG_Message_Test.cpp b/Client/Client/CppUnitTest/MSG_Message_Test.cpp
new file mode 100644
index 00000000..bfe56baf
--- /dev/null
+++ b/Client/Client/CppUnitTest/MSG_Message_Test.cpp
@@ -0,0 +1,517 @@
+#ifdef CPPTEST
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "../../NMessage/MessageUnion.h"
+#include "../../NMessage/Message2Pack.h"
+#include "../../NMessage/Message2Parser.h"
+#include "../../NMessage/ParserMessageXML.h"
+#include "../../NMessage/BufferMessage.h"
+
+using namespace VNOC::Message;
+using namespace VNOC::Message::Define;
+
+CMessage2Pack g_m2pack;
+CMessage2Parser g_m2parser;
+
+class MSG_Message_Test : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE( MSG_Message_Test );
+ CPPUNIT_TEST( MSG_AnswerClassInfo_Test );
+ CPPUNIT_TEST( MSG_AnswerClassList_Test );
+ CPPUNIT_TEST( MSG_AnswerLogin_Test );
+ CPPUNIT_TEST( MSG_AnswerProfileSync_Test );
+ CPPUNIT_TEST( MSG_AnswerRegister_Test );
+ CPPUNIT_TEST( MSG_AnswerVerificationCode_Test );
+ CPPUNIT_TEST( MSG_RequestClassInfo_Test );
+ CPPUNIT_TEST( MSG_RequestClassList_Test );
+ CPPUNIT_TEST( MSG_RequestLogin_Test );
+ CPPUNIT_TEST( MSG_RequestProfileSync_Test );
+ CPPUNIT_TEST( MSG_RequestRegister_Test );
+ CPPUNIT_TEST( MSG_RequestVerificationCode_Test );
+ CPPUNIT_TEST( MSG_NULL_Test );
+ CPPUNIT_TEST_SUITE_END();
+public:
+ void setUp()
+ {
+
+ }
+ void tearDown()
+ {
+
+ }
+public:
+
+ void MSG_AnswerClassInfo_Test()
+ {
+ CBufferMessage buf;
+ MSG_AnswerClassInfo TMAci;
+ std::vector PeopListId;
+ TMAci.SetRoomName("");
+ TMAci.SetRoomID(22);
+ TMAci.SetRoomManageId(12);
+ TMAci.SetRoomPassword("123456789");
+ TMAci.SetRoomRank(10);
+ TMAci.SetRoomPeopleNumMax(1000);
+ TMAci.SetRoomType(25);
+ TMAci.SetRoomState(100);
+ PeopListId.push_back(1);
+ PeopListId.push_back(2);
+ PeopListId.push_back(3);
+ TMAci.SetRoomPeopleListId(PeopListId);
+ PeopListId.clear();
+
+ g_m2pack.PackMessage(&TMAci, buf);
+ CMessage parserMsg(CMessage2Parser::GetMsgType(buf));
+ CPPUNIT_ASSERT(CMessage2Parser::GetMsgType(buf) == MSG_AnswerClassInfo_Id);
+ g_m2parser.Parser(&parserMsg, buf);
+ MSG_AnswerClassInfo TParserAci(parserMsg);
+
+ uint32 RoomId = 0;
+ uint32 RoomRank = 0;
+ uint32 RoomType = 0;
+ uint32 RoomState = 0;
+ uint32 RoomPeopleNumMax = 0;
+ uint32 RoomManageId = 0;
+ std::string strRoomName;
+ std::string strPassword;
+
+ TParserAci.GetRoomName(strRoomName);
+ CPPUNIT_ASSERT(strRoomName == "");
+ TParserAci.GetRoomID(RoomId);
+ CPPUNIT_ASSERT(RoomId == 22);
+ TParserAci.GetRoomRank(RoomRank);
+ CPPUNIT_ASSERT(RoomRank == 10);
+ TParserAci.GetRoomPeopleNumMax(RoomPeopleNumMax);
+ CPPUNIT_ASSERT(RoomPeopleNumMax == 1000);
+ TParserAci.GetRoomPassword(strPassword);
+ CPPUNIT_ASSERT(strPassword == "123456789");
+ TParserAci.GetRoomState(RoomState);
+ CPPUNIT_ASSERT(RoomState == 100);
+ TParserAci.GetRoomManageId(RoomManageId);
+ CPPUNIT_ASSERT(RoomManageId == 12);
+ TParserAci.GetRoomType(RoomType);
+ CPPUNIT_ASSERT(RoomType == 25);
+ TParserAci.GetRoomPeopleListId(PeopListId);
+ CPPUNIT_ASSERT(PeopListId[0] == 1);
+ CPPUNIT_ASSERT(PeopListId[1] == 2);
+ CPPUNIT_ASSERT(PeopListId[2] == 3);
+ }
+
+ void MSG_AnswerClassList_Test()
+ {
+ CBufferMessage buf;
+ MSG_AnswerClassList TMAcl;
+ std::vector RoomIdList;
+ std::vector RoomStateList;
+ std::vector RoomNameList;
+ RoomIdList.push_back(111);
+ RoomIdList.push_back(1112);
+ RoomIdList.push_back(11123);
+ TMAcl.SetRoomIdList(RoomIdList);
+ RoomStateList.push_back(111);
+ RoomStateList.push_back(1112);
+ RoomStateList.push_back(1113);
+ TMAcl.SetRoomStateList(RoomStateList);
+ RoomNameList.push_back("1");
+ RoomNameList.push_back("2");
+ RoomNameList.push_back("3");
+ TMAcl.SetRoomNameList(RoomNameList);
+ RoomIdList.clear();
+ RoomNameList.clear();
+ RoomStateList.clear();
+
+ g_m2pack.PackMessage(&TMAcl, buf);
+ CMessage parserMsg(CMessage2Parser::GetMsgType(buf));
+ CPPUNIT_ASSERT(CMessage2Parser::GetMsgType(buf) == MSG_AnswerClassList_Id);
+ g_m2parser.Parser(&parserMsg, buf);
+ MSG_AnswerClassList TParserAcl(parserMsg);
+
+ TParserAcl.GetRoomIdList(RoomIdList);
+ CPPUNIT_ASSERT(RoomIdList[0] == 111);
+ CPPUNIT_ASSERT(RoomIdList[1] == 1112);
+ CPPUNIT_ASSERT(RoomIdList[2] == 11123);
+ TParserAcl.GetRoomStateList(RoomStateList);
+ CPPUNIT_ASSERT(RoomStateList[0] == 111);
+ CPPUNIT_ASSERT(RoomStateList[1] == 1112);
+ CPPUNIT_ASSERT(RoomStateList[2] == 1113);
+ TParserAcl.GetRoomNameList(RoomNameList);
+ CPPUNIT_ASSERT(RoomNameList[0] == "1");
+ CPPUNIT_ASSERT(RoomNameList[1] == "2");
+ CPPUNIT_ASSERT(RoomNameList[2] == "3");
+ }
+
+ void MSG_AnswerLogin_Test()
+ {
+ CBufferMessage buf;
+ MSG_AnswerLogin TMAl;
+ std::string ATLGUID;
+ uint8 LoginResult = 0;
+ uint32 Token = 0;
+ TMAl.SetATLGUID("");
+ TMAl.SetLoginResult(10);
+ TMAl.SetToken(10000);
+
+ g_m2pack.PackMessage(&TMAl, buf);
+ CMessage parserMsg(CMessage2Parser::GetMsgType(buf));
+ CPPUNIT_ASSERT(CMessage2Parser::GetMsgType(buf) == MSG_AnswerLogin_Id);
+ g_m2parser.Parser(&parserMsg, buf);
+ MSG_AnswerLogin TParserAl(parserMsg);
+
+ TParserAl.GetATLGUID(ATLGUID);
+ CPPUNIT_ASSERT(ATLGUID == "");
+ TParserAl.GetToken(Token);
+ CPPUNIT_ASSERT(Token == 10000);
+ TParserAl.GetLoginResult(LoginResult);
+ CPPUNIT_ASSERT(LoginResult == 10);
+ }
+
+ void MSG_AnswerProfileSync_Test()
+ {
+ CBufferMessage buf;
+ MSG_AnswerProfileSync TMAps;
+ std::string strMessageSynchro;
+ TMAps.SetMessageSynchro("!!ee e e e ");
+
+ g_m2pack.PackMessage(&TMAps, buf);
+ CMessage parserMsg(CMessage2Parser::GetMsgType(buf));
+ CPPUNIT_ASSERT(CMessage2Parser::GetMsgType(buf) == MSG_AnswerProfileSync_Id);
+ g_m2parser.Parser(&parserMsg, buf);
+ MSG_AnswerProfileSync TParserAps(parserMsg);
+ TParserAps.GetMessageSynchro(strMessageSynchro);
+ CPPUNIT_ASSERT(strMessageSynchro == "!!ee e e e ");
+ }
+
+ void MSG_AnswerRegister_Test()
+ {
+ CBufferMessage buf;
+ MSG_AnswerRegister TMAr;
+ uint32 RetTag = 0;
+ TMAr.SetRetTag(15000);
+
+ g_m2pack.PackMessage(&TMAr, buf);
+ CMessage parserMsg(CMessage2Parser::GetMsgType(buf));
+ CPPUNIT_ASSERT(CMessage2Parser::GetMsgType(buf) == MSG_AnswerRegister_Id);
+ g_m2parser.Parser(&parserMsg, buf);
+ MSG_AnswerRegister TParserAr(parserMsg);
+
+ TParserAr.GetRetTag(RetTag);
+ CPPUNIT_ASSERT(RetTag == 15000);
+ }
+
+ void MSG_AnswerVerificationCode_Test()
+ {
+ CBufferMessage buf;
+ MSG_AnswerVerificationCode TMAvc;
+ std::string strCaptcha;
+ uint8 CaptchaType = 0;
+ uint8 LoginTag = 0;
+ TMAvc.SetCaptcha("DZ⣡");
+ TMAvc.SetCaptchaType(105);
+ TMAvc.SetLoginTag(3);
+
+ g_m2pack.PackMessage(&TMAvc, buf);
+ CMessage parserMsg(CMessage2Parser::GetMsgType(buf));
+ CPPUNIT_ASSERT(CMessage2Parser::GetMsgType(buf) == MSG_AnswerVerificationCode_Id);
+ g_m2parser.Parser(&parserMsg, buf);
+ MSG_AnswerVerificationCode TParserAvc(parserMsg);
+
+ TParserAvc.GetCaptcha(strCaptcha);
+ CPPUNIT_ASSERT(strCaptcha == "DZ⣡");
+ TParserAvc.GetCaptchaType(CaptchaType);
+ CPPUNIT_ASSERT(CaptchaType == 105);
+ TParserAvc.GetLoginTag(LoginTag);
+ CPPUNIT_ASSERT(LoginTag == 3);
+ }
+
+ void MSG_RequestClassInfo_Test()
+ {
+ CBufferMessage buf;
+ MSG_RequestClassInfo TMRci;
+ uint32 RoomId = 0;
+ TMRci.SetRoomID(15016);
+
+ g_m2pack.PackMessage(&TMRci, buf);
+ CMessage parserMsg(CMessage2Parser::GetMsgType(buf));
+ CPPUNIT_ASSERT(CMessage2Parser::GetMsgType(buf) == MSG_RequestClassInfo_Id);
+ g_m2parser.Parser(&parserMsg, buf);
+ MSG_RequestClassInfo TParserAci(parserMsg);
+
+ TParserAci.GetRoomID(RoomId);
+ CPPUNIT_ASSERT(RoomId == 15016);
+ }
+
+ void MSG_RequestClassList_Test()
+ {
+ CBufferMessage buf;
+ uint32 UserType = 0;
+ MSG_RequestClassList TMRcl;
+ TMRcl.SetUserType(10000000);
+
+ g_m2pack.PackMessage(&TMRcl, buf);
+ CMessage parserMsg(CMessage2Parser::GetMsgType(buf));
+ CPPUNIT_ASSERT(CMessage2Parser::GetMsgType(buf) == MSG_RequestClassList_Id);
+ g_m2parser.Parser(&parserMsg, buf);
+ MSG_RequestClassInfo TParserRcl(parserMsg);
+
+ TMRcl.GetUserType(UserType);
+ CPPUNIT_ASSERT(UserType == 10000000);
+ }
+
+ void MSG_RequestLogin_Test()
+ {
+ CBufferMessage buf;
+ MSG_RequestLogin TMRl;
+ std::string strAccountNumber;
+ std::string strPassword;
+ std::string strVerificationCode;
+ TMRl.SetAccountNumber("Sum");
+ TMRl.SetPassword("123456789");
+ TMRl.SetVerificationCode("EFDA");
+
+ g_m2pack.PackMessage(&TMRl, buf);
+ CMessage parserMsg(CMessage2Parser::GetMsgType(buf));
+ CPPUNIT_ASSERT(CMessage2Parser::GetMsgType(buf) == MSG_RequestLogin_Id);
+ g_m2parser.Parser(&parserMsg, buf);
+ MSG_RequestLogin TParserRl(parserMsg);
+
+ TParserRl.GetAccountNumber(strAccountNumber);
+ CPPUNIT_ASSERT(strAccountNumber == "Sum");
+ TParserRl.GetPassword(strPassword);
+ CPPUNIT_ASSERT(strPassword == "123456789");
+ TParserRl.GetVerificationCode(strVerificationCode);
+ CPPUNIT_ASSERT(strVerificationCode == "EFDA");
+ }
+
+ void MSG_RequestProfileSync_Test()
+ {
+ CBufferMessage buf;
+ MSG_RequestProfileSync TMRps;
+ uint8 Rank = 0;
+ uint8 HeadForm = 0;
+ std::string strAutograph;
+ std::string strHeadPortrait;
+ std::string strNickName;
+ TMRps.SetRank(10);
+ TMRps.SetHeadForm(20);
+ TMRps.SetAutograph("!!!!!!!!!!!!!!!!!!!!!");
+ TMRps.SetHeadPortrait("lalala");
+ TMRps.SetNickname("yahoooooooooooooooooooooooooooooooooooo");
+
+ g_m2pack.PackMessage(&TMRps, buf);
+ CMessage parserMsg(CMessage2Parser::GetMsgType(buf));
+ CPPUNIT_ASSERT(CMessage2Parser::GetMsgType(buf) == MSG_RequestProfileSync_Id);
+ g_m2parser.Parser(&parserMsg, buf);
+ MSG_RequestProfileSync TParserRps(parserMsg);
+
+ TParserRps.GetRank(Rank);
+ CPPUNIT_ASSERT(Rank == 10);
+ TParserRps.GetHeadForm(HeadForm);
+ CPPUNIT_ASSERT(HeadForm == 20);
+ TParserRps.GetAutograph(strAutograph);
+ CPPUNIT_ASSERT(strAutograph == "!!!!!!!!!!!!!!!!!!!!!");
+ TParserRps.GetHeadPortrait(strHeadPortrait);
+ CPPUNIT_ASSERT(strHeadPortrait == "lalala");
+ TParserRps.GetNickname(strNickName);
+ CPPUNIT_ASSERT(strNickName == "yahoooooooooooooooooooooooooooooooooooo");
+ }
+
+ void MSG_RequestRegister_Test()
+ {
+ CBufferMessage buf;
+ MSG_RequestRegister TMRr;
+ uint8 Rank = 0;
+ uint8 HeadForm = 0;
+ std::string strAutograph;
+ std::string strHeadPortrait;
+ std::string strNickName;
+ std::string strEmailAddress;
+ TMRr.SetRank(0);
+ TMRr.SetHeadForm(20);
+ TMRr.SetAutograph("!!!!!!!!!!!!!!!!!!!!!");
+ TMRr.SetHeadPortrait("lalala");
+ TMRr.SetNickname("yahoooooooooooooooooooooooooooooooooooo");
+ TMRr.SetEmailAddress("123456@123.com");
+
+ g_m2pack.PackMessage(&TMRr, buf);
+ CMessage parserMsg(CMessage2Parser::GetMsgType(buf));
+ CPPUNIT_ASSERT(CMessage2Parser::GetMsgType(buf) == MSG_RequestRegister_Id);
+ g_m2parser.Parser(&parserMsg, buf);
+ MSG_RequestRegister TParserRr(parserMsg);
+
+ TParserRr.GetRank(Rank);
+ CPPUNIT_ASSERT(Rank == 0);
+ TParserRr.GetHeadForm(HeadForm);
+ CPPUNIT_ASSERT(HeadForm == 20);
+ TParserRr.GetAutograph(strAutograph);
+ CPPUNIT_ASSERT(strAutograph == "!!!!!!!!!!!!!!!!!!!!!");
+ TParserRr.GetHeadPortrait(strHeadPortrait);
+ CPPUNIT_ASSERT(strHeadPortrait == "lalala");
+ TParserRr.GetNickname(strNickName);
+ CPPUNIT_ASSERT(strNickName == "yahoooooooooooooooooooooooooooooooooooo");
+ TMRr.GetEmailAddress(strEmailAddress);
+ CPPUNIT_ASSERT(strEmailAddress == "123456@123.com");
+ }
+
+ void MSG_RequestVerificationCode_Test()
+ {
+ CBufferMessage buf;
+ std::string strMachineAddress;
+ MSG_RequestVerificationCode TMRvc;
+ TMRvc.SetMachineAddress("");
+
+ g_m2pack.PackMessage(&TMRvc, buf);
+ CMessage parserMsg(CMessage2Parser::GetMsgType(buf));
+ CPPUNIT_ASSERT(CMessage2Parser::GetMsgType(buf) == MSG_RequestVerificationCode_Id);
+ g_m2parser.Parser(&parserMsg, buf);
+
+ MSG_RequestVerificationCode TParserRvc(parserMsg);
+ TParserRvc.GetMachineAddress(strMachineAddress);
+ CPPUNIT_ASSERT(strMachineAddress == "");
+ }
+
+ void MSG_NULL_Test()
+ {
+ //NoArrayData Test NULL
+ CBufferMessage buf;
+ MSG_RequestRegister TMRr;
+ char t[1000] = {0};
+ uint8 Rank = 0;
+ uint8 HeadForm = 0;
+ std::string strAutograph;
+ std::string strHeadPortrait;
+ std::string strNickName;
+ std::string strEmailAddress;
+ //TMRr.SetRank(10);
+ //TMRr.SetHeadForm(20);
+ //TMRr.SetAutograph("!!!!!!!!!!!!!!!!!!!!!");
+ TMRr.SetHeadPortrait("");
+ TMRr.SetNickname("yahoooooooooooooooooooooooooooooooooooo");
+ TMRr.SetEmailAddress("123456@123.com");
+
+ g_m2pack.PackMessage(&TMRr, buf);
+ memcpy(t, buf.GetBuffer(), buf.GetSize());
+ CMessage parserMsg(CMessage2Parser::GetMsgType(buf));
+ CPPUNIT_ASSERT(CMessage2Parser::GetMsgType(buf) == MSG_RequestRegister_Id);
+ g_m2parser.Parser(&parserMsg, buf);
+ MSG_RequestRegister TParserRr(parserMsg);
+
+ TParserRr.GetRank(Rank);
+ CPPUNIT_ASSERT(Rank == 0);
+ TParserRr.GetHeadForm(HeadForm);
+ CPPUNIT_ASSERT(HeadForm == 0);
+ TParserRr.GetAutograph(strAutograph);
+ CPPUNIT_ASSERT(strAutograph == "");
+ TParserRr.GetHeadPortrait(strHeadPortrait);
+ CPPUNIT_ASSERT(strHeadPortrait == "");
+ TParserRr.GetNickname(strNickName);
+ CPPUNIT_ASSERT(strNickName == "yahoooooooooooooooooooooooooooooooooooo");
+ TMRr.GetEmailAddress(strEmailAddress);
+ CPPUNIT_ASSERT(strEmailAddress == "123456@123.com");
+
+ //ArrayData Test NULL
+ buf.Clear();
+ MSG_AnswerClassList TMAcl;
+ std::vector RoomIdList;
+ std::vector RoomStateList;
+ std::vector RoomNameList;
+ //RoomIdList.push_back(111);
+ //RoomIdList.push_back(1112);
+ //RoomIdList.push_back(11123);
+ TMAcl.SetRoomIdList(RoomIdList);
+ RoomStateList.push_back(111);
+ RoomStateList.push_back(1112);
+ RoomStateList.push_back(1113);
+ TMAcl.SetRoomStateList(RoomStateList);
+ RoomNameList.push_back("");
+ RoomNameList.push_back("");
+ RoomNameList.push_back("");
+ TMAcl.SetRoomNameList(RoomNameList);
+ RoomIdList.clear();
+ RoomNameList.clear();
+ RoomStateList.clear();
+
+ g_m2pack.PackMessage(&TMAcl, buf);
+ CMessage arrparserMsg(CMessage2Parser::GetMsgType(buf));
+ CPPUNIT_ASSERT(CMessage2Parser::GetMsgType(buf) == MSG_AnswerClassList_Id);
+ g_m2parser.Parser(&arrparserMsg, buf);
+ MSG_AnswerClassList TParserAcl(arrparserMsg);
+
+ TParserAcl.GetRoomIdList(RoomIdList);
+ CPPUNIT_ASSERT(RoomIdList[0] == 0);
+ //CPPUNIT_ASSERT(RoomIdList[1] == 1112);
+ //CPPUNIT_ASSERT(RoomIdList[2] == 11123);
+ TParserAcl.GetRoomStateList(RoomStateList);
+ CPPUNIT_ASSERT(RoomStateList[0] == 111);
+ CPPUNIT_ASSERT(RoomStateList[1] == 1112);
+ CPPUNIT_ASSERT(RoomStateList[2] == 1113);
+ TParserAcl.GetRoomNameList(RoomNameList);
+ CPPUNIT_ASSERT(RoomNameList[0] == "");
+ CPPUNIT_ASSERT(RoomNameList[1] == "");
+ CPPUNIT_ASSERT(RoomNameList[2] == "");
+
+ //ArrayData And NO-ArrayData
+ buf.Clear();
+ MSG_AnswerClassInfo TMAci;
+ std::vector PeopListId;
+ TMAci.SetRoomName("");
+ TMAci.SetRoomID(22);
+ TMAci.SetRoomManageId(12);
+ //TMAci.SetRoomPassword("123456789");
+ TMAci.SetRoomRank(10);
+ TMAci.SetRoomPeopleNumMax(1000);
+ TMAci.SetRoomType(25);
+ TMAci.SetRoomState(100);
+ PeopListId.push_back(1);
+ PeopListId.push_back(2);
+ PeopListId.push_back(3);
+ TMAci.SetRoomPeopleListId(PeopListId);
+ PeopListId.clear();
+
+ g_m2pack.PackMessage(&TMAci, buf);
+ CMessage AparserMsg(CMessage2Parser::GetMsgType(buf));
+ CPPUNIT_ASSERT(CMessage2Parser::GetMsgType(buf) == MSG_AnswerClassInfo_Id);
+ g_m2parser.Parser(&AparserMsg, buf);
+ MSG_AnswerClassInfo TParserAci(AparserMsg);
+
+ uint32 RoomId = 0;
+ uint32 RoomRank = 0;
+ uint32 RoomType = 0;
+ uint32 RoomState = 0;
+ uint32 RoomPeopleNumMax = 0;
+ uint32 RoomManageId = 0;
+ std::string strRoomName;
+ std::string strPassword;
+
+ TParserAci.GetRoomName(strRoomName);
+ CPPUNIT_ASSERT(strRoomName == "");
+ TParserAci.GetRoomID(RoomId);
+ CPPUNIT_ASSERT(RoomId == 22);
+ TParserAci.GetRoomRank(RoomRank);
+ CPPUNIT_ASSERT(RoomRank == 10);
+ TParserAci.GetRoomPeopleNumMax(RoomPeopleNumMax);
+ CPPUNIT_ASSERT(RoomPeopleNumMax == 1000);
+ TParserAci.GetRoomPassword(strPassword);
+ CPPUNIT_ASSERT(strPassword == "");
+ TParserAci.GetRoomState(RoomState);
+ CPPUNIT_ASSERT(RoomState == 100);
+ TParserAci.GetRoomManageId(RoomManageId);
+ CPPUNIT_ASSERT(RoomManageId == 12);
+ TParserAci.GetRoomType(RoomType);
+ CPPUNIT_ASSERT(RoomType == 25);
+ TParserAci.GetRoomPeopleListId(PeopListId);
+ CPPUNIT_ASSERT(PeopListId[0] == 1);
+ CPPUNIT_ASSERT(PeopListId[1] == 2);
+ CPPUNIT_ASSERT(PeopListId[2] == 3);
+ }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION ( MSG_Message_Test );
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(MSG_Message_Test, "testNMessage");
+
+#endif
\ No newline at end of file
diff --git a/VNOC/VNOC/test/Vnocp1MessageParserTest.cpp b/Client/Client/CppUnitTest/Vnocp1MessageParserTest.cpp
similarity index 80%
rename from VNOC/VNOC/test/Vnocp1MessageParserTest.cpp
rename to Client/Client/CppUnitTest/Vnocp1MessageParserTest.cpp
index 62b05f46..e646e2cb 100644
--- a/VNOC/VNOC/test/Vnocp1MessageParserTest.cpp
+++ b/Client/Client/CppUnitTest/Vnocp1MessageParserTest.cpp
@@ -1,416 +1,504 @@
-#include
-#include
-#include "..\..\Message\MessageParser.h"
-#include
-class Vnocp1MessageParserTest : public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE( Vnocp1MessageParserTest );
- CPPUNIT_TEST( MSGAVCParseTest );
- CPPUNIT_TEST( MSGRVCParseTest );
- CPPUNIT_TEST( MSGALIParseTest );
- CPPUNIT_TEST( MSGRLIParseTest );
- CPPUNIT_TEST( MSGAPSParseTest );
- CPPUNIT_TEST( MSGRPSParseTest );
- CPPUNIT_TEST_SUITE_END();
-public:
- void setUp()
- {
-
- }
- void tearDown()
- {
-
- }
-public:
-
- void MSGAVCParseTest()
- {
- byte testParamO [] = {0x01,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02};
- byte testParamT [] = {0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03};
- byte testParamS [] = {0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04};
-
- byte testAVC [] = {0x56,
- 0x00,
- 0x00,0x01,
- 0x00,0x00,0x00,0x3F,
-
-
- 0x01,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x15,
- 0x00,0x00,0x00,0x00,
- 0x03,
-
- 0x00,0x00,0x00,0x01,
- 0x00,0x00,0x00,0x01,
- 0x00,0x00,0x00,0x10,
-
- 0x1e,
-
- 0x1e,
-
- 0x01,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x00,0x00,
- 0x43};
-
-
- byte testPackAVC[63] = {0};
-
- //AVC
- CMessageParser msgParser;
- CMessage* msgAVC = msgParser.Parse(testAVC,sizeof(testAVC));
- CPPUNIT_ASSERT(msgAVC->GetMessageType() == MSG_AVC_TYPE);//֤ϢAVC
- MSG_AVC* msg_avc = (MSG_AVC *)msgAVC;
- CPPUNIT_ASSERT(msg_avc->GetSerial() == 1);
- CPPUNIT_ASSERT(memcmp(msg_avc->GetGUID(),testParamO,sizeof(byte) * 16) == 0);
- CPPUNIT_ASSERT(memcmp(msg_avc->GetCaptcha(),testParamO,16) == 0);
- CPPUNIT_ASSERT(msg_avc->GetLoginTag() == 0x1e);
- CPPUNIT_ASSERT(msg_avc->GetCaptchaType() == 0x1e);
- }
-
- void MSGRVCParseTest()
- {
- byte testParamO [] = {0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02};
- byte testParamT [] = {0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03};
- byte testParamS [] = {0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04};
-
- byte testRVC [] = {0x56,
- 0x00,
- 0x00,0x01,
- 0x00,0x00,0x00,0x35,
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x14,
- 0x00,0x00,0x00,0x00,
- 0x01,
-
- 0x00,0x00,0x00,0x10,
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x00,0x00,
- 0x43};
-
- byte testPackRVC[53] = {0};
-
- CMessageParser msgParser;
- CMessage* msgRVC = msgParser.Parse(testRVC,sizeof(testRVC));
- CPPUNIT_ASSERT(msgRVC->GetMessageType() == MSG_RVC_TYPE);//֤ϢRVC
- MSG_RVC* msg_rvc = (MSG_RVC *)msgRVC;
-
- CPPUNIT_ASSERT(msg_rvc->GetSerial() == 1);
-
- CPPUNIT_ASSERT(memcmp(msg_rvc->GetGUID(),testParamO,sizeof(byte) * 16) == 0);
- CPPUNIT_ASSERT(memcmp(msg_rvc->GetMachineAddress(),testParamO,16) == 0);
- }
-
- void MSGRLIParseTest()
- {
- byte testParamO [] = {0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02};
- byte testParamT [] = {0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03};
- byte testParamS [] = {0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04};
-
- byte testRLI [] = {0x56,
- 0x00,
- 0x00,0x01,
- 0x00,0x00,0x00,0x5D,
-
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x16,
- 0x00,0x00,0x00,0x00,
-
- 0x03,
-
- 0x00,0x00,0x00,0x10,
- 0x00,0x00,0x00,0x10,
- 0x00,0x00,0x00,0x10,
-
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
-
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
-
- 0x00,0x00,
- 0x43};
-
- byte testPackRLI[100] = {0};
-
- //RLI
- CMessageParser msgParser;
- CMessage* msgRLI = msgParser.Parse(testRLI,sizeof(testRLI));
- CPPUNIT_ASSERT(msgRLI->GetMessageType() == MSG_RLI_TYPE);//֤ϢRLI
- MSG_RLI* msg_rli = (MSG_RLI *)msgRLI;
-
- CPPUNIT_ASSERT(msg_rli->GetSerial() == 1);
-
- CPPUNIT_ASSERT(memcmp(msg_rli->GetGUID(),testParamO,sizeof(byte) * 16) == 0);
-
- CPPUNIT_ASSERT(memcmp(msg_rli->GetVerificationCode(),testParamO,sizeof(byte) * 16) == 0);
-
- CPPUNIT_ASSERT(memcmp(msg_rli->GetAccountNumber(),testParamT,16) == 0);
-
- CPPUNIT_ASSERT(memcmp(msg_rli->GetPassword(),testParamS,16) == 0);
-
- }
-
- void MSGRPSParseTest()
- {
- byte testParamO [] = {0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02};
- byte testParamT [] = {0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03};
- byte testParamS [] = {0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04};
-
-
- byte testRPS [] = {0x56,
- 0x00,
- 0x00,0x01,
- 0x00,0x00,0x00,0x67,
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x18,
- 0x00,0x00,0x00,0x00,
-
- 0x05,
-
- 0x00,0x00,0x00,0x01,
- 0x00,0x00,0x00,0x10,
- 0x00,0x00,0x00,0x10,
- 0x00,0x00,0x00,0x01,
- 0x00,0x00,0x00,0x10,
-
- 0x01,
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
-
- 'A',
-
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
-
- 0x00,0x00,
- 0x43};
-
- byte testPackRPS[120] = {0};
-
- //RPS
- CMessageParser msgParser;
- CMessage* msgRPS = msgParser.Parse(testRPS,sizeof(testRPS));
- CPPUNIT_ASSERT(msgRPS->GetMessageType() == MSG_RPS_TYPE);//֤ϢRPS
- MSG_RPS* msg_rps = (MSG_RPS *)msgRPS;
-
- CPPUNIT_ASSERT(msg_rps->GetSerial() == 1);
-
- CPPUNIT_ASSERT(memcmp(msg_rps->GetGUID(),testParamO,sizeof(byte) * 16) == 0);
-
- CPPUNIT_ASSERT(msg_rps->GetRank() == 0x01);
-
- CPPUNIT_ASSERT(memcmp(msg_rps->GetNickname(),testParamO,sizeof(byte) * 16) == 0);
-
- CPPUNIT_ASSERT(memcmp(msg_rps->GetAutograph(),testParamT,sizeof(byte) * 16) == 0);
-
- CPPUNIT_ASSERT(msg_rps->GetHeadForm() == 'A');
-
- CPPUNIT_ASSERT(memcmp(msg_rps->GetHeadPortrait(),testParamS,sizeof(byte) * 16) == 0);
-
- }
-
- void MSGAPSParseTest()
- {
- byte testParamO [] = {0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02};
- byte testParamT [] = {0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03};
- byte testParamS [] = {0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04};
-
- byte testAPS [] = {0x56,
- 0x00,
- 0x00,0x01,
- 0x00,0x00,0x00,0x35,
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x19,
- 0x00,0x00,0x00,0x00,
- 0x01,
-
- 0x00,0x00,0x00,0x10,
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x00,0x00,
- 0x43};
-
- byte testPackAPS[100] = {0};
- //APS
- CMessageParser msgParser;
- CMessage* msgAPS = msgParser.Parse(testAPS,sizeof(testAPS));
- CPPUNIT_ASSERT(msgAPS->GetMessageType() == MSG_APS_TYPE);//֤ϢRPS
- MSG_APS* msg_aps = (MSG_APS *)msgAPS;
-
- CPPUNIT_ASSERT(msg_aps->GetSerial() == 1);
-
- CPPUNIT_ASSERT(memcmp(msg_aps->GetGUID(),testParamO,sizeof(byte) * 16) == 0);
-
- CPPUNIT_ASSERT(memcmp(msg_aps->GetMessageSynchro(),testParamO,sizeof(byte) * 16) == 0);
- }
-
- void MSGALIParseTest()
- {
- byte testParamO [] = {0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02};
- byte testParamT [] = {0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03};
- byte testParamS [] = {0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04};
-
- byte testALI [] = {0x56,
- 0x00,
- 0x00,0x01,
- 0x00,0x00,0x00,0x4E,
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x17,
- 0x00,0x00,0x00,0x00,
-
- 0x03,
-
- 0x00,0x00,0x00,0x01,
- 0x00,0x00,0x00,0x10,
- 0x00,0x00,0x00,0x10,
-
- 0x1e,
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
-
- 0x00,0x00,
- 0x43};
-
- byte testPackALI[100] = {0};
-
- CMessageParser msgParser;
- CMessage* msgALI = msgParser.Parse(testALI,sizeof(testALI));
- CPPUNIT_ASSERT(msgALI->GetMessageType() == MSG_ALI_TYPE);//֤ϢALI
- MSG_ALI* msg_ali = (MSG_ALI *)msgALI;
-
- CPPUNIT_ASSERT(msg_ali->GetSerial() == 1);
-
- CPPUNIT_ASSERT(memcmp(msg_ali->GetGUID(),testParamO,sizeof(byte) * 16) == 0);
-
- CPPUNIT_ASSERT(msg_ali->GetLoginResult() == 0x1E);
-
- CPPUNIT_ASSERT(memcmp(msg_ali->GetATLGUID(),testParamT,sizeof(byte) * 16) == 0);
-
- }
-
-};
-CPPUNIT_TEST_SUITE_REGISTRATION ( Vnocp1MessageParserTest );
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Vnocp1MessageParserTest, "Vnocp1MessageParserTest");
\ No newline at end of file
+#ifdef CPPTEST
+#include
+#include
+#include "..\..\Message\MessageParser.h"
+#include
+class Vnocp1MessageParserTest : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE( Vnocp1MessageParserTest );
+ CPPUNIT_TEST( MSGParserCheckTest );
+ CPPUNIT_TEST( MSGAVCParseTest );
+ CPPUNIT_TEST( MSGRVCParseTest );
+ CPPUNIT_TEST( MSGALIParseTest );
+ CPPUNIT_TEST( MSGRLIParseTest );
+ CPPUNIT_TEST( MSGAPSParseTest );
+ CPPUNIT_TEST( MSGRPSParseTest );
+ CPPUNIT_TEST_SUITE_END();
+public:
+ void setUp()
+ {
+
+ }
+ void tearDown()
+ {
+
+ }
+public:
+
+ void MSGParserCheckTest()
+ {
+ byte testAllRubbish[] = {
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ };
+ byte testHasHeadRubbish[] =
+ {
+ 0x12,0x12,0x12,0x12,
+ 'V',0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ };
+ byte testLengthLack[] =
+ {
+ 'V',0x12,0x12,0x12,
+ 0x00,0x00,0x00,0xff,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ };
+ byte testNoTailRubbish[]=
+ {
+ 'V',0x12,0x12,0x12,
+ 0x00,0x00,0x00,0x10,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ };
+ byte testGood[]=
+ {
+ 'V',0x12,0x12,0x12,
+ 0x00,0x00,0x00,0x10,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,'C',
+ };
+ byte testRubbishWithGood[]=
+ {
+ 0x12,0x12,0x12,0x12,
+ 'V',0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,
+
+ 'V',0x12,0x12,0x12,
+ 0x00,0x00,0x00,0x10,
+ 0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,'C',
+ };
+ CPPUNIT_ASSERT(CMessageParser::Check(testAllRubbish,sizeof(testAllRubbish)) == -1);
+ CPPUNIT_ASSERT(CMessageParser::Check(testHasHeadRubbish,sizeof(testHasHeadRubbish)) == -1);
+ CPPUNIT_ASSERT(CMessageParser::Check(testLengthLack,sizeof(testLengthLack)) == -1);
+ CPPUNIT_ASSERT(CMessageParser::Check(testNoTailRubbish,sizeof(testNoTailRubbish)) == -1);
+ CPPUNIT_ASSERT(CMessageParser::Check(testGood,sizeof(testGood)) == 0x10);
+ CPPUNIT_ASSERT(CMessageParser::Check(testRubbishWithGood,sizeof(testRubbishWithGood)) == 0x2c);
+ }
+
+ void MSGAVCParseTest()
+ {
+ byte testParamO [] = {0x01,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02};
+ byte testParamT [] = {0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03};
+ byte testParamS [] = {0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04};
+
+ byte testAVC [] = {0x56,
+ 0x00,
+ 0x00,0x01,
+ 0x00,0x00,0x00,0x3F,
+
+
+ 0x01,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x15,
+ 0x00,0x00,0x00,0x00,
+ 0x03,
+
+ 0x00,0x00,0x00,0x01,
+ 0x00,0x00,0x00,0x01,
+ 0x00,0x00,0x00,0x10,
+
+ 0x1e,
+
+ 0x1e,
+
+ 0x01,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x00,0x00,
+ 0x43};
+
+
+ byte testPackAVC[63] = {0};
+
+ //AVC
+ CMessageParser msgParser;
+ CMessage* msgAVC = msgParser.Parse(testAVC,sizeof(testAVC));
+ CPPUNIT_ASSERT(msgAVC->GetMessageType() == MSG_AVC_TYPE);//֤ϢAVC
+ MSG_AVC* msg_avc = (MSG_AVC *)msgAVC;
+ CPPUNIT_ASSERT(msg_avc->GetSerial() == 1);
+ CPPUNIT_ASSERT(memcmp(msg_avc->GetGUID(),testParamO,sizeof(byte) * 16) == 0);
+ CPPUNIT_ASSERT(memcmp(msg_avc->GetCaptcha(),testParamO,16) == 0);
+ CPPUNIT_ASSERT(msg_avc->GetLoginTag() == 0x1e);
+ CPPUNIT_ASSERT(msg_avc->GetCaptchaType() == 0x1e);
+ delete msg_avc;
+ }
+
+ void MSGRVCParseTest()
+ {
+ byte testParamO [] = {0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02};
+ byte testParamT [] = {0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03};
+ byte testParamS [] = {0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04};
+
+ byte testRVC [] = {0x56,
+ 0x00,
+ 0x00,0x01,
+ 0x00,0x00,0x00,0x35,
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x14,
+ 0x00,0x00,0x00,0x00,
+ 0x01,
+
+ 0x00,0x00,0x00,0x10,
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x00,0x00,
+ 0x43};
+
+ byte testPackRVC[53] = {0};
+
+ CMessageParser msgParser;
+ CMessage* msgRVC = msgParser.Parse(testRVC,sizeof(testRVC));
+ CPPUNIT_ASSERT(msgRVC->GetMessageType() == MSG_RVC_TYPE);//֤ϢRVC
+ MSG_RVC* msg_rvc = (MSG_RVC *)msgRVC;
+
+ CPPUNIT_ASSERT(msg_rvc->GetSerial() == 1);
+
+ CPPUNIT_ASSERT(memcmp(msg_rvc->GetGUID(),testParamO,sizeof(byte) * 16) == 0);
+ CPPUNIT_ASSERT(memcmp(msg_rvc->GetMachineAddress(),testParamO,16) == 0);
+ delete msg_rvc;
+ }
+
+ void MSGRLIParseTest()
+ {
+ byte testParamO [] = {0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02};
+ byte testParamT [] = {0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03};
+ byte testParamS [] = {0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04};
+
+ byte testRLI [] = {0x56,
+ 0x00,
+ 0x00,0x01,
+ 0x00,0x00,0x00,0x5D,
+
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x16,
+ 0x00,0x00,0x00,0x00,
+
+ 0x03,
+
+ 0x00,0x00,0x00,0x10,
+ 0x00,0x00,0x00,0x10,
+ 0x00,0x00,0x00,0x10,
+
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+
+ 0x00,0x00,
+ 0x43};
+
+ byte testPackRLI[100] = {0};
+
+ //RLI
+ CMessageParser msgParser;
+ CMessage* msgRLI = msgParser.Parse(testRLI,sizeof(testRLI));
+ CPPUNIT_ASSERT(msgRLI->GetMessageType() == MSG_RLI_TYPE);//֤ϢRLI
+ MSG_RLI* msg_rli = (MSG_RLI *)msgRLI;
+
+ CPPUNIT_ASSERT(msg_rli->GetSerial() == 1);
+
+ CPPUNIT_ASSERT(memcmp(msg_rli->GetGUID(),testParamO,sizeof(byte) * 16) == 0);
+
+ CPPUNIT_ASSERT(memcmp(msg_rli->GetVerificationCode(),testParamO,sizeof(byte) * 16) == 0);
+
+ CPPUNIT_ASSERT(memcmp(msg_rli->GetAccountNumber(),testParamT,16) == 0);
+
+ CPPUNIT_ASSERT(memcmp(msg_rli->GetPassword(),testParamS,16) == 0);
+ delete msg_rli;
+
+ }
+
+ void MSGRPSParseTest()
+ {
+ byte testParamO [] = {0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02};
+ byte testParamT [] = {0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03};
+ byte testParamS [] = {0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04};
+
+
+ byte testRPS [] = {0x56,
+ 0x00,
+ 0x00,0x01,
+ 0x00,0x00,0x00,0x67,
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x18,
+ 0x00,0x00,0x00,0x00,
+
+ 0x05,
+
+ 0x00,0x00,0x00,0x01,
+ 0x00,0x00,0x00,0x10,
+ 0x00,0x00,0x00,0x10,
+ 0x00,0x00,0x00,0x01,
+ 0x00,0x00,0x00,0x10,
+
+ 0x01,
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+
+ 'A',
+
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+
+ 0x00,0x00,
+ 0x43};
+
+ byte testPackRPS[120] = {0};
+
+ //RPS
+ CMessageParser msgParser;
+ CMessage* msgRPS = msgParser.Parse(testRPS,sizeof(testRPS));
+ CPPUNIT_ASSERT(msgRPS->GetMessageType() == MSG_RPS_TYPE);//֤ϢRPS
+ MSG_RPS* msg_rps = (MSG_RPS *)msgRPS;
+
+ CPPUNIT_ASSERT(msg_rps->GetSerial() == 1);
+
+ CPPUNIT_ASSERT(memcmp(msg_rps->GetGUID(),testParamO,sizeof(byte) * 16) == 0);
+
+ CPPUNIT_ASSERT(msg_rps->GetRank() == 0x01);
+
+ CPPUNIT_ASSERT(memcmp(msg_rps->GetNickname(),testParamO,sizeof(byte) * 16) == 0);
+
+ CPPUNIT_ASSERT(memcmp(msg_rps->GetAutograph(),testParamT,sizeof(byte) * 16) == 0);
+
+ CPPUNIT_ASSERT(msg_rps->GetHeadForm() == 'A');
+
+ CPPUNIT_ASSERT(memcmp(msg_rps->GetHeadPortrait(),testParamS,sizeof(byte) * 16) == 0);
+ delete msg_rps;
+
+ }
+
+ void MSGAPSParseTest()
+ {
+ byte testParamO [] = {0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02};
+ byte testParamT [] = {0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03};
+ byte testParamS [] = {0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04};
+
+ byte testAPS [] = {0x56,
+ 0x00,
+ 0x00,0x01,
+ 0x00,0x00,0x00,0x35,
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x19,
+ 0x00,0x00,0x00,0x00,
+ 0x01,
+
+ 0x00,0x00,0x00,0x10,
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x00,0x00,
+ 0x43};
+
+ byte testPackAPS[100] = {0};
+ //APS
+ CMessageParser msgParser;
+ CMessage* msgAPS = msgParser.Parse(testAPS,sizeof(testAPS));
+ CPPUNIT_ASSERT(msgAPS->GetMessageType() == MSG_APS_TYPE);//֤ϢRPS
+ MSG_APS* msg_aps = (MSG_APS *)msgAPS;
+
+ CPPUNIT_ASSERT(msg_aps->GetSerial() == 1);
+
+ CPPUNIT_ASSERT(memcmp(msg_aps->GetGUID(),testParamO,sizeof(byte) * 16) == 0);
+
+ CPPUNIT_ASSERT(memcmp(msg_aps->GetMessageSynchro(),testParamO,sizeof(byte) * 16) == 0);
+ delete msg_aps;
+ }
+
+ void MSGALIParseTest()
+ {
+ byte testParamO [] = {0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02};
+ byte testParamT [] = {0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03};
+ byte testParamS [] = {0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04};
+
+ byte testALI [] = {0x56,
+ 0x00,
+ 0x00,0x01,
+ 0x00,0x00,0x00,0x4E,
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x17,
+ 0x00,0x00,0x00,0x00,
+
+ 0x03,
+
+ 0x00,0x00,0x00,0x01,
+ 0x00,0x00,0x00,0x10,
+ 0x00,0x00,0x00,0x10,
+
+ 0x1e,
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+
+ 0x00,0x00,
+ 0x43};
+
+ byte testPackALI[100] = {0};
+
+ CMessageParser msgParser;
+ CMessage* msgALI = msgParser.Parse(testALI,sizeof(testALI));
+ CPPUNIT_ASSERT(msgALI->GetMessageType() == MSG_ALI_TYPE);//֤ϢALI
+ MSG_ALI* msg_ali = (MSG_ALI *)msgALI;
+
+ CPPUNIT_ASSERT(msg_ali->GetSerial() == 1);
+
+ CPPUNIT_ASSERT(memcmp(msg_ali->GetGUID(),testParamO,sizeof(byte) * 16) == 0);
+
+ CPPUNIT_ASSERT(msg_ali->GetLoginResult() == 0x1E);
+
+ CPPUNIT_ASSERT(memcmp(msg_ali->GetATLGUID(),testParamT,sizeof(byte) * 16) == 0);
+ delete msg_ali;
+ }
+
+};
+CPPUNIT_TEST_SUITE_REGISTRATION ( Vnocp1MessageParserTest );
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Vnocp1MessageParserTest, "Vnocp1MessageParserTest");
+
+#endif
\ No newline at end of file
diff --git a/VNOC/VNOC/test/testPackMessage.cpp b/Client/Client/CppUnitTest/testPackMessage.cpp
similarity index 78%
rename from VNOC/VNOC/test/testPackMessage.cpp
rename to Client/Client/CppUnitTest/testPackMessage.cpp
index 11b1f9ca..818c9faa 100644
--- a/VNOC/VNOC/test/testPackMessage.cpp
+++ b/Client/Client/CppUnitTest/testPackMessage.cpp
@@ -1,501 +1,638 @@
-
-#include
-#include
-#include "..\..\Message\PackMessage.h"
-#include
-
-
-class testPackMessage :public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE( testPackMessage );
- CPPUNIT_TEST( MSGAVCPackTest );
- CPPUNIT_TEST( MSGRVCPackTest );
- CPPUNIT_TEST( MSGALIPackTest );
- CPPUNIT_TEST( MSGRLIPackTest );
- CPPUNIT_TEST( MSGAPSPackTest );
- CPPUNIT_TEST( MSGRPSPackTest );
- CPPUNIT_TEST_SUITE_END();
-
-public:
- void setUp()
- {
-
- }
- void tearDown()
- {
-
- }
-
-public:
-
- void MSGAVCPackTest()
- {
- byte testParamO [] = {0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02};
- byte testParamT [] = {0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03};
- byte testParamS [] = {0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04};
-
- byte testAVC [] = {0x56,
- 0x00,
- 0x00,0x01,
- 0x00,0x00,0x00,0x3F,
-
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x15,
- 0x00,0x00,0x00,0x00,
- 0x03,
-
- 0x00,0x00,0x00,0x01,
- 0x00,0x00,0x00,0x01,
- 0x00,0x00,0x00,0x10,
-
- 0x1e,
-
- 0x1e,
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x00,0x00,
- 0x43};
-
-
- byte testPackAVC[63] = {0};
-
- //AVC
- MSG_AVC msg_avc;
- PackMessage msg_pack;
-
- msg_avc.SetSerial(1);
- CPPUNIT_ASSERT(msg_avc.GetSerial() == 1);
- msg_avc.SetGUID(testParamO);
- CPPUNIT_ASSERT(memcmp(msg_avc.GetGUID(),testParamO,sizeof(byte) * 16) == 0);
- //CPPUNIT_ASSERT(msg_avc.SetCmlListLen(testComLenAVC,3));
- msg_avc.SetCaptcha(testParamO,16);
- CPPUNIT_ASSERT(memcmp(msg_avc.GetCaptcha(),testParamO,16) == 0);
- msg_avc.SetLoginTag(0x1e);
- CPPUNIT_ASSERT(msg_avc.GetLoginTag() == 0x1e);
- msg_avc.SetCaptchaType(0x1e);
- CPPUNIT_ASSERT(msg_avc.GetCaptchaType() == 0x1e);
- CPPUNIT_ASSERT(msg_pack.Pack(&msg_avc,testPackAVC,msg_pack.GetMessageLen(&msg_avc)) != -1);
- //ȷԱ
- CPPUNIT_ASSERT(memcmp(testAVC,testPackAVC,sizeof(testAVC)) == 0);
-
- CPPUNIT_ASSERT(true);
- }
-
- void MSGRVCPackTest()
- {
- byte testParamO [] = {0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02};
- byte testParamT [] = {0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03};
- byte testParamS [] = {0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04};
-
- byte testRVC [] = {0x56,
- 0x00,
- 0x00,0x01,
- 0x00,0x00,0x00,0x35,
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x14,
- 0x00,0x00,0x00,0x00,
- 0x01,
-
- 0x00,0x00,0x00,0x10,
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x00,0x00,
- 0x43};
-
- byte testPackRVC[53] = {0};
- PackMessage msg_pack;
-
- //RVC
- MSG_RVC msg_rvc;
-
-
- msg_rvc.SetSerial(1);
-
- msg_rvc.SetGUID(testParamO);
- CPPUNIT_ASSERT(memcmp(msg_rvc.GetGUID(),testParamO,sizeof(byte) * 16) == 0);
- //CPPUNIT_ASSERT(msg_rvc.SetCmlListLen(testComLenRVC,1));
- msg_rvc.SetMachineAddress(testParamO,16);
- CPPUNIT_ASSERT(memcmp(msg_rvc.GetMachineAddress(),testParamO,16) == 0);
-
- CPPUNIT_ASSERT(msg_pack.Pack(&msg_rvc,testPackRVC,msg_pack.GetMessageLen(&msg_rvc)) != -1);
-
- //ȷԱ
- CPPUNIT_ASSERT(memcmp(testRVC,testPackRVC,sizeof(testRVC)) == 0);
-
- CPPUNIT_ASSERT(true);
- }
-
- void MSGRLIPackTest()
- {
- byte testParamO [] = {0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02};
- byte testParamT [] = {0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03};
- byte testParamS [] = {0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04};
-
- byte testRLI [] = {0x56,
- 0x00,
- 0x00,0x01,
- 0x00,0x00,0x00,0x5D,
-
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x16,
- 0x00,0x00,0x00,0x00,
-
- 0x03,
-
- 0x00,0x00,0x00,0x10,
- 0x00,0x00,0x00,0x10,
- 0x00,0x00,0x00,0x10,
-
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
-
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
-
- 0x00,0x00,
- 0x43};
-
- byte testPackRLI[100] = {0};
- //RLI
- MSG_RLI msg_rli;
- PackMessage msg_pack;
-
- msg_rli.SetSerial(1);
- CPPUNIT_ASSERT(msg_rli.GetSerial() == 1);
-
- msg_rli.SetGUID(testParamO);
- CPPUNIT_ASSERT(memcmp(msg_rli.GetGUID(),testParamO,sizeof(byte) * 16) == 0);
-
- //CPPUNIT_ASSERT(msg_rli.SetCmlListLen(testComLenRLI,3));
-
- msg_rli.SetVerificationCode(testParamO,16);
- CPPUNIT_ASSERT(memcmp(msg_rli.GetVerificationCode(),testParamO,sizeof(byte) * 16) == 0);
-
- msg_rli.SetAccountNumber(testParamT,16);
- CPPUNIT_ASSERT(memcmp(msg_rli.GetAccountNumber(),testParamT,16) == 0);
-
- msg_rli.SetPassword(testParamS,16);
- CPPUNIT_ASSERT(memcmp(msg_rli.GetPassword(),testParamS,16) == 0);
- CPPUNIT_ASSERT(msg_pack.Pack(&msg_rli,testPackRLI,msg_pack.GetMessageLen(&msg_rli)) != -1);
-
-
- //ȷԱ
- CPPUNIT_ASSERT(memcmp(testRLI,testPackRLI,sizeof(testRLI)) == 0);
-
- CPPUNIT_ASSERT(true);
- }
-
- void MSGRPSPackTest()
- {
- byte testParamO [] = {0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02};
- byte testParamT [] = {0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03};
- byte testParamS [] = {0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04};
-
-
- byte testRPS [] = {0x56,
- 0x00,
- 0x00,0x01,
- 0x00,0x00,0x00,0x67,
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x18,
- 0x00,0x00,0x00,0x00,
-
- 0x05,
-
- 0x00,0x00,0x00,0x01,
- 0x00,0x00,0x00,0x10,
- 0x00,0x00,0x00,0x10,
- 0x00,0x00,0x00,0x01,
- 0x00,0x00,0x00,0x10,
-
- 0x01,
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
-
- 'A',
-
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
-
- 0x00,0x00,
- 0x43};
-
- byte testPackRPS[120] = {0};
-
- //RPS
- MSG_RPS msg_rps;
- PackMessage msg_pack;
-
- msg_rps.SetSerial(1);
- CPPUNIT_ASSERT(msg_rps.GetSerial() == 1);
-
- msg_rps.SetGUID(testParamO);
- CPPUNIT_ASSERT(memcmp(msg_rps.GetGUID(),testParamO,sizeof(byte) * 16) == 0);
-
- //CPPUNIT_ASSERT(msg_rps.SetCmlListLen(testComLenRPS,5));
-
- msg_rps.SetRank(0x01);
- CPPUNIT_ASSERT(msg_rps.GetRank() == 0x01);
-
- msg_rps.SetNickname(testParamO,16);
- CPPUNIT_ASSERT(memcmp(msg_rps.GetNickname(),testParamO,sizeof(byte) * 16) == 0);
-
- msg_rps.SetAutograph(testParamT,16);
- CPPUNIT_ASSERT(memcmp(msg_rps.GetAutograph(),testParamT,sizeof(byte) * 16) == 0);
-
- msg_rps.SetHeadForm('A');
- CPPUNIT_ASSERT(msg_rps.GetHeadForm() == 'A');
-
- msg_rps.SetHeadPortrait(testParamS,16);
- CPPUNIT_ASSERT(memcmp(msg_rps.GetHeadPortrait(),testParamS,sizeof(byte) * 16) == 0);
-
- CPPUNIT_ASSERT(msg_pack.Pack(&msg_rps,testPackRPS,msg_pack.GetMessageLen(&msg_rps)) != -1);
-
- //ȷԱ
- CPPUNIT_ASSERT(memcmp(testRPS,testPackRPS,sizeof(testRPS)) == 0);
-
- CPPUNIT_ASSERT(true);
-
- }
-
- void MSGAPSPackTest()
- {
- byte testParamO [] = {0x01,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02};
- byte testParamT [] = {0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03};
- byte testParamS [] = {0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04};
-
- byte testAPS [] = {0x56,
- 0x00,
- 0x00,0x01,
- 0x00,0x00,0x00,0x35,
-
- 0x01,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x19,
- 0x00,0x00,0x00,0x00,
- 0x01,
-
- 0x00,0x00,0x00,0x10,
-
- 0x01,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x00,0x00,
- 0x43};
-
- byte testPackAPS[100] = {0};
- //APS
- MSG_APS msg_aps;
- PackMessage msg_pack;
-
- msg_aps.SetSerial(1);
-
- CPPUNIT_ASSERT(msg_aps.GetSerial() == 1);
-
- msg_aps.SetGUID(testParamO);
- CPPUNIT_ASSERT(memcmp(msg_aps.GetGUID(),testParamO,sizeof(byte) * 16) == 0);
-
- //CPPUNIT_ASSERT(msg_aps.SetCmlListLen(testComLenAPS,1));
-
-
- msg_aps.SetMessageSynchro(testParamO,16);
- CPPUNIT_ASSERT(memcmp(msg_aps.GetMessageSynchro(),testParamO,sizeof(byte) * 16) == 0);
-
- CPPUNIT_ASSERT(msg_pack.Pack(&msg_aps,testPackAPS,msg_pack.GetMessageLen(&msg_aps)) != -1);
-
- //ȷԱ
- int index = 0;
- for (;index < sizeof(testAPS); index++)
- {
- if (testAPS[index] != testPackAPS[index])
- {
- break;
- }
-
- }
- CPPUNIT_ASSERT(memcmp(testAPS,testPackAPS,sizeof(testAPS)) == 0);
-
- CPPUNIT_ASSERT(true);
- }
-
- void MSGALIPackTest()
- {
- byte testParamO [] = {0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02};
- byte testParamT [] = {0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03};
- byte testParamS [] = {0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04,
- 0x04,0x04,0x04,0x04};
-
- byte testALI [] = {0x56,
- 0x00,
- 0x00,0x01,
- 0x00,0x00,0x00,0x4E,
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x17,
- 0x00,0x00,0x00,0x00,
-
- 0x03,
-
- 0x00,0x00,0x00,0x01,
- 0x00,0x00,0x00,0x10,
- 0x00,0x00,0x00,0x10,
-
- 0x00,
-
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
- 0x02,0x02,0x02,0x02,
-
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
- 0x03,0x03,0x03,0x03,
-
- 0x00,0x00,
- 0x43};
-
- byte testPackALI[100] = {0};
-
- //ALI
- MSG_ALI msg_ali;
- PackMessage msg_pack;
-
- msg_ali.SetSerial(1);
- CPPUNIT_ASSERT(msg_ali.GetSerial() == 1);
-
- msg_ali.SetGUID(testParamO);
- CPPUNIT_ASSERT(memcmp(msg_ali.GetGUID(),testParamO,sizeof(byte) * 16) == 0);
-
- //CPPUNIT_ASSERT(msg_ali.SetCmlListLen(testComLenALI,3));
-
- msg_ali.SetLoginResult(0x0);
- CPPUNIT_ASSERT(msg_ali.GetLoginResult() == 0x0);
-
- msg_ali.SetToken(testParamO,16);
- //CPPUNIT_ASSERT(memcmp(msg_ali.GetToken(),testParamO,sizeof(byte) * 16) == 0);
-
- msg_ali.SetATLGUID(testParamT,16);
- CPPUNIT_ASSERT(memcmp(msg_ali.GetATLGUID(),testParamT,sizeof(byte) * 16) == 0);
- CPPUNIT_ASSERT(msg_pack.GetMessageLen(&msg_ali) == sizeof (testALI));
- CPPUNIT_ASSERT(msg_pack.Pack(&msg_ali,testPackALI,msg_pack.GetMessageLen(&msg_ali)) != -1);
-
- //ȷԱ
- CPPUNIT_ASSERT(memcmp(testALI,testPackALI,sizeof(testALI)) == 0);
-
- CPPUNIT_ASSERT(true);
- }
-
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION ( testPackMessage );
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(testPackMessage, "testPackMessage");
+#ifdef CPPTEST
+#include
+#include
+#include "..\..\Message\PackMessage.h"
+#include
+
+
+class testPackMessage :public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE( testPackMessage );
+ CPPUNIT_TEST( MSGAVCPackTest );
+ CPPUNIT_TEST( MSGRVCPackTest );
+ CPPUNIT_TEST( MSGALIPackTest );
+ CPPUNIT_TEST( MSGRLIPackTest );
+ CPPUNIT_TEST( MSGAPSPackTest );
+ CPPUNIT_TEST( MSGRPSPackTest );
+ CPPUNIT_TEST( MSGACIPackTest );
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+ void setUp()
+ {
+
+ }
+ void tearDown()
+ {
+
+ }
+
+public:
+
+ void MSGAVCPackTest()
+ {
+ byte testParamO [] = {0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02};
+ byte testParamT [] = {0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03};
+ byte testParamS [] = {0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04};
+
+ byte testAVC [] = {0x56,
+ 0x00,
+ 0x00,0x01,
+ 0x00,0x00,0x00,0x3F,
+
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x15,
+ 0x00,0x00,0x00,0x00,
+ 0x03,
+
+ 0x00,0x00,0x00,0x01,
+ 0x00,0x00,0x00,0x01,
+ 0x00,0x00,0x00,0x10,
+
+ 0x1e,
+
+ 0x1e,
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x00,0x00,
+ 0x43};
+
+
+ byte testPackAVC[63] = {0};
+
+ //AVC
+ MSG_AVC msg_avc;
+ PackMessage msg_pack;
+
+ msg_avc.SetSerial(1);
+ CPPUNIT_ASSERT(msg_avc.GetSerial() == 1);
+ msg_avc.SetGUID(testParamO);
+ CPPUNIT_ASSERT(memcmp(msg_avc.GetGUID(),testParamO,sizeof(byte) * 16) == 0);
+ //CPPUNIT_ASSERT(msg_avc.SetCmlListLen(testComLenAVC,3));
+ msg_avc.SetCaptcha(testParamO,16);
+ CPPUNIT_ASSERT(memcmp(msg_avc.GetCaptcha(),testParamO,16) == 0);
+ msg_avc.SetLoginTag(0x1e);
+ CPPUNIT_ASSERT(msg_avc.GetLoginTag() == 0x1e);
+ msg_avc.SetCaptchaType(0x1e);
+ CPPUNIT_ASSERT(msg_avc.GetCaptchaType() == 0x1e);
+ CPPUNIT_ASSERT(msg_pack.Pack(&msg_avc,testPackAVC,msg_pack.GetMessageLen(&msg_avc)) != -1);
+ //ȷԱ
+ CPPUNIT_ASSERT(memcmp(testAVC,testPackAVC,sizeof(testAVC)) == 0);
+
+ CPPUNIT_ASSERT(true);
+ }
+
+ void MSGRVCPackTest()
+ {
+ byte testParamO [] = {0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02};
+ byte testParamT [] = {0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03};
+ byte testParamS [] = {0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04};
+
+ byte testRVC [] = {0x56,
+ 0x00,
+ 0x00,0x01,
+ 0x00,0x00,0x00,0x35,
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x14,
+ 0x00,0x00,0x00,0x00,
+ 0x01,
+
+ 0x00,0x00,0x00,0x10,
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x00,0x00,
+ 0x43};
+
+ byte testPackRVC[53] = {0};
+ PackMessage msg_pack;
+
+ //RVC
+ MSG_RVC msg_rvc;
+
+
+ msg_rvc.SetSerial(1);
+
+ msg_rvc.SetGUID(testParamO);
+ CPPUNIT_ASSERT(memcmp(msg_rvc.GetGUID(),testParamO,sizeof(byte) * 16) == 0);
+ //CPPUNIT_ASSERT(msg_rvc.SetCmlListLen(testComLenRVC,1));
+ msg_rvc.SetMachineAddress(testParamO,16);
+ CPPUNIT_ASSERT(memcmp(msg_rvc.GetMachineAddress(),testParamO,16) == 0);
+
+ CPPUNIT_ASSERT(msg_pack.Pack(&msg_rvc,testPackRVC,msg_pack.GetMessageLen(&msg_rvc)) != -1);
+
+ //ȷԱ
+ CPPUNIT_ASSERT(memcmp(testRVC,testPackRVC,sizeof(testRVC)) == 0);
+
+ CPPUNIT_ASSERT(true);
+ }
+
+ void MSGRLIPackTest()
+ {
+ byte testParamO [] = {0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02};
+ byte testParamT [] = {0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03};
+ byte testParamS [] = {0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04};
+
+ byte testRLI [] = {0x56,
+ 0x00,
+ 0x00,0x01,
+ 0x00,0x00,0x00,0x5D,
+
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x16,
+ 0x00,0x00,0x00,0x00,
+
+ 0x03,
+
+ 0x00,0x00,0x00,0x10,
+ 0x00,0x00,0x00,0x10,
+ 0x00,0x00,0x00,0x10,
+
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+
+ 0x00,0x00,
+ 0x43};
+
+ byte testPackRLI[100] = {0};
+ //RLI
+ MSG_RLI msg_rli;
+ PackMessage msg_pack;
+
+ msg_rli.SetSerial(1);
+ CPPUNIT_ASSERT(msg_rli.GetSerial() == 1);
+
+ msg_rli.SetGUID(testParamO);
+ CPPUNIT_ASSERT(memcmp(msg_rli.GetGUID(),testParamO,sizeof(byte) * 16) == 0);
+
+ //CPPUNIT_ASSERT(msg_rli.SetCmlListLen(testComLenRLI,3));
+
+ msg_rli.SetVerificationCode(testParamO,16);
+ CPPUNIT_ASSERT(memcmp(msg_rli.GetVerificationCode(),testParamO,sizeof(byte) * 16) == 0);
+
+ msg_rli.SetAccountNumber(testParamT,16);
+ CPPUNIT_ASSERT(memcmp(msg_rli.GetAccountNumber(),testParamT,16) == 0);
+
+ msg_rli.SetPassword(testParamS,16);
+ CPPUNIT_ASSERT(memcmp(msg_rli.GetPassword(),testParamS,16) == 0);
+ CPPUNIT_ASSERT(msg_pack.Pack(&msg_rli,testPackRLI,msg_pack.GetMessageLen(&msg_rli)) != -1);
+
+
+ //ȷԱ
+ CPPUNIT_ASSERT(memcmp(testRLI,testPackRLI,sizeof(testRLI)) == 0);
+
+ CPPUNIT_ASSERT(true);
+ }
+
+ void MSGRPSPackTest()
+ {
+ byte testParamO [] = {0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02};
+ byte testParamT [] = {0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03};
+ byte testParamS [] = {0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04};
+
+
+ byte testRPS [] = {0x56,
+ 0x00,
+ 0x00,0x01,
+ 0x00,0x00,0x00,0x67,
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x18,
+ 0x00,0x00,0x00,0x00,
+
+ 0x05,
+
+ 0x00,0x00,0x00,0x01,
+ 0x00,0x00,0x00,0x10,
+ 0x00,0x00,0x00,0x10,
+ 0x00,0x00,0x00,0x01,
+ 0x00,0x00,0x00,0x10,
+
+ 0x01,
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+
+ 'A',
+
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+
+ 0x00,0x00,
+ 0x43};
+
+ byte testPackRPS[120] = {0};
+
+ //RPS
+ MSG_RPS msg_rps;
+ PackMessage msg_pack;
+
+ msg_rps.SetSerial(1);
+ CPPUNIT_ASSERT(msg_rps.GetSerial() == 1);
+
+ msg_rps.SetGUID(testParamO);
+ CPPUNIT_ASSERT(memcmp(msg_rps.GetGUID(),testParamO,sizeof(byte) * 16) == 0);
+
+ //CPPUNIT_ASSERT(msg_rps.SetCmlListLen(testComLenRPS,5));
+
+ msg_rps.SetRank(0x01);
+ CPPUNIT_ASSERT(msg_rps.GetRank() == 0x01);
+
+ msg_rps.SetNickname(testParamO,16);
+ CPPUNIT_ASSERT(memcmp(msg_rps.GetNickname(),testParamO,sizeof(byte) * 16) == 0);
+
+ msg_rps.SetAutograph(testParamT,16);
+ CPPUNIT_ASSERT(memcmp(msg_rps.GetAutograph(),testParamT,sizeof(byte) * 16) == 0);
+
+ msg_rps.SetHeadForm('A');
+ CPPUNIT_ASSERT(msg_rps.GetHeadForm() == 'A');
+
+ msg_rps.SetHeadPortrait(testParamS,16);
+ CPPUNIT_ASSERT(memcmp(msg_rps.GetHeadPortrait(),testParamS,sizeof(byte) * 16) == 0);
+
+ CPPUNIT_ASSERT(msg_pack.Pack(&msg_rps,testPackRPS,msg_pack.GetMessageLen(&msg_rps)) != -1);
+
+ //ȷԱ
+
+ CPPUNIT_ASSERT(memcmp(testRPS,testPackRPS,sizeof(testRPS)) == 0);
+
+ CPPUNIT_ASSERT(true);
+
+ }
+
+ void MSGAPSPackTest()
+ {
+ byte testParamO [] = {0x01,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02};
+ byte testParamT [] = {0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03};
+ byte testParamS [] = {0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04};
+
+ byte testAPS [] = {0x56,
+ 0x00,
+ 0x00,0x01,
+ 0x00,0x00,0x00,0x35,
+
+ 0x01,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x19,
+ 0x00,0x00,0x00,0x00,
+ 0x01,
+
+ 0x00,0x00,0x00,0x10,
+
+ 0x01,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x00,0x00,
+ 0x43};
+
+ byte testPackAPS[100] = {0};
+ //APS
+ MSG_APS msg_aps;
+ PackMessage msg_pack;
+
+ msg_aps.SetSerial(1);
+
+ CPPUNIT_ASSERT(msg_aps.GetSerial() == 1);
+
+ msg_aps.SetGUID(testParamO);
+ CPPUNIT_ASSERT(memcmp(msg_aps.GetGUID(),testParamO,sizeof(byte) * 16) == 0);
+
+ //CPPUNIT_ASSERT(msg_aps.SetCmlListLen(testComLenAPS,1));
+
+
+ msg_aps.SetMessageSynchro(testParamO,16);
+ CPPUNIT_ASSERT(memcmp(msg_aps.GetMessageSynchro(),testParamO,sizeof(byte) * 16) == 0);
+
+ CPPUNIT_ASSERT(msg_pack.Pack(&msg_aps,testPackAPS,msg_pack.GetMessageLen(&msg_aps)) != -1);
+
+ //ȷԱ
+ int index = 0;
+ for (;index < sizeof(testAPS); index++)
+ {
+ if (testAPS[index] != testPackAPS[index])
+ {
+ break;
+ }
+
+ }
+ CPPUNIT_ASSERT(memcmp(testAPS,testPackAPS,sizeof(testAPS)) == 0);
+
+ CPPUNIT_ASSERT(true);
+ }
+
+ void MSGALIPackTest()
+ {
+ byte testParamO [] = {0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02};
+ byte testParamT [] = {0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03};
+ byte testParamS [] = {0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04};
+
+ byte testALI [] = {0x56,
+ 0x00,
+ 0x00,0x01,
+ 0x00,0x00,0x00,0x4E,
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x17,
+ 0x00,0x00,0x00,0x00,
+
+ 0x03,
+
+ 0x00,0x00,0x00,0x01,
+ 0x00,0x00,0x00,0x10,
+ 0x00,0x00,0x00,0x10,
+
+ 0x00,
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+
+ 0x00,0x00,
+ 0x43};
+
+ byte testPackALI[100] = {0};
+
+ //ALI
+ MSG_ALI msg_ali;
+ PackMessage msg_pack;
+
+ msg_ali.SetSerial(1);
+ CPPUNIT_ASSERT(msg_ali.GetSerial() == 1);
+
+ msg_ali.SetGUID(testParamO);
+ CPPUNIT_ASSERT(memcmp(msg_ali.GetGUID(),testParamO,sizeof(byte) * 16) == 0);
+
+ //CPPUNIT_ASSERT(msg_ali.SetCmlListLen(testComLenALI,3));
+
+ msg_ali.SetLoginResult(0x0);
+ CPPUNIT_ASSERT(msg_ali.GetLoginResult() == 0x0);
+
+ msg_ali.SetToken(testParamO,16);
+ //CPPUNIT_ASSERT(memcmp(msg_ali.GetToken(),testParamO,sizeof(byte) * 16) == 0);
+
+ msg_ali.SetATLGUID(testParamT,16);
+ CPPUNIT_ASSERT(memcmp(msg_ali.GetATLGUID(),testParamT,sizeof(byte) * 16) == 0);
+ CPPUNIT_ASSERT(msg_pack.GetMessageLen(&msg_ali) == sizeof (testALI));
+ CPPUNIT_ASSERT(msg_pack.Pack(&msg_ali,testPackALI,msg_pack.GetMessageLen(&msg_ali)) != -1);
+
+ //ȷԱ
+ CPPUNIT_ASSERT(memcmp(testALI,testPackALI,sizeof(testALI)) == 0);
+
+ CPPUNIT_ASSERT(true);
+ }
+
+ void MSGACIPackTest()
+ {
+ byte testParamO [] = {0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02};
+ byte testParamT [] = {0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03};
+ byte testParamS [] = {0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04};
+
+ byte testACI [] = {0x56,
+ 0x00,
+ 0x00,0x01,
+ 0x00,0x00,0x00,0x8D,
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x21,
+ 0x00,0x00,0x00,0x00,
+
+ 0x0A,
+
+ 0x00,0x00,0x00,0x04,
+ 0x00,0x00,0x00,0x04,
+ 0x00,0x00,0x00,0x10,
+ 0x00,0x00,0x00,0x04,
+ 0x00,0x00,0x00,0x04,
+ 0x00,0x00,0x00,0x10,
+ 0x00,0x00,0x00,0x04,
+ 0x00,0x00,0x00,0x04,
+ 0x00,0x00,0x00,0x08,
+ 0x00,0x00,0x00,0x04,
+
+ 0x00,0x00,0x00,0x01,
+
+ 0x00,0x00,0x00,0x01,
+
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,
+
+ 0x00,0x00,0x00,0x01,
+
+ 0x00,0x00,0x00,0x01,
+
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,
+
+ 0x00,0x00,0x00,0x01,
+
+ 0x00,0x00,0x00,0x01,
+
+ 0x00,0x00,0x00,0x0A,
+ 0x00,0x00,0x00,0x0B,
+
+ 0x00,0x00,0x00,0x01,
+
+ 0x00,0x00,
+ 0x43};
+
+ byte testPackACI[141] = {0};
+
+ //ACI
+ MSG_ACI msg_aci;
+ PackMessage msg_pack;
+
+
+
+ msg_aci.SetSerial(1);
+ CPPUNIT_ASSERT(msg_aci.GetSerial() == 1);
+
+ msg_aci.SetGUID(testParamO);
+ CPPUNIT_ASSERT(memcmp(msg_aci.GetGUID(),testParamO,sizeof(byte) * 16) == 0);
+
+ msg_aci.SetRoomID(1);
+ CPPUNIT_ASSERT(msg_aci.GetRoomID() == 1);
+
+ msg_aci.SetRoomManageID(1);
+ CPPUNIT_ASSERT(msg_aci.GetRoomManageID() == 1);
+
+ msg_aci.SetRoomName(testParamO,16);
+ CPPUNIT_ASSERT(memcmp(msg_aci.GetRoomName(),testParamO,sizeof(byte) * 16) == 0);
+
+ msg_aci.SetRoomPassword(testParamT,16);
+ CPPUNIT_ASSERT(memcmp(msg_aci.GetRoomPassword(),testParamT,sizeof(byte) * 16) == 0);
+
+ std::vector inList;
+ std::vector outList;
+ inList.push_back(10);
+ inList.push_back(11);
+ msg_aci.SetRoomPeopleList(inList);
+
+/*
+ msg_aci.GetRoomPeopleList(outList);
+ CPPUNIT_ASSERT(outList[0] == 10);
+ CPPUNIT_ASSERT(outList[1] == 11);*/
+
+ msg_aci.SetRoomPeopleNum(1);
+ CPPUNIT_ASSERT(msg_aci.GetRoomPeopleNum() == 1);
+
+ msg_aci.SetRoomPeopleNumMax(1);
+ CPPUNIT_ASSERT(msg_aci.GetRoomPeopleNumMax() == 1);
+
+ msg_aci.SetRoomRank(1);
+ CPPUNIT_ASSERT(msg_aci.GetRoomRank() == 1);
+
+ msg_aci.SetRoomState(1);
+ CPPUNIT_ASSERT(msg_aci.GetRoomState() == 1);
+
+ msg_aci.SetRoomType(1);
+ CPPUNIT_ASSERT(msg_aci.GetRoomType() == 1);
+
+
+ CPPUNIT_ASSERT(msg_pack.GetMessageLen(&msg_aci) == sizeof (testACI));
+ CPPUNIT_ASSERT(msg_pack.Pack(&msg_aci,testPackACI,msg_pack.GetMessageLen(&msg_aci)) != -1);
+
+
+ //int a = CheckMsgTrue(testACI,testPackACI,sizeof(testACI));
+ CPPUNIT_ASSERT(memcmp(testACI,testPackACI,sizeof(testACI)) == 0);
+
+ CPPUNIT_ASSERT(true);
+ }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION ( testPackMessage );
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(testPackMessage, "testPackMessage");
+
+#endif
\ No newline at end of file
diff --git a/Client/Client/CppUnitTest/testRunner.cpp b/Client/Client/CppUnitTest/testRunner.cpp
new file mode 100644
index 00000000..acc881e6
--- /dev/null
+++ b/Client/Client/CppUnitTest/testRunner.cpp
@@ -0,0 +1,28 @@
+#ifdef CPPTEST
+#include "Stdafx.h"
+#include "testRunner.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+VOID CTestRunner::StartTest(XMessage_StartTest* msg)
+{
+ CppUnit::TestResult controller;
+ CppUnit::TestResultCollector result;
+
+ CppUnit::TextUi::TestRunner runner;
+ CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
+ runner.addTest( registry.makeTest() );
+ runner.eventManager().addListener( &result );
+ runner.run();
+
+ std::ofstream xmlFileOut("cpptestresults.xml");
+ CppUnit::XmlOutputter xmlOut(&result, xmlFileOut);
+ xmlOut.write();
+}
+
+#endif
\ No newline at end of file
diff --git a/Client/Client/CppUnitTest/testRunner.h b/Client/Client/CppUnitTest/testRunner.h
new file mode 100644
index 00000000..13690fb0
--- /dev/null
+++ b/Client/Client/CppUnitTest/testRunner.h
@@ -0,0 +1,14 @@
+#include "../FrameWork/FrameBase.hpp"
+
+class CTestRunner : public CFrameBase
+{
+public:
+ CTestRunner():CFrameBase(module_CppTestMain)
+ {};
+
+ VOID StartTest(XMessage_StartTest* msg);
+
+ Begin_XMessage(CTestRunner)
+ OnXMessage(XMessage_StartTest,StartTest)
+ End_XMessage()
+};
\ No newline at end of file
diff --git a/Client/Client/FrameWork/Factory.cpp b/Client/Client/FrameWork/Factory.cpp
new file mode 100644
index 00000000..90896a96
--- /dev/null
+++ b/Client/Client/FrameWork/Factory.cpp
@@ -0,0 +1,53 @@
+#include "stdafx.h"
+#include "Factory.h"
+
+#include "../Logic/room/Room.h"
+#include "../Logic/room/RoomMgr.h"
+#include "../Logic/UserSession/LoginImpl.h"
+
+#include "../GUI/LoginWin/BKWinLogin.h"
+#include "../GUI/RoomListWin/BKWinRoomList.h"
+#include "../gui/RoomWin/BKWinClassroom.h"
+
+#ifdef CPPTEST
+#include "../CppUnitTest/testRunner.h"
+#endif
+
+ResultCode CFrameModuleFactory::CreateFrameModule( FrameModule module,IFrameModule** ppModule )
+{
+ if (!ppModule)
+ {
+ return Result_InvalidParam;
+ }
+ *ppModule = NULL;
+ switch(module)
+ {
+ case module_LoginData:
+ *ppModule = new CLoginImpl;
+ break;
+ case module_LoginWin:
+ *ppModule = new CLoginWnd;
+ break;
+ case module_RoomListData:
+ *ppModule = new CRoomMgr;
+ break;
+ case module_RoomListWin:
+ *ppModule = new CRoomListWnd;
+ break;
+ case module_ClassroomWinData:
+ *ppModule = new CRoomBase;
+ break;
+ case module_ClassroomWin:
+ *ppModule = new CClassroomWnd;
+ break;
+#ifdef CPPTEST
+ case module_CppTestMain:
+ *ppModule = new CTestRunner;
+ break;
+#endif
+ default:
+ ATLASSERT(FALSE && "invalid module");
+ return Result_NotFound;
+ }
+ return Result_Success;
+}
diff --git a/Client/Client/FrameWork/Factory.h b/Client/Client/FrameWork/Factory.h
new file mode 100644
index 00000000..5aa5577f
--- /dev/null
+++ b/Client/Client/FrameWork/Factory.h
@@ -0,0 +1,8 @@
+#pragma once
+#include "IFrameWork.h"
+
+class CFrameModuleFactory
+{
+public:
+ static ResultCode CreateFrameModule(FrameModule module,IFrameModule** ppModule);
+};
diff --git a/Client/Client/FrameWork/FrameBase.hpp b/Client/Client/FrameWork/FrameBase.hpp
new file mode 100644
index 00000000..983789c4
--- /dev/null
+++ b/Client/Client/FrameWork/FrameBase.hpp
@@ -0,0 +1,130 @@
+#pragma once
+#include "IFrameWork.h"
+#include "IRefCountImpl.h"
+#include
+#include
+
+struct XMessage : public IRefCountImpl
+{
+ virtual VOID GetID(CString& id) = 0;
+
+ XMessage()
+ : destModule(module_Any)
+ , srcModule(module_Any)
+ , result(Result_NotSet)
+ {
+ }
+
+ VOID MarkProcessed(ResultCode result)
+ {
+ ATLASSERT(result != Result_NotSet);
+ this->result = result;
+ }
+ BOOL IsProcessed()
+ {
+ return result != Result_NotSet;
+ }
+
+ FrameModule destModule;
+ FrameModule srcModule;
+
+ ResultCode result;
+};
+
+class CFrameBase : public IFrameModule
+{
+public:
+ CFrameBase(FrameModule module)
+ : m_moduleType(module)
+ {
+ }
+ virtual ~CFrameBase()
+ {
+ }
+ ResultCode SendXMessage(XMessage* msg)
+ {
+ ATLASSERT(msg);
+ IFrameWork* pFrameWork;
+ Global->GetIFrameModule(&pFrameWork);
+ Global->PtrAssert(pFrameWork);
+ return pFrameWork->SendXMessage(msg);
+ }
+ FrameModule GetModuleType()
+ {
+ return m_moduleType;
+ }
+ virtual BOOL IsView()
+ {
+ return GetModuleType()>module_ViewBegin && GetModuleType()GetID(msgID); \
+ } \
+ else \
+ { \
+ pListMsg = dynamic_cast(pMsgGetList); \
+ if (!pListMsg) \
+ { \
+ return Result_FatalError; \
+ } \
+ } \
+
+#define OnXMessage(_msg,_proc) \
+ if (pListMsg) \
+ { \
+ CString id; \
+ _msg::Static_GetID(id); \
+ pListMsg->msgIDList.push_back(id); \
+ } \
+ if ( pmsg && _msg::Static_IsTypeOf(msgID) ) \
+ { \
+ _proc((_msg*)pmsg); \
+ }
+
+#define Chain_XMessage(_class) \
+ {} \
+ { \
+ _class::ProcessXMessage(pmsg); \
+ }
+
+#define End_XMessage() \
+ {} \
+ return Result_Success; \
+ }
+
+#define ImTheMessageOf(_msg) \
+public: \
+ virtual VOID GetID(CString& id) \
+ { \
+ Static_GetID(id); \
+ } \
+ static VOID Static_GetID(CString& id) \
+ { \
+ id = #_msg; \
+ } \
+ static BOOL Static_IsTypeOf(LPCTSTR id) \
+ { \
+ CString tempID; \
+ Static_GetID(tempID); \
+ return (tempID.CompareNoCase(id)==0)? TRUE: FALSE; \
+ }
diff --git a/Client/Client/FrameWork/FrameWork.cpp b/Client/Client/FrameWork/FrameWork.cpp
new file mode 100644
index 00000000..d2bb8f5b
--- /dev/null
+++ b/Client/Client/FrameWork/FrameWork.cpp
@@ -0,0 +1,239 @@
+#include "stdafx.h"
+#include "FrameWork.h"
+#include "Factory.h"
+
+CFrameWork::CFrameWork()
+{
+
+}
+
+CFrameWork::~CFrameWork()
+{
+
+}
+
+ResultCode CFrameWork::Initialize( IModule* UpperFrame/*=NULL*/ )
+{
+#ifndef CPPTEST
+ _InitUILib();
+#else
+ _InitTest();
+#endif
+ _LoadModule();
+ return Result_Success;
+}
+
+ResultCode CFrameWork::UnInitialize()
+{
+ _ClearModule();
+ return Result_Success;
+}
+
+ResultCode CFrameWork::Run()
+{
+#ifndef CPPTEST
+ XMessage_FrameStart firstMessage;
+#else
+ XMessage_StartTest firstMessage;
+#endif
+ SendXMessage(&firstMessage);
+ return Result_Success;
+}
+
+ResultCode CFrameWork::Terminate()
+{
+ return Result_Success;
+}
+
+ResultCode CFrameWork::RegisterModule( IFrameModule* iModule )
+{
+ FrameModule module;
+ module = iModule->GetModuleType();
+ ATLASSERT(module != module_Invalid);
+ Util::CAutoCS ac(m_mapcs);
+ m_map[module] = iModule;
+
+ _GetModulesListenList(module);
+ iModule->Initialize(this);
+ iModule->Run();
+ return Result_Success;
+}
+
+ResultCode CFrameWork::GetModule( IFrameModule** piModule,FrameModule module )
+{
+ Util::CAutoCS ac(m_mapcs);
+ if (piModule == NULL)
+ {
+ return Result_InvalidParam;
+ }
+ IFrameModule* var = _FindModule(module);
+ if (var)
+ {
+ *piModule = var;
+ return Result_Success;
+ }
+ return Result_Fail;
+}
+
+ResultCode CFrameWork::RemoveModule( IFrameModule* iModule )
+{
+ Util::CAutoCS ac(m_mapcs);
+
+ for (auto i=m_map.begin(); i!=m_map.end();)
+ {
+ if (!iModule || (i->second==iModule))
+ {
+ if (i->second)
+ {
+ i->second->Terminate();
+ i->second->UnInitialize();
+ }
+ i = m_map.erase(i);
+ }
+ else
+ {
+ ++i;
+ }
+ }
+ return Result_Success;
+}
+
+IFrameModule* CFrameWork::_FindModule( FrameModule module )
+{
+ Util::CAutoCS ac(m_mapcs);
+ auto i = m_map.find(module);
+ if (i != m_map.end())
+ {
+ return i->second;
+ }
+ return NULL;
+}
+
+ResultCode CFrameWork::SendXMessage( XMessage* pMsg )
+{
+ Util::CAutoCS ac(m_mapcs);
+ if (pMsg->destModule == module_Any)
+ { // broadcast
+ Util::CAutoCS ac(m_msgMapCS);
+
+ CString strID;
+ pMsg->GetID(strID);
+ auto& moduleSet = m_msgMap[strID];
+ for (auto i=moduleSet.begin(); i!=moduleSet.end() && !pMsg->IsProcessed(); ++i)
+ {
+ IFrameModule* pModule = m_map[*i];
+ if (pModule)
+ {
+ pModule->ProcessXMessage(pMsg);
+ }
+ }
+ }
+ else
+ {
+ auto i = m_map.find(pMsg->destModule);
+ if (i != m_map.end())
+ {
+ i->second->ProcessXMessage(pMsg);
+ }
+ else
+ {
+ return Result_Fail;
+ }
+ }
+ return Result_Success;
+}
+
+VOID CFrameWork::_ClearModule()
+{
+ RemoveModule(NULL);
+}
+
+VOID CFrameWork::_LoadModule()
+{
+ int i;
+ for (i = module_DataBegin + 1; i < module_DataEnd; ++i)
+ {
+ _LoadModule(static_cast(i));
+ }
+
+#ifndef CPPTEST
+
+ for (i = module_ViewBegin + 1; i < module_ViewEnd; ++i)
+ {
+ _LoadModule(static_cast(i));
+ }
+
+#else
+
+ for (i = module_CppTestBegin + 1; i < module_CppTestEnd; ++i)
+ {
+ _LoadModule(static_cast(i));
+ }
+
+#endif
+}
+
+VOID CFrameWork::_LoadModule( FrameModule module )
+{
+ IFrameModule *pModule=NULL;
+ CFrameModuleFactory::CreateFrameModule(module,&pModule);
+ if (pModule)
+ {
+ RegisterModule(pModule);
+ }
+}
+
+VOID CFrameWork::_GetModulesListenList(FrameModule module)
+{
+ if (module == module_Any)
+ {
+ XMessage_GetListenList msg;
+ Util::CAutoCS ac(m_mapcs);
+ for (auto i=m_map.begin(); i!=m_map.end(); ++i)
+ {
+ msg.msgIDList.clear();
+ i->second->ProcessXMessage(NULL,&msg);
+
+ Util::CAutoCS ac(m_msgMapCS);
+ for (auto j=msg.msgIDList.begin(); j!=msg.msgIDList.end(); ++j)
+ {
+ m_msgMap[*j].insert( i->first );
+ }
+ }
+ }
+ else
+ {
+ Util::CAutoCS ac(m_mapcs);
+ auto i = m_map.find(module);
+ if (i != m_map.end())
+ {
+ XMessage_GetListenList msg;
+ i->second->ProcessXMessage(NULL,&msg);
+
+ Util::CAutoCS ac(m_msgMapCS);
+ for (auto j=msg.msgIDList.begin(); j!=msg.msgIDList.end(); ++j)
+ {
+ m_msgMap[*j].insert( i->first );
+ }
+ }
+ }
+}
+
+VOID CFrameWork::_InitUILib()
+{
+ BkFontPool::SetDefaultFont(_T("Courier New"), -12);
+ BkSkin::LoadSkins(IDR_XML_SKIN_DEF);
+ BkStyle::LoadStyles(IDR_BK_STYLE_DEF);
+ CString strPath;
+ GetModuleFileName(nullptr,strPath.GetBuffer(MAX_PATH),MAX_PATH);
+ strPath.ReleaseBuffer();
+ Util::Filesys::SplitPath(strPath,strPath,CString());
+ strPath += BKWinResDir;
+ Global->Logf(LogFile_FrameWork,_T("ʼԴļ: %s"),strPath);
+ BkResManager::SetResourcePath(strPath);
+}
+
+VOID CFrameWork::_InitTest()
+{
+}
+
diff --git a/Client/Client/FrameWork/FrameWork.h b/Client/Client/FrameWork/FrameWork.h
new file mode 100644
index 00000000..2de0a889
--- /dev/null
+++ b/Client/Client/FrameWork/FrameWork.h
@@ -0,0 +1,38 @@
+#pragma once
+#include "IFrameWork.h"
+#include
+#include