From 9f85ee29ac9f5e0aa8c1976944f9af12da3514db Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 5 Mar 2011 02:18:03 +0000
Subject: Change MoapModule.ClearMediaEntry to set TextureEntryFace.MediaFlags
back to false
Implement test for ClearMediaEntry()
---
.../CoreModules/World/Media/Moap/MoapModule.cs | 30 ++++++++++++++-
.../World/Media/Moap/Tests/MoapTests.cs | 45 ++++++++++++++++++----
2 files changed, 67 insertions(+), 8 deletions(-)
(limited to 'OpenSim/Region/CoreModules')
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
index b6ec6dc..ffb3221 100644
--- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
@@ -225,6 +225,12 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap
return me;
}
+ ///
+ /// Set the media entry on the face of the given part.
+ ///
+ /// /param>
+ ///
+ ///
public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me)
{
// m_log.DebugFormat("[MOAP]: SetMediaEntry for {0}, face {1}", part.Name, face);
@@ -249,9 +255,31 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap
part.TriggerScriptChangedEvent(Changed.MEDIA);
}
+ ///
+ /// Clear the media entry from the face of the given part.
+ ///
+ ///
+ ///
public void ClearMediaEntry(SceneObjectPart part, int face)
{
- SetMediaEntry(part, face, null);
+ CheckFaceParam(part, face);
+
+ // If no media has been set up yetthen we don't need to clear anything
+ if (null == part.Shape.Media)
+ return;
+
+ lock (part.Shape.Media)
+ part.Shape.Media[face] = null;
+
+ UpdateMediaUrl(part, UUID.Zero);
+
+ Primitive.TextureEntry te = part.Shape.Textures;
+ Primitive.TextureEntryFace teFace = te.CreateFace((uint)face);
+ teFace.MediaFlags = false;
+ part.Shape.Textures = te;
+
+ part.ScheduleFullUpdate();
+ part.TriggerScriptChangedEvent(Changed.MEDIA);
}
///
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs
index 9e5c7ae..7a68e55 100644
--- a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs
@@ -48,21 +48,52 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests
[TestFixture]
public class MoapTests
{
+ protected TestScene m_scene;
+ protected MoapModule m_module;
+
+ [SetUp]
+ public void SetUp()
+ {
+ m_module = new MoapModule();
+ m_scene = SceneSetupHelpers.SetupScene();
+ SceneSetupHelpers.SetupSceneModules(m_scene, m_module);
+ }
+
+ [Test]
+ public void TestClearMediaUrl()
+ {
+ TestHelper.InMethod();
+// log4net.Config.XmlConfigurator.Configure();
+
+ SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene);
+ MediaEntry me = new MediaEntry();
+
+ m_module.SetMediaEntry(part, 1, me);
+ m_module.ClearMediaEntry(part, 1);
+
+ Assert.That(part.Shape.Media[1], Is.EqualTo(null));
+
+ // Although we've cleared one face, other faces may still be present. So we need to check for an
+ // update media url version
+ Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000001/" + UUID.Zero));
+
+ // By changing media flag to false, the face texture once again becomes identical to the DefaultTexture.
+ // Therefore, when libOMV reserializes it, it disappears and we are left with no face texture in this slot.
+ // Not at all confusing, eh?
+ Assert.That(part.Shape.Textures.FaceTextures[1], Is.Null);
+ }
+
[Test]
public void TestSetMediaUrl()
{
TestHelper.InMethod();
- string homeUrl = "opensimulator.org";
-
- MoapModule module = new MoapModule();
- TestScene scene = SceneSetupHelpers.SetupScene();
- SceneSetupHelpers.SetupSceneModules(scene, module);
+ string homeUrl = "opensimulator.org";
- SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene);
+ SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene);
MediaEntry me = new MediaEntry() { HomeURL = homeUrl };
- module.SetMediaEntry(part, 1, me);
+ m_module.SetMediaEntry(part, 1, me);
Assert.That(part.Shape.Media[1].HomeURL, Is.EqualTo(homeUrl));
Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000000/" + UUID.Zero));
--
cgit v1.1