1
0

SceneTelehubTests.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. namespace OpenSim.Region.Framework.Scenes.Tests
  35. {
  36. /// <summary>
  37. /// Scene telehub tests
  38. /// </summary>
  39. /// <remarks>
  40. /// TODO: Tests which run through normal functionality. Currently, the only test is one that checks behaviour
  41. /// in the case of an error condition
  42. /// </remarks>
  43. [TestFixture]
  44. public class SceneTelehubTests : OpenSimTestCase
  45. {
  46. /// <summary>
  47. /// Test for desired behaviour when a telehub has no spawn points
  48. /// </summary>
  49. [Test]
  50. public void TestNoTelehubSpawnPoints()
  51. {
  52. TestHelpers.InMethod();
  53. // TestHelpers.EnableLogging();
  54. EstateManagementModule emm = new EstateManagementModule();
  55. SceneHelpers sh = new SceneHelpers();
  56. Scene scene = sh.SetupScene();
  57. SceneHelpers.SetupSceneModules(scene, emm);
  58. UUID telehubSceneObjectOwner = TestHelpers.ParseTail(0x1);
  59. SceneObjectGroup telehubSo = SceneHelpers.AddSceneObject(scene, "telehubObject", telehubSceneObjectOwner);
  60. emm.HandleOnEstateManageTelehub(null, UUID.Zero, UUID.Zero, "connect", telehubSo.LocalId);
  61. scene.RegionInfo.EstateSettings.AllowDirectTeleport = false;
  62. // Must still be possible to successfully log in
  63. UUID loggingInUserId = TestHelpers.ParseTail(0x2);
  64. UserAccount ua
  65. = UserAccountHelpers.CreateUserWithInventory(scene, "Test", "User", loggingInUserId, "password");
  66. SceneHelpers.AddScenePresence(scene, ua);
  67. Assert.That(scene.GetScenePresence(loggingInUserId), Is.Not.Null);
  68. }
  69. /// <summary>
  70. /// Test for desired behaviour when the scene object nominated as a telehub object does not exist.
  71. /// </summary>
  72. [Test]
  73. public void TestNoTelehubSceneObject()
  74. {
  75. TestHelpers.InMethod();
  76. // TestHelpers.EnableLogging();
  77. EstateManagementModule emm = new EstateManagementModule();
  78. SceneHelpers sh = new SceneHelpers();
  79. Scene scene = sh.SetupScene();
  80. SceneHelpers.SetupSceneModules(scene, emm);
  81. UUID telehubSceneObjectOwner = TestHelpers.ParseTail(0x1);
  82. SceneObjectGroup telehubSo = SceneHelpers.AddSceneObject(scene, "telehubObject", telehubSceneObjectOwner);
  83. SceneObjectGroup spawnPointSo = SceneHelpers.AddSceneObject(scene, "spawnpointObject", telehubSceneObjectOwner);
  84. emm.HandleOnEstateManageTelehub(null, UUID.Zero, UUID.Zero, "connect", telehubSo.LocalId);
  85. emm.HandleOnEstateManageTelehub(null, UUID.Zero, UUID.Zero, "spawnpoint add", spawnPointSo.LocalId);
  86. scene.RegionInfo.EstateSettings.AllowDirectTeleport = false;
  87. scene.DeleteSceneObject(telehubSo, false);
  88. // Must still be possible to successfully log in
  89. UUID loggingInUserId = TestHelpers.ParseTail(0x2);
  90. UserAccount ua
  91. = UserAccountHelpers.CreateUserWithInventory(scene, "Test", "User", loggingInUserId, "password");
  92. SceneHelpers.AddScenePresence(scene, ua);
  93. Assert.That(scene.GetScenePresence(loggingInUserId), Is.Not.Null);
  94. }
  95. }
  96. }