diff options
author | Justin Clark-Casey (justincc) | 2014-05-22 19:18:24 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-05-22 19:18:24 +0100 |
commit | 1b156b7fe84bf132b51ff198d6d730708f5930b7 (patch) | |
tree | 94e68fffd365328c8d9be7571d8cbef478c90358 | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-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.
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs | 158 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 5 | ||||
-rw-r--r-- | OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs | 1 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestClient.cs | 40 | ||||
-rw-r--r-- | prebuild.xml | 1 |
5 files changed, 204 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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using log4net.Config; | ||
31 | using Nini.Config; | ||
32 | using NUnit.Framework; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Servers; | ||
36 | using OpenSim.Framework.Servers.HttpServer; | ||
37 | using OpenSim.Region.CoreModules.Avatar.Chat; | ||
38 | using OpenSim.Region.CoreModules.Framework; | ||
39 | using OpenSim.Region.CoreModules.Framework.EntityTransfer; | ||
40 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using OpenSim.Services.Interfaces; | ||
43 | using OpenSim.Tests.Common; | ||
44 | using OpenSim.Tests.Common.Mock; | ||
45 | |||
46 | namespace 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 | { |
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index c2b0935..8eeaf99 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs | |||
@@ -62,14 +62,23 @@ namespace OpenSim.Tests.Common.Mock | |||
62 | public event Action<RegionInfo, Vector3, Vector3> OnReceivedMoveAgentIntoRegion; | 62 | public event Action<RegionInfo, Vector3, Vector3> OnReceivedMoveAgentIntoRegion; |
63 | public event Action<ulong, IPEndPoint> OnTestClientInformClientOfNeighbour; | 63 | public event Action<ulong, IPEndPoint> OnTestClientInformClientOfNeighbour; |
64 | public event TestClientOnSendRegionTeleportDelegate OnTestClientSendRegionTeleport; | 64 | public event TestClientOnSendRegionTeleportDelegate OnTestClientSendRegionTeleport; |
65 | |||
65 | public event Action<ISceneEntity, PrimUpdateFlags> OnReceivedEntityUpdate; | 66 | public event Action<ISceneEntity, PrimUpdateFlags> OnReceivedEntityUpdate; |
67 | |||
68 | public event OnReceivedChatMessageDelegate OnReceivedChatMessage; | ||
66 | public event Action<GridInstantMessage> OnReceivedInstantMessage; | 69 | public event Action<GridInstantMessage> OnReceivedInstantMessage; |
70 | |||
67 | public event Action<UUID> OnReceivedSendRebakeAvatarTextures; | 71 | public event Action<UUID> OnReceivedSendRebakeAvatarTextures; |
68 | 72 | ||
69 | public delegate void TestClientOnSendRegionTeleportDelegate( | 73 | public delegate void TestClientOnSendRegionTeleportDelegate( |
70 | ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, | 74 | ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, |
71 | uint locationID, uint flags, string capsURL); | 75 | uint locationID, uint flags, string capsURL); |
72 | 76 | ||
77 | public delegate void OnReceivedChatMessageDelegate( | ||
78 | string message, byte type, Vector3 fromPos, string fromName, | ||
79 | UUID fromAgentID, UUID ownerID, byte source, byte audible); | ||
80 | |||
81 | |||
73 | // disable warning: public events, part of the public API | 82 | // disable warning: public events, part of the public API |
74 | #pragma warning disable 67 | 83 | #pragma warning disable 67 |
75 | 84 | ||
@@ -467,6 +476,34 @@ namespace OpenSim.Tests.Common.Mock | |||
467 | } | 476 | } |
468 | 477 | ||
469 | /// <summary> | 478 | /// <summary> |
479 | /// Trigger chat coming from this connection. | ||
480 | /// </summary> | ||
481 | /// <param name="channel"></param> | ||
482 | /// <param name="type"></param> | ||
483 | /// <param name="message"></param> | ||
484 | public bool Chat(int channel, ChatTypeEnum type, string message) | ||
485 | { | ||
486 | ChatMessage handlerChatFromClient = OnChatFromClient; | ||
487 | |||
488 | if (handlerChatFromClient != null) | ||
489 | { | ||
490 | OSChatMessage args = new OSChatMessage(); | ||
491 | args.Channel = channel; | ||
492 | args.From = Name; | ||
493 | args.Message = message; | ||
494 | args.Type = type; | ||
495 | |||
496 | args.Scene = Scene; | ||
497 | args.Sender = this; | ||
498 | args.SenderUUID = AgentId; | ||
499 | |||
500 | handlerChatFromClient(this, args); | ||
501 | } | ||
502 | |||
503 | return true; | ||
504 | } | ||
505 | |||
506 | /// <summary> | ||
470 | /// Attempt a teleport to the given region. | 507 | /// Attempt a teleport to the given region. |
471 | /// </summary> | 508 | /// </summary> |
472 | /// <param name="regionHandle"></param> | 509 | /// <param name="regionHandle"></param> |
@@ -550,6 +587,9 @@ namespace OpenSim.Tests.Common.Mock | |||
550 | string message, byte type, Vector3 fromPos, string fromName, | 587 | string message, byte type, Vector3 fromPos, string fromName, |
551 | UUID fromAgentID, UUID ownerID, byte source, byte audible) | 588 | UUID fromAgentID, UUID ownerID, byte source, byte audible) |
552 | { | 589 | { |
590 | // Console.WriteLine("mmm {0} {1} {2}", message, Name, AgentId); | ||
591 | if (OnReceivedChatMessage != null) | ||
592 | OnReceivedChatMessage(message, type, fromPos, fromName, fromAgentID, ownerID, source, audible); | ||
553 | } | 593 | } |
554 | 594 | ||
555 | public void SendInstantMessage(GridInstantMessage im) | 595 | public void SendInstantMessage(GridInstantMessage im) |
diff --git a/prebuild.xml b/prebuild.xml index 9a419eb..196bfd2 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -3081,6 +3081,7 @@ | |||
3081 | <Match path="Asset/Tests" pattern="*.cs" recurse="true"/> | 3081 | <Match path="Asset/Tests" pattern="*.cs" recurse="true"/> |
3082 | <Match path="Avatar/Attachments/Tests" pattern="*.cs" recurse="true"/> | 3082 | <Match path="Avatar/Attachments/Tests" pattern="*.cs" recurse="true"/> |
3083 | <Match path="Avatar/AvatarFactory/Tests" pattern="*.cs" recurse="true"/> | 3083 | <Match path="Avatar/AvatarFactory/Tests" pattern="*.cs" recurse="true"/> |
3084 | <Match path="Avatar/Chat/Tests" pattern="*.cs" recurse="true"/> | ||
3084 | <Match path="Avatar/Friends/Tests" pattern="*.cs" recurse="true"/> | 3085 | <Match path="Avatar/Friends/Tests" pattern="*.cs" recurse="true"/> |
3085 | <Match path="Avatar/Inventory/Archiver/Tests" pattern="*.cs" recurse="true"/> | 3086 | <Match path="Avatar/Inventory/Archiver/Tests" pattern="*.cs" recurse="true"/> |
3086 | <Match path="Avatar/Inventory/Transfer/Tests" pattern="*.cs" recurse="true"/> | 3087 | <Match path="Avatar/Inventory/Transfer/Tests" pattern="*.cs" recurse="true"/> |