PageRenderTime 42ms CodeModel.GetById 1ms app.highlight 36ms RepoModel.GetById 2ms 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
  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
 27#include "linden_common.h"
 28
 29#include "../test/lltut.h"
 30
 31#include "../llremoteparcelrequest.h"
 32
 33#include "../llagent.h"
 34#include "message.h"
 35#include "llurlentry.h"
 36
 37namespace {
 38	const LLUUID TEST_PARCEL_ID("11111111-1111-1111-1111-111111111111");
 39}
 40
 41LLCurl::Responder::Responder() { }
 42LLCurl::Responder::~Responder() { }
 43void LLCurl::Responder::error(U32,std::string const &) { }
 44void LLCurl::Responder::result(LLSD const &) { }
 45void LLCurl::Responder::errorWithContent(U32 status,std::string const &,LLSD const &) { }
 46void LLCurl::Responder::completedRaw(U32 status, std::string const &, LLChannelDescriptors const &,boost::shared_ptr<LLBufferArray> const &) { }
 47void LLCurl::Responder::completed(U32 status, std::string const &, LLSD const &) { }
 48void LLCurl::Responder::completedHeader(U32 status, std::string const &, LLSD const &) { }
 49void LLMessageSystem::getF32(char const *,char const *,F32 &,S32) { }
 50void LLMessageSystem::getU8(char const *,char const *,U8 &,S32) { }
 51void LLMessageSystem::getS32(char const *,char const *,S32 &,S32) { }
 52void LLMessageSystem::getString(char const *,char const *, std::string &,S32) { }
 53void LLMessageSystem::getUUID(char const *,char const *, LLUUID & out_id,S32)
 54{
 55	out_id = TEST_PARCEL_ID;
 56}
 57void LLMessageSystem::nextBlock(char const *) { }
 58void LLMessageSystem::addUUID(char const *,LLUUID const &) { }
 59void LLMessageSystem::addUUIDFast(char const *,LLUUID const &) { }
 60void LLMessageSystem::nextBlockFast(char const *) { }
 61void LLMessageSystem::newMessage(char const *) { }
 62LLMessageSystem * gMessageSystem;
 63char const* const _PREHASH_AgentID = 0;   // never dereferenced during this test
 64char const* const _PREHASH_AgentData = 0; // never dereferenced during this test
 65LLAgent gAgent;
 66LLAgent::LLAgent() : mAgentAccess(NULL) { }
 67LLAgent::~LLAgent() { }
 68void LLAgent::sendReliableMessage(void) { }
 69LLUUID gAgentSessionID;
 70LLUUID gAgentID;
 71LLUIColor::LLUIColor(void) { }
 72LLControlGroup::LLControlGroup(std::string const & name) : LLInstanceTracker<LLControlGroup, std::string>(name) { }
 73LLControlGroup::~LLControlGroup(void) { }
 74void LLUrlEntryParcel::processParcelInfo(const LLUrlEntryParcel::LLParcelData& parcel_data) { }
 75
 76namespace tut
 77{
 78	struct TestObserver : public LLRemoteParcelInfoObserver {
 79		TestObserver() : mProcessed(false) { }
 80
 81		virtual void processParcelInfo(const LLParcelData& parcel_data)
 82		{
 83			mProcessed = true;
 84		}
 85
 86		virtual void setParcelID(const LLUUID& parcel_id) { }
 87
 88		virtual void setErrorStatus(U32 status, const std::string& reason) { }
 89
 90		bool mProcessed;
 91	};
 92
 93    struct RemoteParcelRequestData
 94    {
 95		RemoteParcelRequestData()
 96		{
 97		}
 98    };
 99    
100	typedef test_group<RemoteParcelRequestData> remoteparcelrequest_t;
101	typedef remoteparcelrequest_t::object remoteparcelrequest_object_t;
102	tut::remoteparcelrequest_t tut_remoteparcelrequest("LLRemoteParcelRequest");
103
104	template<> template<>
105	void remoteparcelrequest_object_t::test<1>()
106	{
107		set_test_name("observer pointer");
108
109		boost::scoped_ptr<TestObserver> observer(new TestObserver());
110
111		LLRemoteParcelInfoProcessor & processor = LLRemoteParcelInfoProcessor::instance();
112		processor.addObserver(LLUUID(TEST_PARCEL_ID), observer.get());
113
114		processor.processParcelInfoReply(gMessageSystem, NULL);
115
116		ensure(observer->mProcessed);
117	}
118
119	template<> template<>
120	void remoteparcelrequest_object_t::test<2>()
121	{
122		set_test_name("CHOP-220: dangling observer pointer");
123
124		LLRemoteParcelInfoObserver * observer = new TestObserver();
125
126		LLRemoteParcelInfoProcessor & processor = LLRemoteParcelInfoProcessor::instance();
127		processor.addObserver(LLUUID(TEST_PARCEL_ID), observer);
128
129		delete observer;
130		observer = NULL;
131
132		processor.processParcelInfoReply(gMessageSystem, NULL);
133	}
134}