From 3c89527b222c2ddc50553ce1c49f22e9f05db11b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 5 Mar 2011 00:06:51 +0000 Subject: Fix bug where llSetPrimMediaParams() reported success but never set the media texture. We weren't setting the TextureEntryFace.MediaFlags = true when a media texture was set directly via a script. This was being done when the viewer was setting them directly. --- .../Region/CoreModules/World/Media/Moap/MoapModule.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/CoreModules/World') diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs index 7c5d044..9132753 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs @@ -227,15 +227,24 @@ namespace OpenSim.Region.CoreModules.Media.Moap public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me) { +// m_log.DebugFormat("[MOAP]: SetMediaEntry for {0}, face {1}", part.Name, face); + CheckFaceParam(part, face); if (null == part.Shape.Media) part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]); - + lock (part.Shape.Media) - part.Shape.Media[face] = me; + part.Shape.Media[face] = me; UpdateMediaUrl(part, UUID.Zero); + + // Temporary code to fix llSetPrimMediaParams() bug, pending refactoring + Primitive.TextureEntry te = part.Shape.Textures; + Primitive.TextureEntryFace teFace = te.CreateFace((uint)face); + teFace.MediaFlags = true; + part.Shape.Textures = te; + part.ScheduleFullUpdate(); part.TriggerScriptChangedEvent(Changed.MEDIA); } @@ -333,7 +342,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap } // m_log.DebugFormat("[MOAP]: Received {0} media entries for prim {1}", omu.FaceMedia.Length, primId); - +// // for (int i = 0; i < omu.FaceMedia.Length; i++) // { // MediaEntry me = omu.FaceMedia[i]; @@ -380,6 +389,8 @@ namespace OpenSim.Region.CoreModules.Media.Moap } else { +// m_log.DebugFormat("[MOAP]: Setting existing media list for {0}", part.Name); + // We need to go through the media textures one at a time to make sure that we have permission // to change them -- cgit v1.1 From 481ca910da47e68546623573ac9bba669d7b44c1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 5 Mar 2011 01:07:05 +0000 Subject: add test for MoapModule.SetMediaUrl() --- .../World/Media/Moap/Tests/MoapTests.cs | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs (limited to 'OpenSim/Region/CoreModules/World') diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs new file mode 100644 index 0000000..d4c9245 --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs @@ -0,0 +1,72 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Threading; +using log4net.Config; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +using OpenMetaverse; +using OpenMetaverse.Assets; +using OpenSim.Framework; +using OpenSim.Region.CoreModules.Media.Moap; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Serialization; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; +using OpenSim.Tests.Common.Setup; + +namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests +{ + [TestFixture] + public class MoapTests + { + [Test] + public void TestSetMediaUrl() + { + TestHelper.InMethod(); + + string homeUrl = "opensimulator.org"; + + MoapModule module = new MoapModule(); + TestScene scene = SceneSetupHelpers.SetupScene(); + SceneSetupHelpers.SetupSceneModules(scene, module); + + SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); + MediaEntry me = new MediaEntry() { HomeURL = homeUrl }; + + 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)); + Assert.That(part.Shape.Textures.FaceTextures[1].MediaFlags, Is.True); + } + } +} \ No newline at end of file -- cgit v1.1 From 72cb498fd0c167867d71c26e55afedc2e23ab9b4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 5 Mar 2011 01:13:59 +0000 Subject: minor: Make MoapModule namespace consistent with other modules --- OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs | 2 +- OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules/World') diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs index 9132753..b6ec6dc 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs @@ -50,7 +50,7 @@ using Caps = OpenSim.Framework.Capabilities.Caps; using OSDArray = OpenMetaverse.StructuredData.OSDArray; using OSDMap = OpenMetaverse.StructuredData.OSDMap; -namespace OpenSim.Region.CoreModules.Media.Moap +namespace OpenSim.Region.CoreModules.World.Media.Moap { [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MoapModule")] public class MoapModule : INonSharedRegionModule, IMoapModule diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs index d4c9245..9e5c7ae 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs @@ -36,7 +36,7 @@ using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenMetaverse.Assets; using OpenSim.Framework; -using OpenSim.Region.CoreModules.Media.Moap; +using OpenSim.Region.CoreModules.World.Media.Moap; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Tests.Common; -- cgit v1.1 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/World') 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 From 9e579a7891d6eb4c3e5a0593d67837ed423135ee Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 5 Mar 2011 02:21:53 +0000 Subject: Fold ClearMediaEntry() back into SetMediaEntry() --- .../CoreModules/World/Media/Moap/MoapModule.cs | 30 +++++++--------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/CoreModules/World') diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs index ffb3221..b8943ad 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs @@ -230,7 +230,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap /// /// /param> /// - /// + /// If null, then the media entry is cleared. public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me) { // m_log.DebugFormat("[MOAP]: SetMediaEntry for {0}, face {1}", part.Name, face); @@ -238,7 +238,12 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap CheckFaceParam(part, face); if (null == part.Shape.Media) - part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]); + { + if (me == null) + return; + else + part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]); + } lock (part.Shape.Media) part.Shape.Media[face] = me; @@ -248,7 +253,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap // Temporary code to fix llSetPrimMediaParams() bug, pending refactoring Primitive.TextureEntry te = part.Shape.Textures; Primitive.TextureEntryFace teFace = te.CreateFace((uint)face); - teFace.MediaFlags = true; + teFace.MediaFlags = me != null; part.Shape.Textures = te; part.ScheduleFullUpdate(); @@ -262,24 +267,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap /// public void ClearMediaEntry(SceneObjectPart part, int face) { - 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); + SetMediaEntry(part, face, null); } /// -- cgit v1.1 From 9b345ebf73663a04d8baa69f0fb48ab80b8b1a58 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 5 Mar 2011 02:42:47 +0000 Subject: factor out SetPartMediaFlags() function in MoapModule. --- .../CoreModules/World/Media/Moap/MoapModule.cs | 31 ++++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/CoreModules/World') diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs index b8943ad..898ca4a 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs @@ -250,11 +250,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap UpdateMediaUrl(part, UUID.Zero); - // Temporary code to fix llSetPrimMediaParams() bug, pending refactoring - Primitive.TextureEntry te = part.Shape.Textures; - Primitive.TextureEntryFace teFace = te.CreateFace((uint)face); - teFace.MediaFlags = me != null; - part.Shape.Textures = te; + SetPartMediaFlags(part, face, me != null); part.ScheduleFullUpdate(); part.TriggerScriptChangedEvent(Changed.MEDIA); @@ -271,6 +267,23 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap } /// + /// Set the media flags on the texture face of the given part. + /// + /// + /// The fact that we need a separate function to do what should be a simple one line operation is BUTT UGLY. + /// + /// + /// + /// + protected void SetPartMediaFlags(SceneObjectPart part, int face, bool flag) + { + Primitive.TextureEntry te = part.Shape.Textures; + Primitive.TextureEntryFace teFace = te.CreateFace((uint)face); + teFace.MediaFlags = flag; + part.Shape.Textures = te; + } + + /// /// Sets or gets per face media textures. /// /// @@ -393,10 +406,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap // FIXME: Race condition here since some other texture entry manipulator may overwrite/get // overwritten. Unfortunately, PrimitiveBaseShape does not allow us to change texture entry // directly. - Primitive.TextureEntry te = part.Shape.Textures; - Primitive.TextureEntryFace face = te.CreateFace((uint)i); - face.MediaFlags = true; - part.Shape.Textures = te; + SetPartMediaFlags(part, i, true); // m_log.DebugFormat( // "[MOAP]: Media flags for face {0} is {1}", // i, part.Shape.Textures.FaceTextures[i].MediaFlags); @@ -428,8 +438,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap if (null == media[i]) continue; - Primitive.TextureEntryFace face = te.CreateFace((uint)i); - face.MediaFlags = true; + SetPartMediaFlags(part, i, true); // m_log.DebugFormat( // "[MOAP]: Media flags for face {0} is {1}", -- cgit v1.1 From 9456bb77fbf794bb6fc2808e6cfd69c9bb1d1326 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 9 Mar 2011 23:25:24 +0000 Subject: Upgrade nunit.framework.dll to version 2.5.9. Fix up tests appropriately. This version removes the NUnit.Framework.SyntaxHelpers namespace, so any modules with their own tests will need to delete this using statement. --- OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | 1 - OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs | 1 - OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs | 1 - 3 files changed, 3 deletions(-) (limited to 'OpenSim/Region/CoreModules/World') diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 04b6e3d..e2760a2 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -32,7 +32,6 @@ using System.Reflection; using System.Threading; using log4net.Config; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenMetaverse.Assets; using OpenSim.Framework; diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs index 7a68e55..5b85830 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs @@ -32,7 +32,6 @@ using System.Reflection; using System.Threading; using log4net.Config; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenMetaverse.Assets; using OpenSim.Framework; diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index f10e848..dafaa0c 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs @@ -30,7 +30,6 @@ using System.IO; using System.Xml; using log4net.Config; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; -- cgit v1.1