MiscellaneousTestsTest.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. #include "MiscellaneousTestsTest.h"
  11. /*
  12. Description:
  13. Tests:
  14. virtual void SetRouterInterface (RouterInterface *routerInterface)=0
  15. virtual void RemoveRouterInterface (RouterInterface *routerInterface)=0
  16. virtual bool AdvertiseSystem (const char *host, unsigned short remotePort, const char *data, int dataLength, unsigned connectionSocketIndex=0)=0
  17. Success conditions:
  18. Failure conditions:
  19. RakPeerInterface Functions used, tested indirectly by its use,list may not be complete:
  20. Startup
  21. SetMaximumIncomingConnections
  22. Receive
  23. DeallocatePacket
  24. Send
  25. RakPeerInterface Functions Explicitly Tested:
  26. SetRouterInterface
  27. RemoveRouterInterface
  28. AdvertiseSystem
  29. */
  30. int MiscellaneousTestsTest::RunTest(DataStructures::List<RakString> params,bool isVerbose,bool noPauses)
  31. { destroyList.Clear(false,_FILE_AND_LINE_);
  32. RakPeerInterface *client,*server;
  33. TestHelpers::StandardClientPrep(client,destroyList);
  34. TestHelpers::StandardServerPrep(server,destroyList);
  35. printf("Testing AdvertiseSystem\n");
  36. client->AdvertiseSystem("127.0.0.1",60000,0,0);
  37. if (!CommonFunctions::WaitForMessageWithID(server,ID_ADVERTISE_SYSTEM,5000))
  38. {
  39. if (isVerbose)
  40. DebugTools::ShowError(errorList[1-1],!noPauses && isVerbose,__LINE__,__FILE__);
  41. return 1;
  42. }
  43. return 0;
  44. }
  45. RakString MiscellaneousTestsTest::GetTestName()
  46. {
  47. return "MiscellaneousTestsTest";
  48. }
  49. RakString MiscellaneousTestsTest::ErrorCodeToString(int errorCode)
  50. {
  51. if (errorCode>0&&(unsigned int)errorCode<=errorList.Size())
  52. {
  53. return errorList[errorCode-1];
  54. }
  55. else
  56. {
  57. return "Undefined Error";
  58. }
  59. }
  60. void MiscellaneousTestsTest::DestroyPeers()
  61. {
  62. int theSize=destroyList.Size();
  63. for (int i=0; i < theSize; i++)
  64. RakPeerInterface::DestroyInstance(destroyList[i]);
  65. }
  66. MiscellaneousTestsTest::MiscellaneousTestsTest(void)
  67. {
  68. errorList.Push("Did not recieve client advertise",_FILE_AND_LINE_);
  69. errorList.Push("The router interface should not be called because no send has happened yet",_FILE_AND_LINE_);
  70. errorList.Push("Router failed to trigger on failed directed send",_FILE_AND_LINE_);
  71. errorList.Push("Router was not properly removed",_FILE_AND_LINE_);
  72. }
  73. MiscellaneousTestsTest::~MiscellaneousTestsTest(void)
  74. {
  75. }
粤ICP备19079148号