PageRenderTime 41ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/tests/llremoteparcelrequest_test.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 134 lines | 86 code | 23 blank | 25 comment | 0 complexity | 8d447186db1079b6bb598d24c684e52b MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llremoteparcelrequest_test.cpp
  3. * @author Brad Kittenbrink <brad@lindenlab.com>
  4. *
  5. * $LicenseInfo:firstyear=2010&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "linden_common.h"
  27. #include "../test/lltut.h"
  28. #include "../llremoteparcelrequest.h"
  29. #include "../llagent.h"
  30. #include "message.h"
  31. #include "llurlentry.h"
  32. namespace {
  33. const LLUUID TEST_PARCEL_ID("11111111-1111-1111-1111-111111111111");
  34. }
  35. LLCurl::Responder::Responder() { }
  36. LLCurl::Responder::~Responder() { }
  37. void LLCurl::Responder::error(U32,std::string const &) { }
  38. void LLCurl::Responder::result(LLSD const &) { }
  39. void LLCurl::Responder::errorWithContent(U32 status,std::string const &,LLSD const &) { }
  40. void LLCurl::Responder::completedRaw(U32 status, std::string const &, LLChannelDescriptors const &,boost::shared_ptr<LLBufferArray> const &) { }
  41. void LLCurl::Responder::completed(U32 status, std::string const &, LLSD const &) { }
  42. void LLCurl::Responder::completedHeader(U32 status, std::string const &, LLSD const &) { }
  43. void LLMessageSystem::getF32(char const *,char const *,F32 &,S32) { }
  44. void LLMessageSystem::getU8(char const *,char const *,U8 &,S32) { }
  45. void LLMessageSystem::getS32(char const *,char const *,S32 &,S32) { }
  46. void LLMessageSystem::getString(char const *,char const *, std::string &,S32) { }
  47. void LLMessageSystem::getUUID(char const *,char const *, LLUUID & out_id,S32)
  48. {
  49. out_id = TEST_PARCEL_ID;
  50. }
  51. void LLMessageSystem::nextBlock(char const *) { }
  52. void LLMessageSystem::addUUID(char const *,LLUUID const &) { }
  53. void LLMessageSystem::addUUIDFast(char const *,LLUUID const &) { }
  54. void LLMessageSystem::nextBlockFast(char const *) { }
  55. void LLMessageSystem::newMessage(char const *) { }
  56. LLMessageSystem * gMessageSystem;
  57. char const* const _PREHASH_AgentID = 0; // never dereferenced during this test
  58. char const* const _PREHASH_AgentData = 0; // never dereferenced during this test
  59. LLAgent gAgent;
  60. LLAgent::LLAgent() : mAgentAccess(NULL) { }
  61. LLAgent::~LLAgent() { }
  62. void LLAgent::sendReliableMessage(void) { }
  63. LLUUID gAgentSessionID;
  64. LLUUID gAgentID;
  65. LLUIColor::LLUIColor(void) { }
  66. LLControlGroup::LLControlGroup(std::string const & name) : LLInstanceTracker<LLControlGroup, std::string>(name) { }
  67. LLControlGroup::~LLControlGroup(void) { }
  68. void LLUrlEntryParcel::processParcelInfo(const LLUrlEntryParcel::LLParcelData& parcel_data) { }
  69. namespace tut
  70. {
  71. struct TestObserver : public LLRemoteParcelInfoObserver {
  72. TestObserver() : mProcessed(false) { }
  73. virtual void processParcelInfo(const LLParcelData& parcel_data)
  74. {
  75. mProcessed = true;
  76. }
  77. virtual void setParcelID(const LLUUID& parcel_id) { }
  78. virtual void setErrorStatus(U32 status, const std::string& reason) { }
  79. bool mProcessed;
  80. };
  81. struct RemoteParcelRequestData
  82. {
  83. RemoteParcelRequestData()
  84. {
  85. }
  86. };
  87. typedef test_group<RemoteParcelRequestData> remoteparcelrequest_t;
  88. typedef remoteparcelrequest_t::object remoteparcelrequest_object_t;
  89. tut::remoteparcelrequest_t tut_remoteparcelrequest("LLRemoteParcelRequest");
  90. template<> template<>
  91. void remoteparcelrequest_object_t::test<1>()
  92. {
  93. set_test_name("observer pointer");
  94. boost::scoped_ptr<TestObserver> observer(new TestObserver());
  95. LLRemoteParcelInfoProcessor & processor = LLRemoteParcelInfoProcessor::instance();
  96. processor.addObserver(LLUUID(TEST_PARCEL_ID), observer.get());
  97. processor.processParcelInfoReply(gMessageSystem, NULL);
  98. ensure(observer->mProcessed);
  99. }
  100. template<> template<>
  101. void remoteparcelrequest_object_t::test<2>()
  102. {
  103. set_test_name("CHOP-220: dangling observer pointer");
  104. LLRemoteParcelInfoObserver * observer = new TestObserver();
  105. LLRemoteParcelInfoProcessor & processor = LLRemoteParcelInfoProcessor::instance();
  106. processor.addObserver(LLUUID(TEST_PARCEL_ID), observer);
  107. delete observer;
  108. observer = NULL;
  109. processor.processParcelInfoReply(gMessageSystem, NULL);
  110. }
  111. }