1
0

SceneObjectStatusTests.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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
  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 TestSetPhysicsSinglePrim()
  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.ScriptSetPhysicsStatus(true);
  77. // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
  78. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  79. m_so1.ScriptSetPhysicsStatus(false);
  80. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  81. }
  82. [Test]
  83. public void TestSetPhysicsLinkset()
  84. {
  85. TestHelpers.InMethod();
  86. m_scene.AddSceneObject(m_so1);
  87. m_scene.AddSceneObject(m_so2);
  88. m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
  89. m_so1.ScriptSetPhysicsStatus(true);
  90. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  91. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
  92. m_so1.ScriptSetPhysicsStatus(false);
  93. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
  94. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
  95. m_so1.ScriptSetPhysicsStatus(true);
  96. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  97. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
  98. }
  99. /// <summary>
  100. /// Test that linking results in the correct physical status for all linkees.
  101. /// </summary>
  102. [Test]
  103. public void TestLinkPhysicsRootPhysicalOnly()
  104. {
  105. TestHelpers.InMethod();
  106. m_scene.AddSceneObject(m_so1);
  107. m_scene.AddSceneObject(m_so2);
  108. m_so1.ScriptSetPhysicsStatus(true);
  109. m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
  110. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  111. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
  112. }
  113. /// <summary>
  114. /// Test that linking results in the correct physical status for all linkees.
  115. /// </summary>
  116. [Test]
  117. public void TestLinkPhysicsChildPhysicalOnly()
  118. {
  119. TestHelpers.InMethod();
  120. m_scene.AddSceneObject(m_so1);
  121. m_scene.AddSceneObject(m_so2);
  122. m_so2.ScriptSetPhysicsStatus(true);
  123. m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
  124. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
  125. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
  126. }
  127. }
  128. }