aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-05-22 19:18:24 +0100
committerJustin Clark-Casey (justincc)2014-05-22 19:18:24 +0100
commit1b156b7fe84bf132b51ff198d6d730708f5930b7 (patch)
tree94e68fffd365328c8d9be7571d8cbef478c90358 /OpenSim/Region
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-1b156b7fe84bf132b51ff198d6d730708f5930b7.zip
opensim-SC_OLD-1b156b7fe84bf132b51ff198d6d730708f5930b7.tar.gz
opensim-SC_OLD-1b156b7fe84bf132b51ff198d6d730708f5930b7.tar.bz2
opensim-SC_OLD-1b156b7fe84bf132b51ff198d6d730708f5930b7.tar.xz
Add regression test for in-range chat between neighbouring regions from east to west.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs158
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs5
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs1
3 files changed, 163 insertions, 1 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs
new file mode 100644
index 0000000..315cc19
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs
@@ -0,0 +1,158 @@
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 OpenSimulator 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
28using System;
29using System.Collections.Generic;
30using log4net.Config;
31using Nini.Config;
32using NUnit.Framework;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Servers;
36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Region.CoreModules.Avatar.Chat;
38using OpenSim.Region.CoreModules.Framework;
39using OpenSim.Region.CoreModules.Framework.EntityTransfer;
40using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Services.Interfaces;
43using OpenSim.Tests.Common;
44using OpenSim.Tests.Common.Mock;
45
46namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests
47{
48 [TestFixture]
49 public class ChatModuleTests : OpenSimTestCase
50 {
51 [TestFixtureSetUp]
52 public void FixtureInit()
53 {
54 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
55 // We must do this here so that child agent positions are updated in a predictable manner.
56 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
57 }
58
59 [TestFixtureTearDown]
60 public void TearDown()
61 {
62 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
63 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
64 // tests really shouldn't).
65 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
66 }
67
68 /// <summary>
69 /// Tests chat between neighbour regions on the east-west axis
70 /// </summary>
71 /// <remarks>
72 /// Really, this is a combination of a child agent position update test and a chat range test. These need
73 /// to be separated later on.
74 /// </remarks>
75 [Test]
76 public void TestInterRegionChatDistanceEastWest()
77 {
78 TestHelpers.InMethod();
79// TestHelpers.EnableLogging();
80
81 UUID sp1Uuid = TestHelpers.ParseTail(0x11);
82 UUID sp2Uuid = TestHelpers.ParseTail(0x12);
83
84 Vector3 sp1Position = new Vector3(6, 128, 20);
85 Vector3 sp2Position = new Vector3(250, 128, 20);
86
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();
107
108 TestScene sceneWest = sh.SetupScene("sceneWest", TestHelpers.ParseTail(0x1), 1000, 1000);
109 TestScene sceneEast = sh.SetupScene("sceneEast", TestHelpers.ParseTail(0x2), 1001, 1000);
110 SceneHelpers.SetupSceneModules(new Scene[] { sceneWest, sceneEast }, config, lscm);
111
112 SceneHelpers.SetupSceneModules(sceneWest, config, new CapabilitiesModule(), etmA, new ChatModule());
113 SceneHelpers.SetupSceneModules(sceneEast, config, new CapabilitiesModule(), etmB, new ChatModule());
114
115 ScenePresence sp1 = SceneHelpers.AddScenePresence(sceneEast, sp1Uuid);
116 TestClient sp1Client = (TestClient)sp1.ControllingClient;
117
118 // If we don't set agents to flying, test will go wrong as they instantly fall to z = 0.
119 // TODO: May need to create special complete no-op test physics module rather than basic physics, since
120 // physics is irrelevant to this test.
121 sp1.Flying = true;
122 sp1.AbsolutePosition = sp1Position;
123
124 AgentCircuitData acd = SceneHelpers.GenerateAgentData(sp2Uuid);
125 TestClient tc = new TestClient(acd, sceneEast);
126 List<TestClient> destinationTestClients = new List<TestClient>();
127 EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
128
129 ScenePresence sp2 = SceneHelpers.AddScenePresence(sceneWest, tc, acd);
130 TestClient sp2Client = (TestClient)sp2.ControllingClient;
131
132 sp2.Flying = true;
133 sp2.AbsolutePosition = sp2Position;
134
135 TestClient sp2ChildClient = destinationTestClients[0];
136
137 // We must update the scene in order to make the new root agent sp2 in sceneWest trigger a position update to its
138 // child in sceneEast.
139 sceneWest.Update(1);
140
141 // Check child position is correct.
142 Assert.AreEqual(
143 new Vector3(sp2Position.X - sceneWest.RegionInfo.RegionSizeX, sp2Position.Y, sp2Position.Z),
144 sp2ChildClient.SceneAgent.AbsolutePosition);
145
146 // Check chat received
147 string receivedChatMessage = "";
148
149 sp2ChildClient.OnReceivedChatMessage
150 += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedChatMessage = message;
151
152 string testMessage = "'ello darling";
153 sp1Client.Chat(0, ChatTypeEnum.Say, testMessage);
154
155 Assert.AreEqual(testMessage, receivedChatMessage);
156 }
157 }
158} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 3b8fbfd..7005c0a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -4133,7 +4133,10 @@ namespace OpenSim.Region.Framework.Scenes
4133 /// <returns>true if we handled it.</returns> 4133 /// <returns>true if we handled it.</returns>
4134 public virtual bool IncomingUpdateChildAgent(AgentPosition cAgentData) 4134 public virtual bool IncomingUpdateChildAgent(AgentPosition cAgentData)
4135 { 4135 {
4136 //m_log.Debug(" XXX Scene IncomingChildAgentDataUpdate POSITION in " + RegionInfo.RegionName); 4136// m_log.DebugFormat(
4137// "[SCENE PRESENCE]: IncomingChildAgentDataUpdate POSITION for {0} in {1}, position {2}",
4138// cAgentData.AgentID, Name, cAgentData.Position);
4139
4137 ScenePresence childAgentUpdate = GetScenePresence(cAgentData.AgentID); 4140 ScenePresence childAgentUpdate = GetScenePresence(cAgentData.AgentID);
4138 if (childAgentUpdate != null) 4141 if (childAgentUpdate != null)
4139 { 4142 {
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
index 8e40561..f53adcb 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
@@ -147,6 +147,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
147 terrainHeight = _heightMap[(int)actor.Position.Y * (int)m_regionExtent.Y + (int)actor.Position.X]; 147 terrainHeight = _heightMap[(int)actor.Position.Y * (int)m_regionExtent.Y + (int)actor.Position.X];
148 148
149 float height = terrainHeight + actor.Size.Z; 149 float height = terrainHeight + actor.Size.Z;
150// Console.WriteLine("height {0}, actorPosition {1}", height, actorPosition);
150 151
151 if (actor.Flying) 152 if (actor.Flying)
152 { 153 {