SceneObjectBasicTests.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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.Reflection;
  29. using NUnit.Framework;
  30. using NUnit.Framework.SyntaxHelpers;
  31. using OpenMetaverse;
  32. using OpenSim.Framework;
  33. using OpenSim.Framework.Communications;
  34. using OpenSim.Framework.Communications.Cache;
  35. using OpenSim.Region.Communications.Local;
  36. using OpenSim.Region.Framework.Scenes;
  37. using OpenSim.Tests.Common;
  38. using OpenSim.Tests.Common.Mock;
  39. using OpenSim.Tests.Common.Setup;
  40. namespace OpenSim.Region.Framework.Scenes.Tests
  41. {
  42. /// <summary>
  43. /// Basic scene object tests (create, read and delete but not update).
  44. /// </summary>
  45. [TestFixture]
  46. public class SceneObjectBasicTests
  47. {
  48. /// <summary>
  49. /// Test adding an object to a scene.
  50. /// </summary>
  51. [Test, LongRunning]
  52. public void TestAddSceneObject()
  53. {
  54. TestHelper.InMethod();
  55. Scene scene = SceneSetupHelpers.SetupScene();
  56. SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene);
  57. SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
  58. //m_log.Debug("retrievedPart : {0}", retrievedPart);
  59. // If the parts have the same UUID then we will consider them as one and the same
  60. Assert.That(retrievedPart.UUID, Is.EqualTo(part.UUID));
  61. }
  62. /// <summary>
  63. /// Test deleting an object from a scene.
  64. /// </summary>
  65. [Test]
  66. public void TestDeleteSceneObject()
  67. {
  68. TestHelper.InMethod();
  69. TestScene scene = SceneSetupHelpers.SetupScene();
  70. SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene);
  71. scene.DeleteSceneObject(part.ParentGroup, false);
  72. SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
  73. Assert.That(retrievedPart, Is.Null);
  74. }
  75. /// <summary>
  76. /// Test deleting an object asynchronously
  77. /// </summary>
  78. [Test]
  79. public void TestDeleteSceneObjectAsync()
  80. {
  81. TestHelper.InMethod();
  82. UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
  83. TestScene scene = SceneSetupHelpers.SetupScene();
  84. // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
  85. AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
  86. sogd.Enabled = false;
  87. SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene);
  88. IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId);
  89. scene.DeRezObject(client, part.LocalId, UUID.Zero, DeRezAction.Delete, UUID.Zero);
  90. SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
  91. Assert.That(retrievedPart, Is.Not.Null);
  92. sogd.InventoryDeQueueAndDelete();
  93. SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId);
  94. Assert.That(retrievedPart2, Is.Null);
  95. }
  96. /// <summary>
  97. /// Test deleting an object asynchronously to user inventory.
  98. /// </summary>
  99. //[Test]
  100. //public void TestDeleteSceneObjectAsyncToUserInventory()
  101. //{
  102. // TestHelper.InMethod();
  103. // //log4net.Config.XmlConfigurator.Configure();
  104. // UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
  105. // string myObjectName = "Fred";
  106. // TestScene scene = SceneSetupHelpers.SetupScene();
  107. // SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene, myObjectName);
  108. // Assert.That(
  109. // scene.CommsManager.UserAdminService.AddUser(
  110. // "Bob", "Hoskins", "test", "[email protected]", 1000, 1000, agentId),
  111. // Is.EqualTo(agentId));
  112. // IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId);
  113. // CachedUserInfo userInfo = scene.CommsManager.UserProfileCacheService.GetUserDetails(agentId);
  114. // Assert.That(userInfo, Is.Not.Null);
  115. // Assert.That(userInfo.RootFolder, Is.Not.Null);
  116. // SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client);
  117. // // Check that we now have the taken part in our inventory
  118. // Assert.That(myObjectName, Is.EqualTo(userInfo.RootFolder.FindItemByPath(myObjectName).Name));
  119. // // Check that the taken part has actually disappeared
  120. // SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
  121. // Assert.That(retrievedPart, Is.Null);
  122. //}
  123. }
  124. }