SceneObjectStatusTests.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Reflection;
  30. using NUnit.Framework;
  31. using OpenMetaverse;
  32. using OpenSim.Framework;
  33. using OpenSim.Framework.Communications;
  34. using OpenSim.Region.Framework.Scenes;
  35. using OpenSim.Tests.Common;
  36. namespace OpenSim.Region.Framework.Scenes.Tests
  37. {
  38. /// <summary>
  39. /// Basic scene object status tests
  40. /// </summary>
  41. [TestFixture]
  42. public class SceneObjectStatusTests : OpenSimTestCase
  43. {
  44. private TestScene m_scene;
  45. private UUID m_ownerId = TestHelpers.ParseTail(0x1);
  46. private SceneObjectGroup m_so1;
  47. private SceneObjectGroup m_so2;
  48. [SetUp]
  49. public void Init()
  50. {
  51. m_scene = new SceneHelpers().SetupScene();
  52. m_so1 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so1", 0x10);
  53. m_so2 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so2", 0x20);
  54. }
  55. [Test]
  56. public void TestSetTemporary()
  57. {
  58. TestHelpers.InMethod();
  59. m_scene.AddSceneObject(m_so1);
  60. m_so1.ScriptSetTemporaryStatus(true);
  61. // Is this really the correct flag?
  62. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.TemporaryOnRez));
  63. Assert.That(m_so1.Backup, Is.False);
  64. // Test setting back to non-temporary
  65. m_so1.ScriptSetTemporaryStatus(false);
  66. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
  67. Assert.That(m_so1.Backup, Is.True);
  68. }
  69. [Test]
  70. public void TestSetPhantomSinglePrim()
  71. {
  72. TestHelpers.InMethod();
  73. m_scene.AddSceneObject(m_so1);
  74. SceneObjectPart rootPart = m_so1.RootPart;
  75. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  76. m_so1.ScriptSetPhantomStatus(true);
  77. // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
  78. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom));
  79. m_so1.ScriptSetPhantomStatus(false);
  80. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  81. }
  82. [Test]
  83. public void TestSetNonPhysicsVolumeDetectSinglePrim()
  84. {
  85. TestHelpers.InMethod();
  86. m_scene.AddSceneObject(m_so1);
  87. SceneObjectPart rootPart = m_so1.RootPart;
  88. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  89. m_so1.ScriptSetVolumeDetect(true);
  90. // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
  91. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom));
  92. m_so1.ScriptSetVolumeDetect(false);
  93. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  94. }
  95. [Test]
  96. public void TestSetPhysicsSinglePrim()
  97. {
  98. TestHelpers.InMethod();
  99. m_scene.AddSceneObject(m_so1);
  100. SceneObjectPart rootPart = m_so1.RootPart;
  101. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  102. m_so1.ScriptSetPhysicsStatus(true);
  103. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  104. m_so1.ScriptSetPhysicsStatus(false);
  105. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  106. }
  107. [Test]
  108. public void TestSetPhysicsVolumeDetectSinglePrim()
  109. {
  110. TestHelpers.InMethod();
  111. m_scene.AddSceneObject(m_so1);
  112. SceneObjectPart rootPart = m_so1.RootPart;
  113. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  114. m_so1.ScriptSetPhysicsStatus(true);
  115. m_so1.ScriptSetVolumeDetect(true);
  116. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom | PrimFlags.Physics));
  117. m_so1.ScriptSetVolumeDetect(false);
  118. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  119. }
  120. [Test]
  121. public void TestSetPhysicsLinkset()
  122. {
  123. TestHelpers.InMethod();
  124. m_scene.AddSceneObject(m_so1);
  125. m_scene.AddSceneObject(m_so2);
  126. m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
  127. m_so1.ScriptSetPhysicsStatus(true);
  128. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  129. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
  130. m_so1.ScriptSetPhysicsStatus(false);
  131. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
  132. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
  133. m_so1.ScriptSetPhysicsStatus(true);
  134. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  135. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
  136. }
  137. /// <summary>
  138. /// Test that linking results in the correct physical status for all linkees.
  139. /// </summary>
  140. [Test]
  141. public void TestLinkPhysicsBothPhysical()
  142. {
  143. TestHelpers.InMethod();
  144. m_scene.AddSceneObject(m_so1);
  145. m_scene.AddSceneObject(m_so2);
  146. m_so1.ScriptSetPhysicsStatus(true);
  147. m_so2.ScriptSetPhysicsStatus(true);
  148. m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
  149. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  150. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
  151. }
  152. /// <summary>
  153. /// Test that linking results in the correct physical status for all linkees.
  154. /// </summary>
  155. [Test]
  156. public void TestLinkPhysicsRootPhysicalOnly()
  157. {
  158. TestHelpers.InMethod();
  159. m_scene.AddSceneObject(m_so1);
  160. m_scene.AddSceneObject(m_so2);
  161. m_so1.ScriptSetPhysicsStatus(true);
  162. m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
  163. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  164. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
  165. }
  166. /// <summary>
  167. /// Test that linking results in the correct physical status for all linkees.
  168. /// </summary>
  169. [Test]
  170. public void TestLinkPhysicsChildPhysicalOnly()
  171. {
  172. TestHelpers.InMethod();
  173. m_scene.AddSceneObject(m_so1);
  174. m_scene.AddSceneObject(m_so2);
  175. m_so2.ScriptSetPhysicsStatus(true);
  176. m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
  177. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
  178. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
  179. }
  180. }
  181. }