SceneObjectStatusTests.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. using OpenSim.Tests.Common.Mock;
  37. namespace OpenSim.Region.Framework.Scenes.Tests
  38. {
  39. /// <summary>
  40. /// Basic scene object status tests
  41. /// </summary>
  42. [TestFixture]
  43. public class SceneObjectStatusTests : OpenSimTestCase
  44. {
  45. private TestScene m_scene;
  46. private UUID m_ownerId = TestHelpers.ParseTail(0x1);
  47. private SceneObjectGroup m_so1;
  48. private SceneObjectGroup m_so2;
  49. [SetUp]
  50. public void Init()
  51. {
  52. m_scene = new SceneHelpers().SetupScene();
  53. m_so1 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so1", 0x10);
  54. m_so2 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so2", 0x20);
  55. }
  56. [Test]
  57. public void TestSetPhantomSinglePrim()
  58. {
  59. TestHelpers.InMethod();
  60. m_scene.AddSceneObject(m_so1);
  61. SceneObjectPart rootPart = m_so1.RootPart;
  62. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  63. m_so1.ScriptSetPhantomStatus(true);
  64. // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
  65. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom));
  66. m_so1.ScriptSetPhantomStatus(false);
  67. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  68. }
  69. [Test]
  70. public void TestSetNonPhysicsVolumeDetectSinglePrim()
  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.ScriptSetVolumeDetect(true);
  77. // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
  78. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom));
  79. m_so1.ScriptSetVolumeDetect(false);
  80. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  81. }
  82. [Test]
  83. public void TestSetPhysicsSinglePrim()
  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.ScriptSetPhysicsStatus(true);
  90. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  91. m_so1.ScriptSetPhysicsStatus(false);
  92. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  93. }
  94. [Test]
  95. public void TestSetPhysicsVolumeDetectSinglePrim()
  96. {
  97. TestHelpers.InMethod();
  98. m_scene.AddSceneObject(m_so1);
  99. SceneObjectPart rootPart = m_so1.RootPart;
  100. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  101. m_so1.ScriptSetPhysicsStatus(true);
  102. m_so1.ScriptSetVolumeDetect(true);
  103. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom | PrimFlags.Physics));
  104. m_so1.ScriptSetVolumeDetect(false);
  105. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  106. }
  107. [Test]
  108. public void TestSetPhysicsLinkset()
  109. {
  110. TestHelpers.InMethod();
  111. m_scene.AddSceneObject(m_so1);
  112. m_scene.AddSceneObject(m_so2);
  113. m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
  114. m_so1.ScriptSetPhysicsStatus(true);
  115. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  116. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
  117. m_so1.ScriptSetPhysicsStatus(false);
  118. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
  119. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
  120. m_so1.ScriptSetPhysicsStatus(true);
  121. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  122. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
  123. }
  124. /// <summary>
  125. /// Test that linking results in the correct physical status for all linkees.
  126. /// </summary>
  127. [Test]
  128. public void TestLinkPhysicsBothPhysical()
  129. {
  130. TestHelpers.InMethod();
  131. m_scene.AddSceneObject(m_so1);
  132. m_scene.AddSceneObject(m_so2);
  133. m_so1.ScriptSetPhysicsStatus(true);
  134. m_so2.ScriptSetPhysicsStatus(true);
  135. m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
  136. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  137. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
  138. }
  139. /// <summary>
  140. /// Test that linking results in the correct physical status for all linkees.
  141. /// </summary>
  142. [Test]
  143. public void TestLinkPhysicsRootPhysicalOnly()
  144. {
  145. TestHelpers.InMethod();
  146. m_scene.AddSceneObject(m_so1);
  147. m_scene.AddSceneObject(m_so2);
  148. m_so1.ScriptSetPhysicsStatus(true);
  149. m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
  150. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  151. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
  152. }
  153. /// <summary>
  154. /// Test that linking results in the correct physical status for all linkees.
  155. /// </summary>
  156. [Test]
  157. public void TestLinkPhysicsChildPhysicalOnly()
  158. {
  159. TestHelpers.InMethod();
  160. m_scene.AddSceneObject(m_so1);
  161. m_scene.AddSceneObject(m_so2);
  162. m_so2.ScriptSetPhysicsStatus(true);
  163. m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
  164. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
  165. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
  166. }
  167. }
  168. }