SceneTelehubTests.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Redistribution and use in source and binary forms, with or without
  3. * modification, are permitted provided that the following conditions are met:
  4. * * Redistributions of source code must retain the above copyright
  5. * notice, this list of conditions and the following disclaimer.
  6. * * Redistributions in binary form must reproduce the above copyright
  7. * notice, this list of conditions and the following disclaimer in the
  8. * documentation and/or other materials provided with the distribution.
  9. * * Neither the name of the OpenSimulator Project nor the
  10. * names of its contributors may be used to endorse or promote products
  11. * derived from this software without specific prior written permission.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  14. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  16. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  17. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. */
  24. using System;
  25. using Nini.Config;
  26. using NUnit.Framework;
  27. using OpenMetaverse;
  28. using OpenSim.Framework;
  29. using OpenSim.Region.CoreModules.World.Estate;
  30. using OpenSim.Region.Framework.Scenes;
  31. using OpenSim.Region.Framework.Interfaces;
  32. using OpenSim.Services.Interfaces;
  33. using OpenSim.Tests.Common;
  34. using OpenSim.Tests.Common.Mock;
  35. namespace OpenSim.Region.Framework.Scenes.Tests
  36. {
  37. /// <summary>
  38. /// Scene telehub tests
  39. /// </summary>
  40. /// <remarks>
  41. /// TODO: Tests which run through normal functionality. Currently, the only test is one that checks behaviour
  42. /// in the case of an error condition
  43. /// </remarks>
  44. [TestFixture]
  45. public class SceneTelehubTests : OpenSimTestCase
  46. {
  47. /// <summary>
  48. /// Test for desired behaviour when a telehub has no spawn points
  49. /// </summary>
  50. [Test]
  51. public void TestNoTelehubSpawnPoints()
  52. {
  53. TestHelpers.InMethod();
  54. // TestHelpers.EnableLogging();
  55. EstateManagementModule emm = new EstateManagementModule();
  56. SceneHelpers sh = new SceneHelpers();
  57. Scene scene = sh.SetupScene();
  58. SceneHelpers.SetupSceneModules(scene, emm);
  59. UUID telehubSceneObjectOwner = TestHelpers.ParseTail(0x1);
  60. SceneObjectGroup telehubSo = SceneHelpers.AddSceneObject(scene, "telehubObject", telehubSceneObjectOwner);
  61. emm.HandleOnEstateManageTelehub(null, UUID.Zero, UUID.Zero, "connect", telehubSo.LocalId);
  62. scene.RegionInfo.EstateSettings.AllowDirectTeleport = false;
  63. // Must still be possible to successfully log in
  64. UUID loggingInUserId = TestHelpers.ParseTail(0x2);
  65. UserAccount ua
  66. = UserAccountHelpers.CreateUserWithInventory(scene, "Test", "User", loggingInUserId, "password");
  67. SceneHelpers.AddScenePresence(scene, ua);
  68. Assert.That(scene.GetScenePresence(loggingInUserId), Is.Not.Null);
  69. }
  70. /// <summary>
  71. /// Test for desired behaviour when the scene object nominated as a telehub object does not exist.
  72. /// </summary>
  73. [Test]
  74. public void TestNoTelehubSceneObject()
  75. {
  76. TestHelpers.InMethod();
  77. // TestHelpers.EnableLogging();
  78. EstateManagementModule emm = new EstateManagementModule();
  79. SceneHelpers sh = new SceneHelpers();
  80. Scene scene = sh.SetupScene();
  81. SceneHelpers.SetupSceneModules(scene, emm);
  82. UUID telehubSceneObjectOwner = TestHelpers.ParseTail(0x1);
  83. SceneObjectGroup telehubSo = SceneHelpers.AddSceneObject(scene, "telehubObject", telehubSceneObjectOwner);
  84. SceneObjectGroup spawnPointSo = SceneHelpers.AddSceneObject(scene, "spawnpointObject", telehubSceneObjectOwner);
  85. emm.HandleOnEstateManageTelehub(null, UUID.Zero, UUID.Zero, "connect", telehubSo.LocalId);
  86. emm.HandleOnEstateManageTelehub(null, UUID.Zero, UUID.Zero, "spawnpoint add", spawnPointSo.LocalId);
  87. scene.RegionInfo.EstateSettings.AllowDirectTeleport = false;
  88. scene.DeleteSceneObject(telehubSo, false);
  89. // Must still be possible to successfully log in
  90. UUID loggingInUserId = TestHelpers.ParseTail(0x2);
  91. UserAccount ua
  92. = UserAccountHelpers.CreateUserWithInventory(scene, "Test", "User", loggingInUserId, "password");
  93. SceneHelpers.AddScenePresence(scene, ua);
  94. Assert.That(scene.GetScenePresence(loggingInUserId), Is.Not.Null);
  95. }
  96. }
  97. }