aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs185
1 files changed, 133 insertions, 52 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs
index bdaa97b..7b8c418 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs
@@ -65,6 +65,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests
65 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; 65 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
66 } 66 }
67 67
68 private void SetupNeighbourRegions(TestScene sceneA, TestScene sceneB)
69 {
70 // XXX: HTTP server is not (and should not be) necessary for this test, though it's absence makes the
71 // CapabilitiesModule complain when it can't set up HTTP endpoints.
72 // BaseHttpServer httpServer = new BaseHttpServer(99999);
73 // MainServer.AddHttpServer(httpServer);
74 // MainServer.Instance = httpServer;
75
76 // We need entity transfer modules so that when sp2 logs into the east region, the region calls
77 // EntityTransferModuleto set up a child agent on the west region.
78 // XXX: However, this is not an entity transfer so is misleading.
79 EntityTransferModule etmA = new EntityTransferModule();
80 EntityTransferModule etmB = new EntityTransferModule();
81 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
82
83 IConfigSource config = new IniConfigSource();
84 config.AddConfig("Chat");
85 IConfig modulesConfig = config.AddConfig("Modules");
86 modulesConfig.Set("EntityTransferModule", etmA.Name);
87 modulesConfig.Set("SimulationServices", lscm.Name);
88
89 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
90 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA, new ChatModule());
91 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB, new ChatModule());
92 }
93
68 /// <summary> 94 /// <summary>
69 /// Tests chat between neighbour regions on the east-west axis 95 /// Tests chat between neighbour regions on the east-west axis
70 /// </summary> 96 /// </summary>
@@ -84,33 +110,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests
84 Vector3 sp1Position = new Vector3(6, 128, 20); 110 Vector3 sp1Position = new Vector3(6, 128, 20);
85 Vector3 sp2Position = new Vector3(250, 128, 20); 111 Vector3 sp2Position = new Vector3(250, 128, 20);
86 112
87 // XXX: HTTP server is not (and should not be) necessary for this test, though it's absence makes the
88 // CapabilitiesModule complain when it can't set up HTTP endpoints.
89// BaseHttpServer httpServer = new BaseHttpServer(99999);
90// MainServer.AddHttpServer(httpServer);
91// MainServer.Instance = httpServer;
92
93 // We need entity transfer modules so that when sp2 logs into the east region, the region calls
94 // EntityTransferModuleto set up a child agent on the west region.
95 // XXX: However, this is not an entity transfer so is misleading.
96 EntityTransferModule etmA = new EntityTransferModule();
97 EntityTransferModule etmB = new EntityTransferModule();
98 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
99
100 IConfigSource config = new IniConfigSource();
101 config.AddConfig("Chat");
102 IConfig modulesConfig = config.AddConfig("Modules");
103 modulesConfig.Set("EntityTransferModule", etmA.Name);
104 modulesConfig.Set("SimulationServices", lscm.Name);
105
106 SceneHelpers sh = new SceneHelpers(); 113 SceneHelpers sh = new SceneHelpers();
107
108 TestScene sceneWest = sh.SetupScene("sceneWest", TestHelpers.ParseTail(0x1), 1000, 1000); 114 TestScene sceneWest = sh.SetupScene("sceneWest", TestHelpers.ParseTail(0x1), 1000, 1000);
109 TestScene sceneEast = sh.SetupScene("sceneEast", TestHelpers.ParseTail(0x2), 1001, 1000); 115 TestScene sceneEast = sh.SetupScene("sceneEast", TestHelpers.ParseTail(0x2), 1001, 1000);
110 SceneHelpers.SetupSceneModules(new Scene[] { sceneWest, sceneEast }, config, lscm);
111 116
112 SceneHelpers.SetupSceneModules(sceneWest, config, new CapabilitiesModule(), etmA, new ChatModule()); 117 SetupNeighbourRegions(sceneWest, sceneEast);
113 SceneHelpers.SetupSceneModules(sceneEast, config, new CapabilitiesModule(), etmB, new ChatModule());
114 118
115 ScenePresence sp1 = SceneHelpers.AddScenePresence(sceneEast, sp1Uuid); 119 ScenePresence sp1 = SceneHelpers.AddScenePresence(sceneEast, sp1Uuid);
116 TestClient sp1Client = (TestClient)sp1.ControllingClient; 120 TestClient sp1Client = (TestClient)sp1.ControllingClient;
@@ -158,23 +162,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests
158 sp2ChildClient.OnReceivedChatMessage 162 sp2ChildClient.OnReceivedChatMessage
159 += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp2ChatMessage = message; 163 += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp2ChatMessage = message;
160 164
161 // Check chat from sp1 165 TestUserInRange(sp1Client, "ello darling", ref receivedSp2ChatMessage);
162 { 166 TestUserInRange(sp2Client, "fantastic cats", ref receivedSp1ChatMessage);
163 string testMessage = "'ello darling";
164 sp1Client.Chat(0, ChatTypeEnum.Say, testMessage);
165
166// Assert.AreEqual(testMessage, receivedSp1ChatMessage);
167 Assert.AreEqual(testMessage, receivedSp2ChatMessage);
168 }
169
170 // Check chat from sp2
171 {
172 string testMessage = "fantastic cats";
173 sp2Client.Chat(0, ChatTypeEnum.Say, testMessage);
174
175 Assert.AreEqual(testMessage, receivedSp1ChatMessage);
176// Assert.AreEqual(testMessage, receivedSp2ChatMessage);
177 }
178 167
179 sp1Position = new Vector3(30, 128, 20); 168 sp1Position = new Vector3(30, 128, 20);
180 sp1.AbsolutePosition = sp1Position; 169 sp1.AbsolutePosition = sp1Position;
@@ -185,21 +174,113 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests
185 new Vector3(sp1Position.X + sceneEast.RegionInfo.RegionSizeX, sp1Position.Y, sp1Position.Z), 174 new Vector3(sp1Position.X + sceneEast.RegionInfo.RegionSizeX, sp1Position.Y, sp1Position.Z),
186 sp1ChildClient.SceneAgent.AbsolutePosition); 175 sp1ChildClient.SceneAgent.AbsolutePosition);
187 176
188 // sp2 should now be out of range for chat from sp1 177 TestUserOutOfRange(sp1Client, "beef", ref receivedSp2ChatMessage);
189 { 178 TestUserOutOfRange(sp2Client, "lentils", ref receivedSp1ChatMessage);
190 string testMessage = "beef"; 179 }
191 sp1Client.Chat(0, ChatTypeEnum.Say, testMessage); 180
181 /// <summary>
182 /// Tests chat between neighbour regions on the north-south axis
183 /// </summary>
184 /// <remarks>
185 /// Really, this is a combination of a child agent position update test and a chat range test. These need
186 /// to be separated later on.
187 /// </remarks>
188 [Test]
189 public void TestInterRegionChatDistanceNorthSouth()
190 {
191 TestHelpers.InMethod();
192 // TestHelpers.EnableLogging();
193
194 UUID sp1Uuid = TestHelpers.ParseTail(0x11);
195 UUID sp2Uuid = TestHelpers.ParseTail(0x12);
196
197 Vector3 sp1Position = new Vector3(128, 250, 20);
198 Vector3 sp2Position = new Vector3(128, 6, 20);
199
200 SceneHelpers sh = new SceneHelpers();
201 TestScene sceneNorth = sh.SetupScene("sceneNorth", TestHelpers.ParseTail(0x1), 1000, 1000);
202 TestScene sceneSouth = sh.SetupScene("sceneSouth", TestHelpers.ParseTail(0x2), 1000, 1001);
192 203
193 Assert.AreNotEqual(testMessage, receivedSp2ChatMessage); 204 SetupNeighbourRegions(sceneNorth, sceneSouth);
194 } 205
206 ScenePresence sp1 = SceneHelpers.AddScenePresence(sceneNorth, sp1Uuid);
207 TestClient sp1Client = (TestClient)sp1.ControllingClient;
208
209 // If we don't set agents to flying, test will go wrong as they instantly fall to z = 0.
210 // TODO: May need to create special complete no-op test physics module rather than basic physics, since
211 // physics is irrelevant to this test.
212 sp1.Flying = true;
213
214 // When sp1 logs in to sceneEast, it sets up a child agent in sceneNorth and informs the sp2 client to
215 // make the connection. For this test, will simplify this chain by making the connection directly.
216 ScenePresence sp1Child = SceneHelpers.AddChildScenePresence(sceneSouth, sp1Uuid);
217 TestClient sp1ChildClient = (TestClient)sp1Child.ControllingClient;
218
219 sp1.AbsolutePosition = sp1Position;
220
221 ScenePresence sp2 = SceneHelpers.AddScenePresence(sceneSouth, sp2Uuid);
222 TestClient sp2Client = (TestClient)sp2.ControllingClient;
223 sp2.Flying = true;
224
225 ScenePresence sp2Child = SceneHelpers.AddChildScenePresence(sceneNorth, sp2Uuid);
226 TestClient sp2ChildClient = (TestClient)sp2Child.ControllingClient;
227
228 sp2.AbsolutePosition = sp2Position;
229
230 // We must update the scenes in order to make the root new root agents trigger position updates in their
231 // children.
232 sceneNorth.Update(1);
233 sceneSouth.Update(1);
234
235 // Check child positions are correct.
236 Assert.AreEqual(
237 new Vector3(sp1Position.X, sp1Position.Y - sceneNorth.RegionInfo.RegionSizeY, sp1Position.Z),
238 sp1ChildClient.SceneAgent.AbsolutePosition);
239
240 Assert.AreEqual(
241 new Vector3(sp2Position.X, sp2Position.Y + sceneSouth.RegionInfo.RegionSizeY, sp2Position.Z),
242 sp2ChildClient.SceneAgent.AbsolutePosition);
243
244 string receivedSp1ChatMessage = "";
245 string receivedSp2ChatMessage = "";
246
247 sp1ChildClient.OnReceivedChatMessage
248 += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp1ChatMessage = message;
249 sp2ChildClient.OnReceivedChatMessage
250 += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp2ChatMessage = message;
251
252 TestUserInRange(sp1Client, "ello darling", ref receivedSp2ChatMessage);
253 TestUserInRange(sp2Client, "fantastic cats", ref receivedSp1ChatMessage);
254
255 sp1Position = new Vector3(30, 128, 20);
256 sp1.AbsolutePosition = sp1Position;
257 sceneNorth.Update(1);
258
259 // Check child position is correct.
260 Assert.AreEqual(
261 new Vector3(sp1Position.X, sp1Position.Y - sceneNorth.RegionInfo.RegionSizeY, sp1Position.Z),
262 sp1ChildClient.SceneAgent.AbsolutePosition);
263
264 TestUserOutOfRange(sp1Client, "beef", ref receivedSp2ChatMessage);
265 TestUserOutOfRange(sp2Client, "lentils", ref receivedSp1ChatMessage);
266 }
267
268 private void TestUserInRange(TestClient speakClient, string testMessage, ref string receivedMessage)
269 {
270 receivedMessage = "";
271
272 speakClient.Chat(0, ChatTypeEnum.Say, testMessage);
273
274 Assert.AreEqual(testMessage, receivedMessage);
275 }
276
277 private void TestUserOutOfRange(TestClient speakClient, string testMessage, ref string receivedMessage)
278 {
279 receivedMessage = "";
195 280
196 // sp1 should now be out of range for chat from sp2 281 speakClient.Chat(0, ChatTypeEnum.Say, testMessage);
197 {
198 string testMessage = "lentils";
199 sp2Client.Chat(0, ChatTypeEnum.Say, testMessage);
200 282
201 Assert.AreNotEqual(testMessage, receivedSp1ChatMessage); 283 Assert.AreNotEqual(testMessage, receivedMessage);
202 }
203 } 284 }
204 } 285 }
205} \ No newline at end of file 286} \ No newline at end of file