From 9ec432034dc3c45d7ce763eb02dae4cc7f6b8da8 Mon Sep 17 00:00:00 2001
From: Steven Bennetts <steve@lindenlab.com>
Date: Sun, 21 Jun 2009 08:04:56 +0000
Subject: merge -r 122421-124917 viewer-2.0.0-2 -> viewer-2.0.0-3
 ignore-dead-branch

---
 indra/llprimitive/llmaterialtable.cpp            |  11 ++
 indra/llprimitive/llmaterialtable.h              |   2 +
 indra/llprimitive/llprimitive.cpp                |   2 +-
 indra/llprimitive/llprimitive.h                  |   2 +-
 indra/llprimitive/llprimtexturelist.cpp          |   7 +-
 indra/llprimitive/llprimtexturelist.h            |   7 +-
 indra/llprimitive/tests/llmessagesystem_stub.cpp |  42 +++++
 indra/llprimitive/tests/llprimitive_test.cpp     | 214 +++++++++++++++++++++++
 8 files changed, 279 insertions(+), 8 deletions(-)
 create mode 100644 indra/llprimitive/tests/llmessagesystem_stub.cpp
 create mode 100644 indra/llprimitive/tests/llprimitive_test.cpp

(limited to 'indra/llprimitive')

diff --git a/indra/llprimitive/llmaterialtable.cpp b/indra/llprimitive/llmaterialtable.cpp
index 4c22203eb9..18787c47c5 100644
--- a/indra/llprimitive/llmaterialtable.cpp
+++ b/indra/llprimitive/llmaterialtable.cpp
@@ -124,6 +124,17 @@ LLMaterialTable::~LLMaterialTable()
 	mMaterialInfoList.clear();
 }
 
+void LLMaterialTable::initTableTransNames(std::map<std::string, std::string> namemap)
+{
+	for (info_list_t::iterator iter = mMaterialInfoList.begin();
+		 iter != mMaterialInfoList.end(); ++iter)
+	{
+		LLMaterialInfo *infop = *iter;
+		std::string name = infop->mName;
+		infop->mName = namemap[name];
+	}
+}
+
 void LLMaterialTable::initBasicTable()
 {
 	// *TODO: Translate
diff --git a/indra/llprimitive/llmaterialtable.h b/indra/llprimitive/llmaterialtable.h
index ca9017abd0..2c0b046fa7 100644
--- a/indra/llprimitive/llmaterialtable.h
+++ b/indra/llprimitive/llmaterialtable.h
@@ -147,6 +147,8 @@ public:
 
 	void initBasicTable();
 
+	void initTableTransNames(std::map<std::string, std::string> namemap);
+	
 	BOOL add(U8 mcode, const std::string& name, const LLUUID &uuid);	                 
 	BOOL addCollisionSound(U8 mcode, U8 mcode2, const LLUUID &uuid);
 	BOOL addSlidingSound(U8 mcode, U8 mcode2, const LLUUID &uuid);
diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp
index 13facc0d58..33807e7545 100644
--- a/indra/llprimitive/llprimitive.cpp
+++ b/indra/llprimitive/llprimitive.cpp
@@ -132,7 +132,7 @@ void LLPrimitive::setVolumeManager( LLVolumeMgr* volume_manager )
 {
 	if ( !volume_manager || sVolumeManager )
 	{
-		llerrs << "Unable to set LLPrimitive::sVolumeManager to NULL" << llendl;
+		llerrs << "LLPrimitive::sVolumeManager attempting to be set to NULL or it already has been set." << llendl;
 	}
 	sVolumeManager = volume_manager;
 }
diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h
index c25df0a40f..b3a337ce5d 100644
--- a/indra/llprimitive/llprimitive.h
+++ b/indra/llprimitive/llprimitive.h
@@ -37,7 +37,7 @@
 #include "v3math.h"
 #include "xform.h"
 #include "message.h"
-#include "llmemory.h"
+#include "llpointer.h"
 #include "llvolume.h"
 #include "lltextureentry.h"
 #include "llprimtexturelist.h"
diff --git a/indra/llprimitive/llprimtexturelist.cpp b/indra/llprimitive/llprimtexturelist.cpp
index c9632ebdad..d03150fc78 100644
--- a/indra/llprimitive/llprimtexturelist.cpp
+++ b/indra/llprimitive/llprimtexturelist.cpp
@@ -4,7 +4,7 @@
  *
  * $LicenseInfo:firstyear=2008&license=viewergpl$
  * 
- * Copyright (c) 2008-2007, Linden Research, Inc.
+ * Copyright (c) 2008-2009, Linden Research, Inc.
  * 
  * Second Life Viewer Source Code
  * The source code in this file ("Source Code") is provided by Linden Lab
@@ -12,12 +12,13 @@
  * ("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
+ * online at http://secondlifegrid.net/programs/open_source/licensing/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
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
  * By copying, modifying or distributing this software, you acknowledge
  * that you have read and understood your obligations described above,
diff --git a/indra/llprimitive/llprimtexturelist.h b/indra/llprimitive/llprimtexturelist.h
index 61285bd1bf..6254878b99 100644
--- a/indra/llprimitive/llprimtexturelist.h
+++ b/indra/llprimitive/llprimtexturelist.h
@@ -4,7 +4,7 @@
  *
  * $LicenseInfo:firstyear=2008&license=viewergpl$
  * 
- * Copyright (c) 2008-2007, Linden Research, Inc.
+ * Copyright (c) 2008-2009, Linden Research, Inc.
  * 
  * Second Life Viewer Source Code
  * The source code in this file ("Source Code") is provided by Linden Lab
@@ -12,12 +12,13 @@
  * ("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
+ * online at http://secondlifegrid.net/programs/open_source/licensing/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
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
  * By copying, modifying or distributing this software, you acknowledge
  * that you have read and understood your obligations described above,
diff --git a/indra/llprimitive/tests/llmessagesystem_stub.cpp b/indra/llprimitive/tests/llmessagesystem_stub.cpp
new file mode 100644
index 0000000000..62504be3b0
--- /dev/null
+++ b/indra/llprimitive/tests/llmessagesystem_stub.cpp
@@ -0,0 +1,42 @@
+/**
+ * @file llmessagesystem_stub.cpp
+ * @brief stub class to allow unit testing
+ *
+ * $LicenseInfo:firstyear=2008&license=internal$
+ *
+ * Copyright (c) 2008, Linden Research, Inc.
+ *
+ * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of
+ * this source code is governed by the Linden Lab Source Code Disclosure
+ * Agreement ("Agreement") { }
+ * Lab. By accessing, using, copying, modifying or distributing this
+ * software, you acknowledge that you have been informed of your
+ * obligations under the Agreement 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 "linden_common.h"
+
+char * _PREHASH_TextureEntry;
+
+S32 LLMessageSystem::getSizeFast(char const*, char const*) const
+{
+	return 0;
+}
+
+S32 LLMessageSystem::getSizeFast(char const*, int, char const*) const
+{
+	return 0;
+}
+
+void LLMessageSystem::getBinaryDataFast(char const*, char const*, void*, int, int, int)
+{
+}
+
+void LLMessageSystem::addBinaryDataFast(char const*, void const*, int)
+{
+}
+
diff --git a/indra/llprimitive/tests/llprimitive_test.cpp b/indra/llprimitive/tests/llprimitive_test.cpp
new file mode 100644
index 0000000000..1805a9e968
--- /dev/null
+++ b/indra/llprimitive/tests/llprimitive_test.cpp
@@ -0,0 +1,214 @@
+/** 
+ * @file llprimitive_test.cpp
+ * @brief llprimitive tests
+ *
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * Copyright (c) 2001-2009, Linden Research, Inc.
+ * $/LicenseInfo$
+ */
+
+#include "linden_common.h"
+
+#include "../test/lltut.h"
+
+#include "../llprimitive.h"
+
+#include "../../llmath/llvolumemgr.h"
+
+class DummyVolumeMgr : public LLVolumeMgr
+{
+public:
+	DummyVolumeMgr() : LLVolumeMgr(), mVolumeTest(NULL), mCurrDetailTest(0) {}
+	~DummyVolumeMgr() 
+	{
+	}
+	
+	
+	virtual LLVolume *refVolume(const LLVolumeParams &volume_params, const S32 detail) 
+	{
+		if (mVolumeTest.isNull() || volume_params != mCurrParamsTest || detail != mCurrDetailTest)
+		{
+			F32 volume_detail = LLVolumeLODGroup::getVolumeScaleFromDetail(detail);
+			mVolumeTest = new LLVolume(volume_params, volume_detail, FALSE, FALSE);
+			mCurrParamsTest = volume_params;
+			mCurrDetailTest = detail;
+			return mVolumeTest;
+		} 
+		else 
+		{
+			return mVolumeTest;
+		}
+	}
+	
+	virtual void unrefVolume(LLVolume *volumep) 
+	{
+		if (mVolumeTest == volumep)
+		{
+			mVolumeTest = NULL;
+		}
+	}
+	
+private:
+	LLPointer<LLVolume> mVolumeTest;
+	LLVolumeParams mCurrParamsTest;
+	S32 mCurrDetailTest;
+};
+
+class PRIMITIVE_TEST_SETUP
+{
+public:
+	PRIMITIVE_TEST_SETUP()
+	{
+		volume_manager_test = new DummyVolumeMgr();
+		LLPrimitive::setVolumeManager(volume_manager_test);
+	}
+	
+	~PRIMITIVE_TEST_SETUP()
+	{
+		LLPrimitive::cleanupVolumeManager();
+	}
+	DummyVolumeMgr * volume_manager_test;
+}; 
+
+namespace tut
+{
+	struct llprimitive
+	{
+		PRIMITIVE_TEST_SETUP setup_class;
+	};
+    
+	typedef test_group<llprimitive> llprimitive_t;
+	typedef llprimitive_t::object llprimitive_object_t;
+	tut::llprimitive_t tut_llprimitive("llprimitive");
+
+	template<> template<>
+	void llprimitive_object_t::test<1>()
+	{
+		set_test_name("Test LLPrimitive Instantiation");
+		LLPrimitive test;
+	}
+	
+	template<> template<>
+	void llprimitive_object_t::test<2>()
+	{
+		set_test_name("Test LLPrimitive PCode setter and getter.");
+		LLPrimitive test;
+		ensure_equals(test.getPCode(), 0);
+		LLPCode code = 1;
+		test.setPCode(code);
+		ensure_equals(test.getPCode(), code);
+	}
+	
+	template<> template<>
+	void llprimitive_object_t::test<3>()
+	{
+		set_test_name("Test llprimitive constructor and initer.");
+		LLPCode code = 1;
+		LLPrimitive primitive;
+		primitive.init_primitive(code);
+		ensure_equals(primitive.getPCode(), code);
+	}
+	
+	template<> template<>
+	void llprimitive_object_t::test<4>()
+	{
+		set_test_name("Test Static llprimitive constructor and initer.");
+		LLPCode code = 1;
+		LLPrimitive * primitive = LLPrimitive::createPrimitive(code);
+		ensure(primitive != NULL);
+		ensure_equals(primitive->getPCode(), code);
+	}
+
+	template<> template<>
+	void llprimitive_object_t::test<5>()
+	{
+		set_test_name("Test setVolume creation of new unique volume.");
+		LLPrimitive primitive;
+		LLVolumeParams params;
+		
+		// Make sure volume starts off null
+		ensure(primitive.getVolume() == NULL);
+		
+		// Make sure we have no texture entries before setting the volume
+		ensure_equals(primitive.getNumTEs(), 0);
+		
+		// Test that GEOMETRY has not been flagged as changed.
+		ensure(!primitive.isChanged(LLXform::GEOMETRY));
+		
+		// Make sure setVolume returns true
+		ensure(primitive.setVolume(params, 0, true) == TRUE);
+		LLVolume* new_volume = primitive.getVolume();
+		
+		// make sure new volume was actually created
+		ensure(new_volume != NULL);
+		
+		// Make sure that now that we've set the volume we have texture entries
+		ensure_not_equals(primitive.getNumTEs(), 0);
+		
+		// Make sure that the number of texture entries equals the number of faces in the volume (should be 6)
+		ensure_equals(new_volume->getNumFaces(), 6);
+		ensure_equals(primitive.getNumTEs(), new_volume->getNumFaces());
+		
+		// Test that GEOMETRY has been flagged as changed.
+		ensure(primitive.isChanged(LLXform::GEOMETRY));
+		
+		// Run it twice to make sure it doesn't create a different one if params are the same
+		ensure(primitive.setVolume(params, 0, true) == FALSE);
+		ensure(new_volume == primitive.getVolume());
+		
+		// Change the param definition and try setting it again.
+		params.setRevolutions(4);
+		ensure(primitive.setVolume(params, 0, true) == TRUE);
+		
+		// Ensure that we now have a different volume
+		ensure(new_volume != primitive.getVolume());
+	}
+	
+	template<> template<>
+	void llprimitive_object_t::test<6>()
+	{
+		set_test_name("Test setVolume creation of new NOT-unique volume.");
+		LLPrimitive primitive;
+		LLVolumeParams params;
+		
+		// Make sure volume starts off null
+		ensure(primitive.getVolume() == NULL);
+		
+		// Make sure we have no texture entries before setting the volume
+		ensure_equals(primitive.getNumTEs(), 0);
+		
+		// Test that GEOMETRY has not been flagged as changed.
+		ensure(!primitive.isChanged(LLXform::GEOMETRY));
+		
+		// Make sure setVolume returns true
+		ensure(primitive.setVolume(params, 0, false) == TRUE);
+		
+		LLVolume* new_volume = primitive.getVolume();
+		
+		// make sure new volume was actually created
+		ensure(new_volume != NULL);
+		
+		// Make sure that now that we've set the volume we have texture entries
+		ensure_not_equals(primitive.getNumTEs(), 0);
+		
+		// Make sure that the number of texture entries equals the number of faces in the volume (should be 6)
+		ensure_equals(new_volume->getNumFaces(), 6);
+		ensure_equals(primitive.getNumTEs(), new_volume->getNumFaces());
+		
+		// Test that GEOMETRY has been flagged as changed.
+		ensure(primitive.isChanged(LLXform::GEOMETRY));
+		
+		// Run it twice to make sure it doesn't create a different one if params are the same
+		ensure(primitive.setVolume(params, 0, false) == FALSE);
+		ensure(new_volume == primitive.getVolume());
+		
+		// Change the param definition and try setting it again.
+		params.setRevolutions(4);
+		ensure(primitive.setVolume(params, 0, false) == TRUE); 
+		
+		// Ensure that we now have a different volume
+		ensure(new_volume != primitive.getVolume());
+	}
+}
+
+#include "llmessagesystem_stub.cpp"
-- 
cgit v1.2.3