aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs177
1 files changed, 45 insertions, 132 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
index eb7bfbd..19542ff 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
@@ -61,7 +61,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
61 // Not strictly necessary since FriendsModule assumes it is the default (!) 61 // Not strictly necessary since FriendsModule assumes it is the default (!)
62 config.Configs["Modules"].Set("EntityTransferModule", etm.Name); 62 config.Configs["Modules"].Set("EntityTransferModule", etm.Name);
63 63
64 TestScene scene = SceneHelpers.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); 64 TestScene scene = new SceneHelpers().SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
65 SceneHelpers.SetupSceneModules(scene, config, etm); 65 SceneHelpers.SetupSceneModules(scene, config, etm);
66 66
67 Vector3 teleportPosition = new Vector3(10, 11, 12); 67 Vector3 teleportPosition = new Vector3(10, 11, 12);
@@ -83,145 +83,58 @@ namespace OpenSim.Region.Framework.Scenes.Tests
83// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); 83// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
84 } 84 }
85 85
86 /// <summary> 86 [Test]
87 /// Test a teleport between two regions that are not neighbours and do not share any neighbours in common. 87 public void TestSameSimulatorSeparatedRegionsTeleport()
88 /// </summary>
89 /// Does not yet do what is says on the tin.
90 /// Commenting for now
91 //[Test, LongRunning]
92 public void TestSimpleNotNeighboursTeleport()
93 { 88 {
94 TestHelpers.InMethod(); 89 TestHelpers.InMethod();
95 ThreadRunResults results = new ThreadRunResults(); 90// log4net.Config.XmlConfigurator.Configure();
96 results.Result = false;
97 results.Message = "Test did not run";
98 TestRunning testClass = new TestRunning(results);
99 91
100 Thread testThread = new Thread(testClass.run); 92 UUID userId = TestHelpers.ParseTail(0x1);
101 93
102 // Seems kind of redundant to start a thread and then join it, however.. We need to protect against 94 EntityTransferModule etm = new EntityTransferModule();
103 // A thread abort exception in the simulator code. 95 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
104 testThread.Start();
105 testThread.Join();
106 96
107 Assert.That(testClass.results.Result, Is.EqualTo(true), testClass.results.Message); 97 IConfigSource config = new IniConfigSource();
108 // Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); 98 config.AddConfig("Modules");
109 } 99 // Not strictly necessary since FriendsModule assumes it is the default (!)
100 config.Configs["Modules"].Set("EntityTransferModule", etm.Name);
101 config.Configs["Modules"].Set("SimulationServices", lscm.Name);
110 102
111 [TearDown] 103 SceneHelpers sh = new SceneHelpers();
112 public void TearDown() 104 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
113 { 105 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
114 try
115 {
116 if (MainServer.Instance != null) MainServer.Instance.Stop();
117 }
118 catch (NullReferenceException)
119 { }
120 }
121 106
122 } 107 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, etm, lscm);
123 108
124 public class ThreadRunResults 109 Vector3 teleportPosition = new Vector3(10, 11, 12);
125 { 110 Vector3 teleportLookAt = new Vector3(20, 21, 22);
126 public bool Result = false;
127 public string Message = string.Empty;
128 }
129 111
130 public class TestRunning 112 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);
131 { 113 sp.AbsolutePosition = new Vector3(30, 31, 32);
132 public ThreadRunResults results; 114
133 public TestRunning(ThreadRunResults t) 115 // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole
134 { 116 // UDP stack (?)
135 results = t; 117 ((TestClient)sp.ControllingClient).TeleportTargetScene = sceneB;
136 } 118
137 public void run(object o) 119 sceneA.RequestTeleportLocation(
138 { 120 sp.ControllingClient,
139 121 sceneB.RegionInfo.RegionHandle,
140 //results.Result = true; 122 teleportPosition,
141 log4net.Config.XmlConfigurator.Configure(); 123 teleportLookAt,
142 124 (uint)TeleportFlags.ViaLocation);
143 UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100"); 125
144 UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200"); 126 Assert.That(sceneA.GetScenePresence(userId), Is.Null);
145 127
146 // shared module 128 ScenePresence sceneBSp = sceneB.GetScenePresence(userId);
147 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); 129 Assert.That(sceneBSp, Is.Not.Null);
148 130 Assert.That(sceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
149 131 Assert.That(sceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
150 Scene sceneB = SceneHelpers.SetupScene("sceneB", sceneBId, 1010, 1010); 132
151 SceneHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms); 133 // TODO: Add assertions to check correct circuit details in both scenes.
152 sceneB.RegisterRegionWithGrid(); 134
153 135 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
154 Scene sceneA = SceneHelpers.SetupScene("sceneA", sceneAId, 1000, 1000); 136 // position instead).
155 SceneHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms); 137// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
156 sceneA.RegisterRegionWithGrid();
157
158 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000041");
159 TestClient client = (TestClient)SceneHelpers.AddScenePresence(sceneA, agentId).ControllingClient;
160
161 ICapabilitiesModule sceneACapsModule = sceneA.RequestModuleInterface<ICapabilitiesModule>();
162
163 results.Result = (sceneACapsModule.GetCapsPath(agentId) == client.CapsSeedUrl);
164
165 if (!results.Result)
166 {
167 results.Message = "Incorrect caps object path set up in sceneA";
168 return;
169 }
170
171 /*
172 Assert.That(
173 sceneACapsModule.GetCapsPath(agentId),
174 Is.EqualTo(client.CapsSeedUrl),
175 "Incorrect caps object path set up in sceneA");
176 */
177 // FIXME: This is a hack to get the test working - really the normal OpenSim mechanisms should be used.
178
179
180 client.TeleportTargetScene = sceneB;
181 client.Teleport(sceneB.RegionInfo.RegionHandle, new Vector3(100, 100, 100), new Vector3(40, 40, 40));
182
183 results.Result = (sceneB.GetScenePresence(agentId) != null);
184 if (!results.Result)
185 {
186 results.Message = "Client does not have an agent in sceneB";
187 return;
188 }
189
190 //Assert.That(sceneB.GetScenePresence(agentId), Is.Not.Null, "Client does not have an agent in sceneB");
191
192 //Assert.That(sceneA.GetScenePresence(agentId), Is.Null, "Client still had an agent in sceneA");
193
194 results.Result = (sceneA.GetScenePresence(agentId) == null);
195 if (!results.Result)
196 {
197 results.Message = "Client still had an agent in sceneA";
198 return;
199 }
200
201 ICapabilitiesModule sceneBCapsModule = sceneB.RequestModuleInterface<ICapabilitiesModule>();
202
203
204 results.Result = ("http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort +
205 "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/" == client.CapsSeedUrl);
206 if (!results.Result)
207 {
208 results.Message = "Incorrect caps object path set up in sceneB";
209 return;
210 }
211
212 // Temporary assertion - caps url construction should at least be doable through a method.
213 /*
214 Assert.That(
215 "http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort + "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/",
216 Is.EqualTo(client.CapsSeedUrl),
217 "Incorrect caps object path set up in sceneB");
218 */
219 // This assertion will currently fail since we don't remove the caps paths when no longer needed
220 //Assert.That(sceneACapsModule.GetCapsPath(agentId), Is.Null, "sceneA still had a caps object path");
221
222 // TODO: Check that more of everything is as it should be
223
224 // TODO: test what happens if we try to teleport to a region that doesn't exist
225 } 138 }
226 } 139 }
227} 140} \ No newline at end of file