aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs184
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs148
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs258
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs387
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs111
5 files changed, 1088 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
new file mode 100644
index 0000000..dae095f
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
@@ -0,0 +1,184 @@
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.Reflection;
30using System.Threading;
31using System.Text;
32using System.Collections.Generic;
33using Nini.Config;
34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Communications;
39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Tests.Common;
41using OpenSim.Tests.Common.Setup;
42
43namespace OpenSim.Region.Framework.Scenes.Tests
44{
45 [TestFixture, LongRunning]
46 public class EntityManagerTests
47 {
48 static public Random random;
49 SceneObjectGroup found;
50 Scene scene = SceneSetupHelpers.SetupScene();
51
52 [Test]
53 public void T010_AddObjects()
54 {
55 TestHelper.InMethod();
56 // Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod());
57
58 random = new Random();
59 SceneObjectGroup found;
60 EntityManager entman = new EntityManager();
61 SceneObjectGroup sog = NewSOG();
62 UUID obj1 = sog.UUID;
63 uint li1 = sog.LocalId;
64 entman.Add(sog);
65 sog = NewSOG();
66 UUID obj2 = sog.UUID;
67 uint li2 = sog.LocalId;
68 entman.Add(sog);
69
70 found = (SceneObjectGroup)entman[obj1];
71 Assert.That(found.UUID ,Is.EqualTo(obj1) );
72 found = (SceneObjectGroup)entman[li1];
73 Assert.That(found.UUID ,Is.EqualTo(obj1) );
74 found = (SceneObjectGroup)entman[obj2];
75 Assert.That(found.UUID ,Is.EqualTo(obj2) );
76 found = (SceneObjectGroup)entman[li2];
77 Assert.That(found.UUID ,Is.EqualTo(obj2) );
78
79 entman.Remove(obj1);
80 entman.Remove(li2);
81
82 Assert.That(entman.ContainsKey(obj1), Is.False);
83 Assert.That(entman.ContainsKey(li1), Is.False);
84 Assert.That(entman.ContainsKey(obj2), Is.False);
85 Assert.That(entman.ContainsKey(li2), Is.False);
86 }
87
88 [Test]
89 public void T011_ThreadAddRemoveTest()
90 {
91 TestHelper.InMethod();
92 // Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod());
93
94 // This test adds and removes with mutiple threads, attempting to break the
95 // uuid and localid dictionary coherence.
96 EntityManager entman = new EntityManager();
97 SceneObjectGroup sog = NewSOG();
98 for (int j=0; j<20; j++)
99 {
100 List<Thread> trdlist = new List<Thread>();
101
102 for (int i=0; i<4; i++)
103 {
104 // Adds scene object
105 NewTestThreads test = new NewTestThreads(entman,sog);
106 Thread start = new Thread(new ThreadStart(test.TestAddSceneObject));
107 start.Start();
108 trdlist.Add(start);
109
110 // Removes it
111 test = new NewTestThreads(entman,sog);
112 start = new Thread(new ThreadStart(test.TestRemoveSceneObject));
113 start.Start();
114 trdlist.Add(start);
115 }
116 foreach (Thread thread in trdlist)
117 {
118 thread.Join();
119 }
120 if (entman.ContainsKey(sog.UUID) || entman.ContainsKey(sog.LocalId)) {
121 found = (SceneObjectGroup)entman[sog.UUID];
122 Assert.That(found.UUID,Is.EqualTo(sog.UUID));
123 found = (SceneObjectGroup)entman[sog.LocalId];
124 Assert.That(found.UUID,Is.EqualTo(sog.UUID));
125 }
126 }
127 }
128
129 private SceneObjectGroup NewSOG()
130 {
131 SceneObjectGroup sog = new SceneObjectGroup();
132 SceneObjectPart sop = new SceneObjectPart(UUID.Random(), PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero);
133 sop.Name = RandomName();
134 sop.Description = sop.Name;
135 sop.Text = RandomName();
136 sop.SitName = RandomName();
137 sop.TouchName = RandomName();
138 sop.ObjectFlags |= (uint)PrimFlags.Phantom;
139
140 sog.SetRootPart(sop);
141
142 scene.AddNewSceneObject(sog, false);
143
144 return sog;
145 }
146
147 private static string RandomName()
148 {
149 StringBuilder name = new StringBuilder();
150 int size = random.Next(40,80);
151 char ch ;
152 for (int i=0; i<size; i++)
153 {
154 ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
155 name.Append(ch);
156 }
157 return name.ToString();
158 }
159 }
160
161 public class NewTestThreads
162 {
163 private EntityManager entman;
164 private SceneObjectGroup sog;
165 private Random random;
166
167 public NewTestThreads(EntityManager entman, SceneObjectGroup sog)
168 {
169 this.entman = entman;
170 this.sog = sog;
171 this.random = new Random();
172 }
173 public void TestAddSceneObject()
174 {
175 Thread.Sleep(random.Next(0,50));
176 entman.Add(sog);
177 }
178 public void TestRemoveSceneObject()
179 {
180 Thread.Sleep(random.Next(0,50));
181 entman.Remove(sog.UUID);
182 }
183 }
184} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
new file mode 100644
index 0000000..105446d
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -0,0 +1,148 @@
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.Reflection;
30using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Region.Communications.Local;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock;
40using OpenSim.Tests.Common.Setup;
41
42namespace OpenSim.Region.Framework.Scenes.Tests
43{
44 /// <summary>
45 /// Basic scene object tests (create, read and delete but not update).
46 /// </summary>
47 [TestFixture]
48 public class SceneObjectBasicTests
49 {
50 /// <summary>
51 /// Test adding an object to a scene.
52 /// </summary>
53 [Test, LongRunning]
54 public void TestAddSceneObject()
55 {
56 TestHelper.InMethod();
57
58 Scene scene = SceneSetupHelpers.SetupScene();
59 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene);
60 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
61
62 //m_log.Debug("retrievedPart : {0}", retrievedPart);
63 // If the parts have the same UUID then we will consider them as one and the same
64 Assert.That(retrievedPart.UUID, Is.EqualTo(part.UUID));
65 }
66
67 /// <summary>
68 /// Test deleting an object from a scene.
69 /// </summary>
70 [Test]
71 public void TestDeleteSceneObject()
72 {
73 TestHelper.InMethod();
74
75 TestScene scene = SceneSetupHelpers.SetupScene();
76 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene);
77 scene.DeleteSceneObject(part.ParentGroup, false);
78
79 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
80 Assert.That(retrievedPart, Is.Null);
81 }
82
83 /// <summary>
84 /// Test deleting an object asynchronously
85 /// </summary>
86 [Test]
87 public void TestDeleteSceneObjectAsync()
88 {
89 TestHelper.InMethod();
90
91 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
92
93 TestScene scene = SceneSetupHelpers.SetupScene();
94
95 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
96 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
97 sogd.Enabled = false;
98
99 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene);
100
101 IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId);
102 scene.DeRezObject(client, part.LocalId, UUID.Zero, DeRezAction.Delete, UUID.Zero);
103
104 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
105 Assert.That(retrievedPart, Is.Not.Null);
106
107 sogd.InventoryDeQueueAndDelete();
108 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId);
109 Assert.That(retrievedPart2, Is.Null);
110 }
111
112 /// <summary>
113 /// Test deleting an object asynchronously to user inventory.
114 /// </summary>
115 //[Test]
116 //public void TestDeleteSceneObjectAsyncToUserInventory()
117 //{
118 // TestHelper.InMethod();
119 // //log4net.Config.XmlConfigurator.Configure();
120
121 // UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
122 // string myObjectName = "Fred";
123
124 // TestScene scene = SceneSetupHelpers.SetupScene();
125 // SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene, myObjectName);
126
127 // Assert.That(
128 // scene.CommsManager.UserAdminService.AddUser(
129 // "Bob", "Hoskins", "test", "test@test.com", 1000, 1000, agentId),
130 // Is.EqualTo(agentId));
131
132 // IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId);
133
134 // CachedUserInfo userInfo = scene.CommsManager.UserProfileCacheService.GetUserDetails(agentId);
135 // Assert.That(userInfo, Is.Not.Null);
136 // Assert.That(userInfo.RootFolder, Is.Not.Null);
137
138 // SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client);
139
140 // // Check that we now have the taken part in our inventory
141 // Assert.That(myObjectName, Is.EqualTo(userInfo.RootFolder.FindItemByPath(myObjectName).Name));
142
143 // // Check that the taken part has actually disappeared
144 // SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
145 // Assert.That(retrievedPart, Is.Null);
146 //}
147 }
148}
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
new file mode 100644
index 0000000..bf13607
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
@@ -0,0 +1,258 @@
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.Reflection;
30using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Region.Communications.Local;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock;
40using OpenSim.Tests.Common.Setup;
41using log4net;
42
43namespace OpenSim.Region.Framework.Scenes.Tests
44{
45 /// <summary>
46 /// Linking tests
47 /// </summary>
48 [TestFixture]
49 public class SceneObjectLinkingTests
50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
53 [Test]
54 public void TestLinkDelink2SceneObjects()
55 {
56 TestHelper.InMethod();
57
58 bool debugtest = false;
59
60 Scene scene = SceneSetupHelpers.SetupScene();
61 SceneObjectPart part1 = SceneSetupHelpers.AddSceneObject(scene);
62 SceneObjectGroup grp1 = part1.ParentGroup;
63 SceneObjectPart part2 = SceneSetupHelpers.AddSceneObject(scene);
64 SceneObjectGroup grp2 = part2.ParentGroup;
65
66 grp1.AbsolutePosition = new Vector3(10, 10, 10);
67 grp2.AbsolutePosition = Vector3.Zero;
68
69 // <90,0,0>
70 grp1.Rotation = (Quaternion.CreateFromEulers(90 * Utils.DEG_TO_RAD, 0, 0));
71
72 // <180,0,0>
73 grp2.UpdateGroupRotation(Quaternion.CreateFromEulers(180 * Utils.DEG_TO_RAD, 0, 0));
74
75 // Required for linking
76 grp1.RootPart.UpdateFlag = 0;
77 grp2.RootPart.UpdateFlag = 0;
78
79 // Link grp2 to grp1. part2 becomes child prim to grp1. grp2 is eliminated.
80 grp1.LinkToGroup(grp2);
81
82 // FIXME: Can't do this test yet since group 2 still has its root part! We can't yet null this since
83 // it might cause SOG.ProcessBackup() to fail due to the race condition. This really needs to be fixed.
84 Assert.That(grp2.IsDeleted, "SOG 2 was not registered as deleted after link.");
85 Assert.That(grp2.Children.Count, Is.EqualTo(0), "Group 2 still contained children after delink.");
86 Assert.That(grp1.Children.Count == 2);
87
88 if (debugtest)
89 {
90 m_log.Debug("parts: " + grp1.Children.Count);
91 m_log.Debug("Group1: Pos:"+grp1.AbsolutePosition+", Rot:"+grp1.Rotation);
92 m_log.Debug("Group1: Prim1: OffsetPosition:"+ part1.OffsetPosition+", OffsetRotation:"+part1.RotationOffset);
93 m_log.Debug("Group1: Prim2: OffsetPosition:"+part2.OffsetPosition+", OffsetRotation:"+part2.RotationOffset);
94 }
95
96 // root part should have no offset position or rotation
97 Assert.That(part1.OffsetPosition == Vector3.Zero && part1.RotationOffset == Quaternion.Identity);
98
99 // offset position should be root part position - part2.absolute position.
100 Assert.That(part2.OffsetPosition == new Vector3(-10, -10, -10));
101
102 float roll = 0;
103 float pitch = 0;
104 float yaw = 0;
105
106 // There's a euler anomoly at 180, 0, 0 so expect 180 to turn into -180.
107 part1.RotationOffset.GetEulerAngles(out roll, out pitch, out yaw);
108 Vector3 rotEuler1 = new Vector3(roll * Utils.RAD_TO_DEG, pitch * Utils.RAD_TO_DEG, yaw * Utils.RAD_TO_DEG);
109
110 if (debugtest)
111 m_log.Debug(rotEuler1);
112
113 part2.RotationOffset.GetEulerAngles(out roll, out pitch, out yaw);
114 Vector3 rotEuler2 = new Vector3(roll * Utils.RAD_TO_DEG, pitch * Utils.RAD_TO_DEG, yaw * Utils.RAD_TO_DEG);
115
116 if (debugtest)
117 m_log.Debug(rotEuler2);
118
119 Assert.That(rotEuler2.ApproxEquals(new Vector3(-180, 0, 0), 0.001f) || rotEuler2.ApproxEquals(new Vector3(180, 0, 0), 0.001f));
120
121 // Delink part 2
122 grp1.DelinkFromGroup(part2.LocalId);
123
124 if (debugtest)
125 m_log.Debug("Group2: Prim2: OffsetPosition:" + part2.AbsolutePosition + ", OffsetRotation:" + part2.RotationOffset);
126
127 Assert.That(grp1.Children.Count, Is.EqualTo(1), "Group 1 still contained part2 after delink.");
128 Assert.That(part2.AbsolutePosition == Vector3.Zero);
129 }
130
131 [Test]
132 public void TestLinkDelink2groups4SceneObjects()
133 {
134 TestHelper.InMethod();
135
136 bool debugtest = false;
137
138 Scene scene = SceneSetupHelpers.SetupScene();
139 SceneObjectPart part1 = SceneSetupHelpers.AddSceneObject(scene);
140 SceneObjectGroup grp1 = part1.ParentGroup;
141 SceneObjectPart part2 = SceneSetupHelpers.AddSceneObject(scene);
142 SceneObjectGroup grp2 = part2.ParentGroup;
143 SceneObjectPart part3 = SceneSetupHelpers.AddSceneObject(scene);
144 SceneObjectGroup grp3 = part3.ParentGroup;
145 SceneObjectPart part4 = SceneSetupHelpers.AddSceneObject(scene);
146 SceneObjectGroup grp4 = part4.ParentGroup;
147
148 grp1.AbsolutePosition = new Vector3(10, 10, 10);
149 grp2.AbsolutePosition = Vector3.Zero;
150 grp3.AbsolutePosition = new Vector3(20, 20, 20);
151 grp4.AbsolutePosition = new Vector3(40, 40, 40);
152
153 // <90,0,0>
154 grp1.Rotation = (Quaternion.CreateFromEulers(90 * Utils.DEG_TO_RAD, 0, 0));
155
156 // <180,0,0>
157 grp2.UpdateGroupRotation(Quaternion.CreateFromEulers(180 * Utils.DEG_TO_RAD, 0, 0));
158
159 // <270,0,0>
160 grp3.Rotation = (Quaternion.CreateFromEulers(270 * Utils.DEG_TO_RAD, 0, 0));
161
162 // <0,90,0>
163 grp4.UpdateGroupRotation(Quaternion.CreateFromEulers(0, 90 * Utils.DEG_TO_RAD, 0));
164
165 // Required for linking
166 grp1.RootPart.UpdateFlag = 0;
167 grp2.RootPart.UpdateFlag = 0;
168 grp3.RootPart.UpdateFlag = 0;
169 grp4.RootPart.UpdateFlag = 0;
170
171 // Link grp2 to grp1. part2 becomes child prim to grp1. grp2 is eliminated.
172 grp1.LinkToGroup(grp2);
173
174 // Link grp4 to grp3.
175 grp3.LinkToGroup(grp4);
176
177 // At this point we should have 4 parts total in two groups.
178 Assert.That(grp1.Children.Count == 2);
179 Assert.That(grp2.IsDeleted, "Group 2 was not registered as deleted after link.");
180 Assert.That(grp2.Children.Count, Is.EqualTo(0), "Group 2 still contained parts after delink.");
181 Assert.That(grp3.Children.Count == 2);
182 Assert.That(grp4.IsDeleted, "Group 4 was not registered as deleted after link.");
183 Assert.That(grp4.Children.Count, Is.EqualTo(0), "Group 4 still contained parts after delink.");
184
185 if (debugtest)
186 {
187 m_log.Debug("--------After Link-------");
188 m_log.Debug("Group1: parts:" + grp1.Children.Count);
189 m_log.Debug("Group1: Pos:"+grp1.AbsolutePosition+", Rot:"+grp1.Rotation);
190 m_log.Debug("Group1: Prim1: OffsetPosition:" + part1.OffsetPosition + ", OffsetRotation:" + part1.RotationOffset);
191 m_log.Debug("Group1: Prim2: OffsetPosition:"+part2.OffsetPosition+", OffsetRotation:"+ part2.RotationOffset);
192
193 m_log.Debug("Group3: parts:"+grp3.Children.Count);
194 m_log.Debug("Group3: Pos:"+grp3.AbsolutePosition+", Rot:"+grp3.Rotation);
195 m_log.Debug("Group3: Prim1: OffsetPosition:"+part3.OffsetPosition+", OffsetRotation:"+part3.RotationOffset);
196 m_log.Debug("Group3: Prim2: OffsetPosition:"+part4.OffsetPosition+", OffsetRotation:"+part4.RotationOffset);
197 }
198
199 // Required for linking
200 grp1.RootPart.UpdateFlag = 0;
201 grp3.RootPart.UpdateFlag = 0;
202
203 // root part should have no offset position or rotation
204 Assert.That(part1.OffsetPosition == Vector3.Zero && part1.RotationOffset == Quaternion.Identity);
205
206 // offset position should be root part position - part2.absolute position.
207 Assert.That(part2.OffsetPosition == new Vector3(-10, -10, -10));
208
209 float roll = 0;
210 float pitch = 0;
211 float yaw = 0;
212
213 // There's a euler anomoly at 180, 0, 0 so expect 180 to turn into -180.
214 part1.RotationOffset.GetEulerAngles(out roll, out pitch, out yaw);
215 Vector3 rotEuler1 = new Vector3(roll * Utils.RAD_TO_DEG, pitch * Utils.RAD_TO_DEG, yaw * Utils.RAD_TO_DEG);
216
217 if (debugtest)
218 m_log.Debug(rotEuler1);
219
220 part2.RotationOffset.GetEulerAngles(out roll, out pitch, out yaw);
221 Vector3 rotEuler2 = new Vector3(roll * Utils.RAD_TO_DEG, pitch * Utils.RAD_TO_DEG, yaw * Utils.RAD_TO_DEG);
222
223 if (debugtest)
224 m_log.Debug(rotEuler2);
225
226 Assert.That(rotEuler2.ApproxEquals(new Vector3(-180, 0, 0), 0.001f) || rotEuler2.ApproxEquals(new Vector3(180, 0, 0), 0.001f));
227
228 // Now we're linking the first group to the third group. This will make the first group child parts of the third one.
229 grp3.LinkToGroup(grp1);
230
231 // Delink parts 2 and 3
232 grp3.DelinkFromGroup(part2.LocalId);
233 grp3.DelinkFromGroup(part3.LocalId);
234
235 if (debugtest)
236 {
237 m_log.Debug("--------After De-Link-------");
238 m_log.Debug("Group1: parts:" + grp1.Children.Count);
239 m_log.Debug("Group1: Pos:" + grp1.AbsolutePosition + ", Rot:" + grp1.Rotation);
240 m_log.Debug("Group1: Prim1: OffsetPosition:" + part1.OffsetPosition + ", OffsetRotation:" + part1.RotationOffset);
241 m_log.Debug("Group1: Prim2: OffsetPosition:" + part2.OffsetPosition + ", OffsetRotation:" + part2.RotationOffset);
242
243 m_log.Debug("Group3: parts:" + grp3.Children.Count);
244 m_log.Debug("Group3: Pos:" + grp3.AbsolutePosition + ", Rot:" + grp3.Rotation);
245 m_log.Debug("Group3: Prim1: OffsetPosition:" + part3.OffsetPosition + ", OffsetRotation:" + part3.RotationOffset);
246 m_log.Debug("Group3: Prim2: OffsetPosition:" + part4.OffsetPosition + ", OffsetRotation:" + part4.RotationOffset);
247 }
248
249 Assert.That(part2.AbsolutePosition == Vector3.Zero);
250 Assert.That(part4.OffsetPosition == new Vector3(20, 20, 20));
251 Quaternion compareQuaternion = new Quaternion(0, 0.7071068f, 0, 0.7071068f);
252 Assert.That((part4.RotationOffset.X - compareQuaternion.X < 0.00003)
253 && (part4.RotationOffset.Y - compareQuaternion.Y < 0.00003)
254 && (part4.RotationOffset.Z - compareQuaternion.Z < 0.00003)
255 && (part4.RotationOffset.W - compareQuaternion.W < 0.00003));
256 }
257 }
258}
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
new file mode 100644
index 0000000..5b828c5
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
@@ -0,0 +1,387 @@
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 System.Reflection;
31using System.Text;
32using System.Threading;
33using System.Timers;
34using Timer=System.Timers.Timer;
35using Nini.Config;
36using NUnit.Framework;
37using NUnit.Framework.SyntaxHelpers;
38using OpenMetaverse;
39using OpenSim.Framework;
40using OpenSim.Framework.Communications;
41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.CoreModules.ServiceConnectors.Interregion;
44using OpenSim.Region.CoreModules.World.Serialiser;
45using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock;
47using OpenSim.Tests.Common.Setup;
48
49namespace OpenSim.Region.Framework.Scenes.Tests
50{
51 /// <summary>
52 /// Scene presence tests
53 /// </summary>
54 [TestFixture]
55 public class ScenePresenceTests
56 {
57 public Scene scene, scene2, scene3;
58 public UUID agent1, agent2, agent3;
59 public static Random random;
60 public ulong region1,region2,region3;
61 public TestCommunicationsManager cm;
62 public AgentCircuitData acd1;
63 public SceneObjectGroup sog1, sog2, sog3;
64 public TestClient testclient;
65
66 [TestFixtureSetUp]
67 public void Init()
68 {
69 cm = new TestCommunicationsManager();
70 scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000, cm);
71 scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000, cm);
72 scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000, cm);
73
74 IRegionModule interregionComms = new RESTInterregionComms();
75 interregionComms.Initialise(scene, new IniConfigSource());
76 interregionComms.Initialise(scene2, new IniConfigSource());
77 interregionComms.Initialise(scene3, new IniConfigSource());
78 interregionComms.PostInitialise();
79 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
80 SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms);
81 SceneSetupHelpers.SetupSceneModules(scene3, new IniConfigSource(), interregionComms);
82
83 agent1 = UUID.Random();
84 agent2 = UUID.Random();
85 agent3 = UUID.Random();
86 random = new Random();
87 sog1 = NewSOG(UUID.Random(), scene, agent1);
88 sog2 = NewSOG(UUID.Random(), scene, agent1);
89 sog3 = NewSOG(UUID.Random(), scene, agent1);
90
91 //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
92 region1 = scene.RegionInfo.RegionHandle;
93 region2 = scene2.RegionInfo.RegionHandle;
94 region3 = scene3.RegionInfo.RegionHandle;
95 }
96
97 /// <summary>
98 /// Test adding a root agent to a scene. Doesn't yet actually complete crossing the agent into the scene.
99 /// </summary>
100 [Test]
101 public void T010_TestAddRootAgent()
102 {
103 TestHelper.InMethod();
104
105 string firstName = "testfirstname";
106
107 AgentCircuitData agent = new AgentCircuitData();
108 agent.AgentID = agent1;
109 agent.firstname = firstName;
110 agent.lastname = "testlastname";
111 agent.SessionID = UUID.Zero;
112 agent.SecureSessionID = UUID.Zero;
113 agent.circuitcode = 123;
114 agent.BaseFolder = UUID.Zero;
115 agent.InventoryFolder = UUID.Zero;
116 agent.startpos = Vector3.Zero;
117 agent.CapsPath = GetRandomCapsObjectPath();
118
119 string reason;
120 scene.NewUserConnection(agent, out reason);
121 testclient = new TestClient(agent, scene);
122 scene.AddNewClient(testclient);
123
124 ScenePresence presence = scene.GetScenePresence(agent1);
125
126 Assert.That(presence, Is.Not.Null, "presence is null");
127 Assert.That(presence.Firstname, Is.EqualTo(firstName), "First name not same");
128 acd1 = agent;
129 }
130
131 /// <summary>
132 /// Test removing an uncrossed root agent from a scene.
133 /// </summary>
134 [Test]
135 public void T011_TestRemoveRootAgent()
136 {
137 TestHelper.InMethod();
138
139 scene.RemoveClient(agent1);
140
141 ScenePresence presence = scene.GetScenePresence(agent1);
142
143 Assert.That(presence, Is.Null, "presence is not null");
144 }
145
146 [Test]
147 public void T012_TestAddNeighbourRegion()
148 {
149 TestHelper.InMethod();
150
151 string reason;
152 scene.NewUserConnection(acd1, out reason);
153 scene.AddNewClient(testclient);
154
155 ScenePresence presence = scene.GetScenePresence(agent1);
156 presence.MakeRootAgent(new Vector3(90,90,90),false);
157
158 string cap = presence.ControllingClient.RequestClientInfo().CapsPath;
159
160 presence.AddNeighbourRegion(region2, cap);
161 presence.AddNeighbourRegion(region3, cap);
162
163 List<ulong> neighbours = presence.GetKnownRegionList();
164
165 Assert.That(neighbours.Count, Is.EqualTo(2));
166 }
167
168 [Test]
169 public void T013_TestRemoveNeighbourRegion()
170 {
171 TestHelper.InMethod();
172
173 ScenePresence presence = scene.GetScenePresence(agent1);
174 presence.RemoveNeighbourRegion(region3);
175
176 List<ulong> neighbours = presence.GetKnownRegionList();
177 Assert.That(neighbours.Count,Is.EqualTo(1));
178 /*
179 presence.MakeChildAgent;
180 presence.MakeRootAgent;
181 CompleteAvatarMovement
182 */
183 }
184
185 [Test]
186 public void T020_TestMakeRootAgent()
187 {
188 TestHelper.InMethod();
189
190 ScenePresence presence = scene.GetScenePresence(agent1);
191 Assert.That(presence.IsChildAgent, Is.False, "Starts out as a root agent");
192
193 presence.MakeChildAgent();
194 Assert.That(presence.IsChildAgent, Is.True, "Did not change to child agent after MakeChildAgent");
195
196 // Accepts 0 but rejects Constants.RegionSize
197 Vector3 pos = new Vector3(0,Constants.RegionSize-1,0);
198 presence.MakeRootAgent(pos,true);
199 Assert.That(presence.IsChildAgent, Is.False, "Did not go back to root agent");
200 Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered");
201 }
202
203 [Test]
204 public void T021_TestCrossToNewRegion()
205 {
206 TestHelper.InMethod();
207
208 // Adding child agent to region 1001
209 string reason;
210 scene2.NewUserConnection(acd1, out reason);
211 scene2.AddNewClient(testclient);
212
213 ScenePresence presence = scene.GetScenePresence(agent1);
214 ScenePresence presence2 = scene2.GetScenePresence(agent1);
215
216 // Adding neighbour region caps info to presence2
217 string cap = presence.ControllingClient.RequestClientInfo().CapsPath;
218 presence2.AddNeighbourRegion(region1, cap);
219
220 scene.RegisterRegionWithGrid();
221 scene2.RegisterRegionWithGrid();
222
223 Assert.That(presence.IsChildAgent, Is.False, "Did not start root in origin region.");
224 Assert.That(presence2.IsChildAgent, Is.True, "Is not a child on destination region.");
225
226 // Cross to x+1
227 presence.AbsolutePosition = new Vector3(Constants.RegionSize+1,3,100);
228 presence.Update();
229
230 EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing");
231
232 // Mimicking communication between client and server, by waiting OK from client
233 // sent by TestClient.CrossRegion call. Originally, this is network comm.
234 if (!wh.WaitOne(5000,false))
235 {
236 presence.Update();
237 if (!wh.WaitOne(8000,false))
238 throw new ArgumentException("1 - Timeout waiting for signal/variable.");
239 }
240
241 // This is a TestClient specific method that fires OnCompleteMovementToRegion event, which
242 // would normally be fired after receiving the reply packet from comm. done on the last line.
243 testclient.CompleteMovement();
244
245 // Crossings are asynchronous
246 int timer = 10;
247
248 // Make sure cross hasn't already finished
249 if (!presence.IsInTransit && !presence.IsChildAgent)
250 {
251 // If not and not in transit yet, give it some more time
252 Thread.Sleep(5000);
253 }
254
255 // Enough time, should at least be in transit by now.
256 while (presence.IsInTransit && timer > 0)
257 {
258 Thread.Sleep(1000);
259 timer-=1;
260 }
261
262 Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 2->1.");
263 Assert.That(presence.IsChildAgent, Is.True, "Did not complete region cross as expected.");
264 Assert.That(presence2.IsChildAgent, Is.False, "Did not receive root status after receiving agent.");
265
266 // Cross Back
267 presence2.AbsolutePosition = new Vector3(-10, 3, 100);
268 presence2.Update();
269
270 if (!wh.WaitOne(5000,false))
271 {
272 presence2.Update();
273 if (!wh.WaitOne(8000,false))
274 throw new ArgumentException("2 - Timeout waiting for signal/variable.");
275 }
276 testclient.CompleteMovement();
277
278 if (!presence2.IsInTransit && !presence2.IsChildAgent)
279 {
280 // If not and not in transit yet, give it some more time
281 Thread.Sleep(5000);
282 }
283
284 // Enough time, should at least be in transit by now.
285 while (presence2.IsInTransit && timer > 0)
286 {
287 Thread.Sleep(1000);
288 timer-=1;
289 }
290
291 Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 1->2.");
292 Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected.");
293 Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again.");
294 }
295
296 [Test]
297 public void T030_TestAddAttachments()
298 {
299 TestHelper.InMethod();
300
301 ScenePresence presence = scene.GetScenePresence(agent1);
302
303 presence.AddAttachment(sog1);
304 presence.AddAttachment(sog2);
305 presence.AddAttachment(sog3);
306
307 Assert.That(presence.HasAttachments(), Is.True);
308 Assert.That(presence.ValidateAttachments(), Is.True);
309 }
310
311 [Test]
312 public void T031_RemoveAttachments()
313 {
314 TestHelper.InMethod();
315
316 ScenePresence presence = scene.GetScenePresence(agent1);
317 presence.RemoveAttachment(sog1);
318 presence.RemoveAttachment(sog2);
319 presence.RemoveAttachment(sog3);
320 Assert.That(presence.HasAttachments(), Is.False);
321 }
322
323 [Test]
324 public void T032_CrossAttachments()
325 {
326 TestHelper.InMethod();
327
328 ScenePresence presence = scene.GetScenePresence(agent1);
329 ScenePresence presence2 = scene2.GetScenePresence(agent1);
330 presence2.AddAttachment(sog1);
331 presence2.AddAttachment(sog2);
332
333 IRegionModule serialiser = new SerialiserModule();
334 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser);
335 SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser);
336
337 Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross");
338
339 Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful");
340 Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted");
341 Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects");
342 }
343
344 public static string GetRandomCapsObjectPath()
345 {
346 TestHelper.InMethod();
347
348 UUID caps = UUID.Random();
349 string capsPath = caps.ToString();
350 capsPath = capsPath.Remove(capsPath.Length - 4, 4);
351 return capsPath;
352 }
353
354 private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent)
355 {
356 SceneObjectPart sop = new SceneObjectPart();
357 sop.Name = RandomName();
358 sop.Description = RandomName();
359 sop.Text = RandomName();
360 sop.SitName = RandomName();
361 sop.TouchName = RandomName();
362 sop.UUID = uuid;
363 sop.Shape = PrimitiveBaseShape.Default;
364 sop.Shape.State = 1;
365 sop.OwnerID = agent;
366
367 SceneObjectGroup sog = new SceneObjectGroup();
368 sog.SetScene(scene);
369 sog.SetRootPart(sop);
370
371 return sog;
372 }
373
374 private static string RandomName()
375 {
376 StringBuilder name = new StringBuilder();
377 int size = random.Next(5,12);
378 char ch ;
379 for (int i=0; i<size; i++)
380 {
381 ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
382 name.Append(ch);
383 }
384 return name.ToString();
385 }
386 }
387}
diff --git a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
new file mode 100644
index 0000000..2d286af
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
@@ -0,0 +1,111 @@
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.Reflection;
30using Nini.Config;
31using NUnit.Framework;
32using NUnit.Framework.SyntaxHelpers;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.CoreModules.ServiceConnectors.Interregion;
38using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock;
40using OpenSim.Tests.Common.Setup;
41
42namespace OpenSim.Region.Framework.Scenes.Tests
43{
44 /// <summary>
45 /// Teleport tests in a standalone OpenSim
46 /// </summary>
47 [TestFixture]
48 public class StandaloneTeleportTests
49 {
50 /// <summary>
51 /// Test a teleport between two regions that are not neighbours and do not share any neighbours in common.
52 /// </summary>
53 /// Does not yet do what is says on the tin.
54 [Test, LongRunning]
55 public void TestSimpleNotNeighboursTeleport()
56 {
57 TestHelper.InMethod();
58
59 // Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod());
60
61 log4net.Config.XmlConfigurator.Configure();
62
63 UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100");
64 UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200");
65 TestCommunicationsManager cm = new TestCommunicationsManager();
66
67 // shared module
68 IRegionModule interregionComms = new RESTInterregionComms();
69
70 Scene sceneA = SceneSetupHelpers.SetupScene("sceneA", sceneAId, 1000, 1000, cm);
71 SceneSetupHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms);
72 sceneA.RegisterRegionWithGrid();
73
74 Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010, cm);
75 SceneSetupHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms);
76 sceneB.RegisterRegionWithGrid();
77
78 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000041");
79 TestClient client = SceneSetupHelpers.AddRootAgent(sceneA, agentId);
80
81 ICapabilitiesModule sceneACapsModule = sceneA.RequestModuleInterface<ICapabilitiesModule>();
82
83 Assert.That(
84 sceneACapsModule.GetCapsPath(agentId),
85 Is.EqualTo(client.CapsSeedUrl),
86 "Incorrect caps object path set up in sceneA");
87
88 // FIXME: This is a hack to get the test working - really the normal OpenSim mechanisms should be used.
89 client.TeleportTargetScene = sceneB;
90 client.Teleport(sceneB.RegionInfo.RegionHandle, new Vector3(100, 100, 100), new Vector3(40, 40, 40));
91
92 Assert.That(sceneB.GetScenePresence(agentId), Is.Not.Null, "Client does not have an agent in sceneB");
93 Assert.That(sceneA.GetScenePresence(agentId), Is.Null, "Client still had an agent in sceneA");
94
95 ICapabilitiesModule sceneBCapsModule = sceneB.RequestModuleInterface<ICapabilitiesModule>();
96
97 // Temporary assertion - caps url construction should at least be doable through a method.
98 Assert.That(
99 "http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort + "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/",
100 Is.EqualTo(client.CapsSeedUrl),
101 "Incorrect caps object path set up in sceneB");
102
103 // This assertion will currently fail since we don't remove the caps paths when no longer needed
104 //Assert.That(sceneACapsModule.GetCapsPath(agentId), Is.Null, "sceneA still had a caps object path");
105
106 // TODO: Check that more of everything is as it should be
107
108 // TODO: test what happens if we try to teleport to a region that doesn't exist
109 }
110 }
111}