Change MoapModule.ClearMediaEntry to set TextureEntryFace.MediaFlags back to false

Implement test for ClearMediaEntry()
0.7.1-dev
Justin Clark-Casey (justincc) 2011-03-05 02:18:03 +00:00
parent 12d5a20094
commit 9f85ee29ac
3 changed files with 68 additions and 9 deletions

View File

@ -250,7 +250,7 @@ namespace OpenSim.Framework
{ {
get get
{ {
//m_log.DebugFormat("[SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length); // m_log.DebugFormat("[SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length);
try { return new Primitive.TextureEntry(m_textureEntry, 0, m_textureEntry.Length); } try { return new Primitive.TextureEntry(m_textureEntry, 0, m_textureEntry.Length); }
catch { } catch { }

View File

@ -225,6 +225,12 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap
return me; return me;
} }
/// <summary>
/// Set the media entry on the face of the given part.
/// </summary>
/// <param name="part">/param>
/// <param name="face"></param>
/// <param name="me"></param>
public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me) public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me)
{ {
// m_log.DebugFormat("[MOAP]: SetMediaEntry for {0}, face {1}", part.Name, face); // 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); part.TriggerScriptChangedEvent(Changed.MEDIA);
} }
/// <summary>
/// Clear the media entry from the face of the given part.
/// </summary>
/// <param name="part"></param>
/// <param name="face"></param>
public void ClearMediaEntry(SceneObjectPart part, int face) 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);
} }
/// <summary> /// <summary>

View File

@ -48,6 +48,41 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests
[TestFixture] [TestFixture]
public class MoapTests 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] [Test]
public void TestSetMediaUrl() public void TestSetMediaUrl()
{ {
@ -55,14 +90,10 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests
string homeUrl = "opensimulator.org"; string homeUrl = "opensimulator.org";
MoapModule module = new MoapModule(); SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene);
TestScene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, module);
SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene);
MediaEntry me = new MediaEntry() { HomeURL = homeUrl }; 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.Shape.Media[1].HomeURL, Is.EqualTo(homeUrl));
Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000000/" + UUID.Zero)); Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000000/" + UUID.Zero));