1
0

SceneObjectStatusTests.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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 TestSetTemporary()
  58. {
  59. TestHelpers.InMethod();
  60. m_scene.AddSceneObject(m_so1);
  61. m_so1.ScriptSetTemporaryStatus(true);
  62. // Is this really the correct flag?
  63. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.TemporaryOnRez));
  64. Assert.That(m_so1.Backup, Is.False);
  65. // Test setting back to non-temporary
  66. m_so1.ScriptSetTemporaryStatus(false);
  67. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
  68. Assert.That(m_so1.Backup, Is.True);
  69. }
  70. [Test]
  71. public void TestSetPhantomSinglePrim()
  72. {
  73. TestHelpers.InMethod();
  74. m_scene.AddSceneObject(m_so1);
  75. SceneObjectPart rootPart = m_so1.RootPart;
  76. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  77. m_so1.ScriptSetPhantomStatus(true);
  78. // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
  79. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom));
  80. m_so1.ScriptSetPhantomStatus(false);
  81. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  82. }
  83. [Test]
  84. public void TestSetNonPhysicsVolumeDetectSinglePrim()
  85. {
  86. TestHelpers.InMethod();
  87. m_scene.AddSceneObject(m_so1);
  88. SceneObjectPart rootPart = m_so1.RootPart;
  89. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  90. m_so1.ScriptSetVolumeDetect(true);
  91. // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
  92. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom));
  93. m_so1.ScriptSetVolumeDetect(false);
  94. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  95. }
  96. [Test]
  97. public void TestSetPhysicsSinglePrim()
  98. {
  99. TestHelpers.InMethod();
  100. m_scene.AddSceneObject(m_so1);
  101. SceneObjectPart rootPart = m_so1.RootPart;
  102. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  103. m_so1.ScriptSetPhysicsStatus(true);
  104. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  105. m_so1.ScriptSetPhysicsStatus(false);
  106. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  107. }
  108. [Test]
  109. public void TestSetPhysicsVolumeDetectSinglePrim()
  110. {
  111. TestHelpers.InMethod();
  112. m_scene.AddSceneObject(m_so1);
  113. SceneObjectPart rootPart = m_so1.RootPart;
  114. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  115. m_so1.ScriptSetPhysicsStatus(true);
  116. m_so1.ScriptSetVolumeDetect(true);
  117. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom | PrimFlags.Physics));
  118. m_so1.ScriptSetVolumeDetect(false);
  119. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  120. }
  121. [Test]
  122. public void TestSetPhysicsLinkset()
  123. {
  124. TestHelpers.InMethod();
  125. m_scene.AddSceneObject(m_so1);
  126. m_scene.AddSceneObject(m_so2);
  127. m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
  128. m_so1.ScriptSetPhysicsStatus(true);
  129. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  130. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
  131. m_so1.ScriptSetPhysicsStatus(false);
  132. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
  133. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
  134. m_so1.ScriptSetPhysicsStatus(true);
  135. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  136. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
  137. }
  138. /// <summary>
  139. /// Test that linking results in the correct physical status for all linkees.
  140. /// </summary>
  141. [Test]
  142. public void TestLinkPhysicsBothPhysical()
  143. {
  144. TestHelpers.InMethod();
  145. m_scene.AddSceneObject(m_so1);
  146. m_scene.AddSceneObject(m_so2);
  147. m_so1.ScriptSetPhysicsStatus(true);
  148. m_so2.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 TestLinkPhysicsRootPhysicalOnly()
  158. {
  159. TestHelpers.InMethod();
  160. m_scene.AddSceneObject(m_so1);
  161. m_scene.AddSceneObject(m_so2);
  162. m_so1.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.Physics));
  165. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
  166. }
  167. /// <summary>
  168. /// Test that linking results in the correct physical status for all linkees.
  169. /// </summary>
  170. [Test]
  171. public void TestLinkPhysicsChildPhysicalOnly()
  172. {
  173. TestHelpers.InMethod();
  174. m_scene.AddSceneObject(m_so1);
  175. m_scene.AddSceneObject(m_so2);
  176. m_so2.ScriptSetPhysicsStatus(true);
  177. m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
  178. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
  179. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
  180. }
  181. }
  182. }