StandaloneTeleportTests.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 OpenSim 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 Nini.Config;
  28. using NUnit.Framework;
  29. using NUnit.Framework.SyntaxHelpers;
  30. using OpenMetaverse;
  31. using OpenSim.Framework;
  32. using OpenSim.Framework.Communications;
  33. using OpenSim.Region.Environment;
  34. using OpenSim.Region.Environment.Interfaces;
  35. using OpenSim.Region.Environment.Modules.Communications.REST;
  36. using OpenSim.Tests.Common.Mock;
  37. namespace OpenSim.Region.Environment.Scenes.Tests
  38. {
  39. /// <summary>
  40. /// Teleport tests in a standalone OpenSim
  41. /// </summary>
  42. [TestFixture]
  43. public class StandaloneTeleportTests
  44. {
  45. /// <summary>
  46. /// Test a teleport between two regions that are not neighbours and do not share any neighbours in common.
  47. /// </summary>
  48. /// Does not yet do what is says on the tin.
  49. [Test]
  50. public void TestSimpleNotNeighboursTeleport()
  51. {
  52. log4net.Config.XmlConfigurator.Configure();
  53. UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100");
  54. UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200");
  55. CommunicationsManager cm = new TestCommunicationsManager();
  56. // shared module
  57. IRegionModule interregionComms = new RESTInterregionComms();
  58. // TODO: Clean this up
  59. Scene sceneA = SceneTestUtils.SetupScene("sceneA", sceneAId, 1000, 1000, cm);
  60. interregionComms.Initialise(sceneA, new IniConfigSource());
  61. sceneA.AddModule(interregionComms.Name, interregionComms);
  62. sceneA.SetModuleInterfaces();
  63. sceneA.RegisterRegionWithGrid();
  64. // TODO: Clean this up
  65. Scene sceneB = SceneTestUtils.SetupScene("sceneB", sceneBId, 1010, 1010, cm);
  66. interregionComms.Initialise(sceneB, new IniConfigSource());
  67. sceneB.AddModule(interregionComms.Name, interregionComms);
  68. sceneB.SetModuleInterfaces();
  69. sceneB.RegisterRegionWithGrid();
  70. UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000041");
  71. TestClient client = SceneTestUtils.AddRootAgent(sceneA, agentId);
  72. // FIXME: This is a hack to get the test working - really the normal OpenSim mechanisms should be used.
  73. client.TeleportTargetScene = sceneB;
  74. client.Teleport(sceneB.RegionInfo.RegionHandle, new Vector3(100, 100, 100), new Vector3(40, 40, 40));
  75. Assert.That(sceneB.GetScenePresence(agentId), Is.Not.Null, "Client does not have an agent in sceneB");
  76. Assert.That(sceneA.GetScenePresence(agentId), Is.Null, "Client still had an agent in sceneA");
  77. // TODO: Check that more of everything is as it should be
  78. // TODO: test what happens if we try to teleport to a region that doesn't exist
  79. }
  80. }
  81. }