diff options
| author | Kelly Washington <kelly@lindenlab.com> | 2009-02-24 19:29:36 +0000 | 
|---|---|---|
| committer | Kelly Washington <kelly@lindenlab.com> | 2009-02-24 19:29:36 +0000 | 
| commit | aa2b978bf59dd74083bec86c61a29fefb4ebb14c (patch) | |
| tree | 63d0e55a524208eb2bdad1a1a6f0d03af1b39de2 /indra/test | |
| parent | f5242719b628efb148f05ba44ce78f9818ec617a (diff) | |
merge -r 112783:112799 linden/branches/kelly/lsl-http-in-merge to linden/trunk
Diffstat (limited to 'indra/test')
| -rw-r--r-- | indra/test/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | indra/test/llhttpnode_tut.cpp | 3 | ||||
| -rw-r--r-- | indra/test/llscriptresource_tut.cpp | 203 | ||||
| -rw-r--r-- | indra/test/lltranscode_tut.cpp | 94 | ||||
| -rw-r--r-- | indra/test/message_tut.cpp | 1 | 
5 files changed, 306 insertions, 1 deletions
| diff --git a/indra/test/CMakeLists.txt b/indra/test/CMakeLists.txt index 01c291be7b..0000cc237b 100644 --- a/indra/test/CMakeLists.txt +++ b/indra/test/CMakeLists.txt @@ -10,6 +10,7 @@ include(LLMath)  include(LLMessage)  include(LLVFS)  include(LLXML) +include(LScript)  include(Linking)  include_directories( @@ -20,6 +21,7 @@ include_directories(      ${LLINVENTORY_INCLUDE_DIRS}      ${LLVFS_INCLUDE_DIRS}      ${LLXML_INCLUDE_DIRS} +    ${LSCRIPT_INCLUDE_DIRS}      )  set(test_SOURCE_FILES @@ -48,6 +50,7 @@ set(test_SOURCE_FILES      llquaternion_tut.cpp      llrandom_tut.cpp      llsaleinfo_tut.cpp +    llscriptresource_tut.cpp      llsdmessagebuilder_tut.cpp      llsdmessagereader_tut.cpp      llsd_new_tut.cpp @@ -58,6 +61,7 @@ set(test_SOURCE_FILES      llstring_tut.cpp      lltemplatemessagebuilder_tut.cpp      lltiming_tut.cpp +    lltranscode_tut.cpp      lltut.cpp      lluri_tut.cpp      lluuidhashmap_tut.cpp @@ -109,7 +113,9 @@ target_link_libraries(test      ${LLMATH_LIBRARIES}      ${LLVFS_LIBRARIES}      ${LLXML_LIBRARIES} +    ${LSCRIPT_LIBRARIES}      ${LLCOMMON_LIBRARIES} +    ${APRICONV_LIBRARIES}      ${PTHREAD_LIBRARY}      ${WINDOWS_LIBRARIES}      ${DL_LIBRARY} diff --git a/indra/test/llhttpnode_tut.cpp b/indra/test/llhttpnode_tut.cpp index 8654971f9b..e17d1e0f24 100644 --- a/indra/test/llhttpnode_tut.cpp +++ b/indra/test/llhttpnode_tut.cpp @@ -86,7 +86,8 @@ namespace tut  			void result(const LLSD& result) { mResult = result; }  			void status(S32 code, const std::string& message) { } - +			void extendedResult(S32 code, const std::string& message, const LLSD& headers) { } +			  		private:  			Response() {;} // Must be accessed through LLPointer.  		}; diff --git a/indra/test/llscriptresource_tut.cpp b/indra/test/llscriptresource_tut.cpp new file mode 100644 index 0000000000..e384c275a3 --- /dev/null +++ b/indra/test/llscriptresource_tut.cpp @@ -0,0 +1,203 @@ +/**  + * @file llscriptresource_tut.cpp + * @brief Test LLScriptResource + * + * $LicenseInfo:firstyear=2008&license=viewergpl$ + *  + * Copyright (c) 2006-2007, Linden Research, Inc. + *  + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab.  Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlife.com/developers/opensource/gplv2 + *  + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlife.com/developers/opensource/flossexception + *  + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + *  + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +//#include <tut/tut.h> +#include "linden_common.h" + +#include "lltut.h" + +#include "llscriptresource.h" +#include "llscriptresourceconsumer.h" +#include "llscriptresourcepool.h" + +class TestConsumer : public LLScriptResourceConsumer +{ +public: +	TestConsumer() +		: mUsedURLs(0) +	{ } + +	// LLScriptResourceConsumer interface: +	S32 getUsedPublicURLs() const +	{ +		return mUsedURLs; +	} + +	// Test details: +	S32 mUsedURLs; +}; + + +namespace tut +{ +	class LLScriptResourceTestData +	{ +	}; +	 +	typedef test_group<LLScriptResourceTestData> LLScriptResourceTestGroup; +	typedef LLScriptResourceTestGroup::object		LLScriptResourceTestObject; +	LLScriptResourceTestGroup scriptResourceTestGroup("scriptResource"); + +	template<> template<> +	void LLScriptResourceTestObject::test<1>() +	{ +		LLScriptResource resource; +		U32 total = 42; +		 +		resource.setTotal(total); +		ensure_equals("Verify set/get total", resource.getTotal(), total); +		ensure_equals("Verify all resources are initially available",resource.getAvailable(),total); + +		// Requesting too many, releasing non-allocated +		ensure("Request total + 1 resources should fail",!resource.request(total + 1)); +		ensure_equals("Verify all resources available after failed request",resource.getAvailable(),total); + +		ensure("Releasing resources when none allocated should fail",!resource.release()); +		ensure_equals("All resources should be available after failed release",resource.getAvailable(),total); + +		ensure("Request one resource", resource.request()); +		ensure_equals("Verify available resources after successful request",resource.getAvailable(),total - 1); + +		// Is this right?  Or should we release all used resources if we try to release more than are currently used? +		ensure("Release more resources than allocated",!resource.release(2)); +		ensure_equals("Verify resource availability after failed release",resource.getAvailable(),total - 1); + +		ensure("Release a resource",resource.release()); +		ensure_equals("Verify all resources available after successful release",resource.getAvailable(),total); +	} + + +	template<> template<> +	void LLScriptResourceTestObject::test<2>() +	{ +		LLScriptResource resource; +		U32 total = 42; + +		resource.setTotal(total); + +		S32 resources_to_request = 30; +		ensure("Get multiple resources resources",resource.request(resources_to_request)); +		ensure_equals("Verify available resources is correct after request of multiple resources",resource.getAvailable(), total - resources_to_request); + +		S32 resources_to_release = (resources_to_request / 2); +		ensure("Release some resources",resource.release(resources_to_release)); + +		S32 expected_available = (total - resources_to_request + resources_to_release); +		ensure_equals("Verify available resources after release of some resources",resource.getAvailable(), expected_available); + +		resources_to_release = (resources_to_request - resources_to_release); +		ensure("Release remaining resources",resource.release(resources_to_release)); + +		ensure_equals("Verify available resources after release of remaining resources",resource.getAvailable(), total); +	} + +	template<> template<> +	void LLScriptResourceTestObject::test<3>() +	{ +		LLScriptResource resource; + +		U32 total = 42; +		resource.setTotal(total); + +		ensure("Request all resources",resource.request(total)); + +		U32 low_total = 10; +		ensure("Release all resources",resource.release(total)); +		ensure_equals("Verify all resources available after releasing",resource.getAvailable(),total); + +		resource.setTotal(low_total); +		ensure_equals("Verify low total resources are available after set",resource.getAvailable(),low_total); +	} +	 + +	template<> template<> +	void LLScriptResourceTestObject::test<4>() +	{ +		S32 big_resource_total = 100; +		S32 small_resource_total = 10; +		LLScriptResourcePool big_pool; +		big_pool.getPublicURLResource().setTotal(big_resource_total); +		LLScriptResourcePool small_pool; +		small_pool.getPublicURLResource().setTotal(small_resource_total); + +		TestConsumer consumer; +		LLScriptResourcePool& initial_pool = consumer.getScriptResourcePool(); +		ensure("Initial resource pool is 'null'.", (&initial_pool == &LLScriptResourcePool::null)); + +		consumer.switchScriptResourcePools(big_pool); +		LLScriptResourcePool& get_pool = consumer.getScriptResourcePool(); +		ensure("Get resource that was set.", (&big_pool == &get_pool)); + +		ensure_equals("No public urls in use yet.", consumer.getUsedPublicURLs(),0); + +		S32 request_urls = 5; +		consumer.mUsedURLs = request_urls; +		consumer.getScriptResourcePool().getPublicURLResource().request(request_urls); + +		ensure_equals("Available urls on big_pool is 5 less than total.", +			big_pool.getPublicURLResource().getAvailable(), big_resource_total - request_urls); + +		ensure("Switching from big pool to small pool", +			   consumer.switchScriptResourcePools(small_pool)); + +		ensure_equals("All resources available to big pool again", +			big_pool.getPublicURLResource().getAvailable(), big_resource_total); + +		ensure_equals("Available urls on small pool is 5 less than total.", +			small_pool.getPublicURLResource().getAvailable(), small_resource_total - request_urls); + +		ensure("Switching from small pool to big pool", +			   consumer.switchScriptResourcePools(big_pool)); + +		consumer.getScriptResourcePool().getPublicURLResource().release(request_urls); + +		request_urls = 50; // Too many for the small_pool + +		consumer.mUsedURLs = request_urls; +		consumer.getScriptResourcePool().getPublicURLResource().request(request_urls); + +		// Verify big pool has them +		ensure_equals("Available urls on big pool is 50 less than total.", +			big_pool.getPublicURLResource().getAvailable(), big_resource_total - request_urls); + +		// Verify can't switch to small_pool +		ensure("Switching to small pool with too many resources", +			   !consumer.switchScriptResourcePools(small_pool)); + +		// Verify big pool still accounting for used resources +		ensure_equals("Available urls on big_pool is still 50 less than total.", +			big_pool.getPublicURLResource().getAvailable(), big_resource_total - request_urls); +		 +		// Verify small pool still has all resources available. +		ensure_equals("All resources in small pool are still available.", +			small_pool.getPublicURLResource().getAvailable(), small_resource_total); +	} +} diff --git a/indra/test/lltranscode_tut.cpp b/indra/test/lltranscode_tut.cpp new file mode 100644 index 0000000000..8abf9dc224 --- /dev/null +++ b/indra/test/lltranscode_tut.cpp @@ -0,0 +1,94 @@ +/**  + * @file llscriptresource_tut.cpp + * @brief Test LLScriptResource + * + * $LicenseInfo:firstyear=2008&license=viewergpl$ + *  + * Copyright (c) 2006-2007, Linden Research, Inc. + *  + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab.  Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlife.com/developers/opensource/gplv2 + *  + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlife.com/developers/opensource/flossexception + *  + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + *  + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +//#include <tut/tut.h> +#include "linden_common.h" + +#include "lltut.h" + +#include "../newsim/lltranscode.cpp" // include TU to pull in newsim implementation. + +static const char test_utf8[] = "Edelwei\xc3\x9f"; +static const char test_utf7[] = "Edelwei+AN8-"; +static const char test_latin1[] = "Edelwei\xdf"; +static const char test_latin2[] = "Edelwei\xdf"; + +namespace tut +{ +	class LLTranscodeTestData +	{ +	}; +	 +	typedef test_group<LLTranscodeTestData> LLTranscodeTestGroup; +	typedef LLTranscodeTestGroup::object LLTranscodeTestObject; +	LLTranscodeTestGroup transcodeTestGroup("transcode"); + +	template<> template<> +	void LLTranscodeTestObject::test<1>() +	{ +#if LL_WINDOWS +		skip("Windows APR libs can't transcode."); +#endif +		// Test utf8 +		std::stringstream input; +		std::stringstream output; + +		input.str(test_utf7); +		output.clear(); +		LLTranscode::transcode("charset=UTF-7", input, output); +		ensure_equals("UTF-7 to UTF-8 transcoding", output.str(), +						  std::string(test_utf8)); + +		input.str(test_latin1); +		output.clear(); +		LLTranscode::transcode("", input, output); +		ensure_equals("Default (latin_1) to UTF8 transcoding", output.str(), +			std::string(test_utf8)); +		 +		input.str(test_latin1); +		output.clear(); +		LLTranscode::transcode("charset=iso-8859-1", input, output); +		ensure_equals("latin_1 (ISO-8859-1) to UTF8 transcoding", output.str(), +			std::string(test_utf8)); +	 +		input.str(test_latin2); +		output.clear(); +		LLTranscode::transcode("charset=iso-8859-2", input, output); +		ensure_equals("latin_2 (ISO-8859-2) to UTF8 transcoding", output.str(), +			std::string(test_utf8)); +		 +		input.str(test_utf8); +		output.clear(); +		LLTranscode::transcode("charset=utf-8", input, output); +		ensure_equals("UTF8 to UTF8 transcoding", output.str(), +			std::string(test_utf8)); +	} +} diff --git a/indra/test/message_tut.cpp b/indra/test/message_tut.cpp index e632234623..3fede2608c 100644 --- a/indra/test/message_tut.cpp +++ b/indra/test/message_tut.cpp @@ -51,6 +51,7 @@ namespace  		{  			mStatus = code;  		} +		virtual void extendedResult(S32 code, const std::string& message, const LLSD& headers) { }  		S32 mStatus;  	};  } | 
