diff options
author | Dr Scofield | 2009-02-06 16:55:34 +0000 |
---|---|---|
committer | Dr Scofield | 2009-02-06 16:55:34 +0000 |
commit | 9b66108081a8c8cf79faaa6c541554091c40850e (patch) | |
tree | 095a232ae5a9de3a9244bcd34da08294f61eeea5 /OpenSim/Region/Environment/Scenes/Tests | |
parent | * removed superfluous constants class (diff) | |
download | opensim-SC_OLD-9b66108081a8c8cf79faaa6c541554091c40850e.zip opensim-SC_OLD-9b66108081a8c8cf79faaa6c541554091c40850e.tar.gz opensim-SC_OLD-9b66108081a8c8cf79faaa6c541554091c40850e.tar.bz2 opensim-SC_OLD-9b66108081a8c8cf79faaa6c541554091c40850e.tar.xz |
This changeset is the step 1 of 2 in refactoring
OpenSim.Region.Environment into a "framework" part and a modules only
part. This first changeset refactors OpenSim.Region.Environment.Scenes,
OpenSim.Region.Environment.Interfaces, and OpenSim.Region.Interfaces
into OpenSim.Region.Framework.{Interfaces,Scenes} leaving only region
modules in OpenSim.Region.Environment.
The next step will be to move region modules up from
OpenSim.Region.Environment.Modules to OpenSim.Region.CoreModules and
then sort out which modules are really core modules and which should
move out to forge.
I've been very careful to NOT BREAK anything. i hope i've
succeeded. as this is the work of a whole week i hope i managed to
keep track with the applied patches of the last week --- could any of
you that did check in stuff have a look at whether it survived? thx!
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Tests')
5 files changed, 0 insertions, 961 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Environment/Scenes/Tests/EntityManagerTests.cs deleted file mode 100644 index 0155966..0000000 --- a/OpenSim/Region/Environment/Scenes/Tests/EntityManagerTests.cs +++ /dev/null | |||
@@ -1,176 +0,0 @@ | |||
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 OpenSim 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.Threading; | ||
30 | using System.Text; | ||
31 | using System.Collections.Generic; | ||
32 | using Nini.Config; | ||
33 | using NUnit.Framework; | ||
34 | using NUnit.Framework.SyntaxHelpers; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Communications; | ||
38 | using OpenSim.Region.Environment.Scenes; | ||
39 | using OpenSim.Tests.Common.Setup; | ||
40 | |||
41 | namespace OpenSim.Region.Environment.Scenes.Tests | ||
42 | { | ||
43 | [TestFixture] | ||
44 | public class EntityManagerTests | ||
45 | { | ||
46 | static public Random random; | ||
47 | SceneObjectGroup found; | ||
48 | Scene scene = SceneSetupHelpers.SetupScene(); | ||
49 | |||
50 | [Test] | ||
51 | public void T010_AddObjects() | ||
52 | { | ||
53 | random = new Random(); | ||
54 | SceneObjectGroup found; | ||
55 | EntityManager entman = new EntityManager(); | ||
56 | SceneObjectGroup sog = NewSOG(); | ||
57 | UUID obj1 = sog.UUID; | ||
58 | uint li1 = sog.LocalId; | ||
59 | entman.Add(sog); | ||
60 | sog = NewSOG(); | ||
61 | UUID obj2 = sog.UUID; | ||
62 | uint li2 = sog.LocalId; | ||
63 | entman.Add(sog); | ||
64 | |||
65 | found = (SceneObjectGroup)entman[obj1]; | ||
66 | Assert.That(found.UUID ,Is.EqualTo(obj1) ); | ||
67 | found = (SceneObjectGroup)entman[li1]; | ||
68 | Assert.That(found.UUID ,Is.EqualTo(obj1) ); | ||
69 | found = (SceneObjectGroup)entman[obj2]; | ||
70 | Assert.That(found.UUID ,Is.EqualTo(obj2) ); | ||
71 | found = (SceneObjectGroup)entman[li2]; | ||
72 | Assert.That(found.UUID ,Is.EqualTo(obj2) ); | ||
73 | |||
74 | entman.Remove(obj1); | ||
75 | entman.Remove(li2); | ||
76 | |||
77 | Assert.That(entman.ContainsKey(obj1), Is.False); | ||
78 | Assert.That(entman.ContainsKey(li1), Is.False); | ||
79 | Assert.That(entman.ContainsKey(obj2), Is.False); | ||
80 | Assert.That(entman.ContainsKey(li2), Is.False); | ||
81 | } | ||
82 | |||
83 | [Test] | ||
84 | public void T011_ThreadAddRemoveTest() | ||
85 | { | ||
86 | // This test adds and removes with mutiple threads, attempting to break the | ||
87 | // uuid and localid dictionary coherence. | ||
88 | EntityManager entman = new EntityManager(); | ||
89 | SceneObjectGroup sog = NewSOG(); | ||
90 | for (int j=0; j<20; j++) | ||
91 | { | ||
92 | List<Thread> trdlist = new List<Thread>(); | ||
93 | |||
94 | for (int i=0; i<4; i++) | ||
95 | { | ||
96 | // Adds scene object | ||
97 | NewTestThreads test = new NewTestThreads(entman,sog); | ||
98 | Thread start = new Thread(new ThreadStart(test.TestAddSceneObject)); | ||
99 | start.Start(); | ||
100 | trdlist.Add(start); | ||
101 | |||
102 | // Removes it | ||
103 | test = new NewTestThreads(entman,sog); | ||
104 | start = new Thread(new ThreadStart(test.TestRemoveSceneObject)); | ||
105 | start.Start(); | ||
106 | trdlist.Add(start); | ||
107 | } | ||
108 | foreach (Thread thread in trdlist) | ||
109 | { | ||
110 | thread.Join(); | ||
111 | } | ||
112 | if (entman.ContainsKey(sog.UUID) || entman.ContainsKey(sog.LocalId)) { | ||
113 | found = (SceneObjectGroup)entman[sog.UUID]; | ||
114 | Assert.That(found.UUID,Is.EqualTo(sog.UUID)); | ||
115 | found = (SceneObjectGroup)entman[sog.LocalId]; | ||
116 | Assert.That(found.UUID,Is.EqualTo(sog.UUID)); | ||
117 | } | ||
118 | } | ||
119 | } | ||
120 | |||
121 | private SceneObjectGroup NewSOG() | ||
122 | { | ||
123 | SceneObjectGroup sog = new SceneObjectGroup(); | ||
124 | SceneObjectPart sop = new SceneObjectPart(UUID.Random(), PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero); | ||
125 | sop.Name = RandomName(); | ||
126 | sop.Description = sop.Name; | ||
127 | sop.Text = RandomName(); | ||
128 | sop.SitName = RandomName(); | ||
129 | sop.TouchName = RandomName(); | ||
130 | sop.ObjectFlags |= (uint)PrimFlags.Phantom; | ||
131 | |||
132 | sog.SetRootPart(sop); | ||
133 | |||
134 | scene.AddNewSceneObject(sog, false); | ||
135 | |||
136 | return sog; | ||
137 | } | ||
138 | |||
139 | private static string RandomName() | ||
140 | { | ||
141 | StringBuilder name = new StringBuilder(); | ||
142 | int size = random.Next(40,80); | ||
143 | char ch ; | ||
144 | for (int i=0; i<size; i++) | ||
145 | { | ||
146 | ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ; | ||
147 | name.Append(ch); | ||
148 | } | ||
149 | return name.ToString(); | ||
150 | } | ||
151 | } | ||
152 | |||
153 | public class NewTestThreads | ||
154 | { | ||
155 | private EntityManager entman; | ||
156 | private SceneObjectGroup sog; | ||
157 | private Random random; | ||
158 | |||
159 | public NewTestThreads(EntityManager entman, SceneObjectGroup sog) | ||
160 | { | ||
161 | this.entman = entman; | ||
162 | this.sog = sog; | ||
163 | this.random = new Random(); | ||
164 | } | ||
165 | public void TestAddSceneObject() | ||
166 | { | ||
167 | Thread.Sleep(random.Next(0,50)); | ||
168 | entman.Add(sog); | ||
169 | } | ||
170 | public void TestRemoveSceneObject() | ||
171 | { | ||
172 | Thread.Sleep(random.Next(0,50)); | ||
173 | entman.Remove(sog.UUID); | ||
174 | } | ||
175 | } | ||
176 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Environment/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Environment/Scenes/Tests/SceneObjectBasicTests.cs deleted file mode 100644 index d063eae..0000000 --- a/OpenSim/Region/Environment/Scenes/Tests/SceneObjectBasicTests.cs +++ /dev/null | |||
@@ -1,139 +0,0 @@ | |||
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 OpenSim 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 NUnit.Framework; | ||
30 | using NUnit.Framework.SyntaxHelpers; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Framework.Communications; | ||
34 | using OpenSim.Framework.Communications.Cache; | ||
35 | using OpenSim.Region.Communications.Local; | ||
36 | using OpenSim.Region.Environment.Scenes; | ||
37 | using OpenSim.Tests.Common.Mock; | ||
38 | using OpenSim.Tests.Common.Setup; | ||
39 | |||
40 | namespace OpenSim.Region.Environment.Scenes.Tests | ||
41 | { | ||
42 | /// <summary> | ||
43 | /// Basic scene object tests (create, read and delete but not update). | ||
44 | /// </summary> | ||
45 | [TestFixture] | ||
46 | public class SceneObjectTests | ||
47 | { | ||
48 | /// <summary> | ||
49 | /// Test adding an object to a scene. | ||
50 | /// </summary> | ||
51 | [Test] | ||
52 | public void TestAddSceneObject() | ||
53 | { | ||
54 | Scene scene = SceneSetupHelpers.SetupScene(); | ||
55 | SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); | ||
56 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | ||
57 | |||
58 | //System.Console.WriteLine("retrievedPart : {0}", retrievedPart); | ||
59 | // If the parts have the same UUID then we will consider them as one and the same | ||
60 | Assert.That(retrievedPart.UUID, Is.EqualTo(part.UUID)); | ||
61 | } | ||
62 | |||
63 | /// <summary> | ||
64 | /// Test deleting an object from a scene. | ||
65 | /// </summary> | ||
66 | [Test] | ||
67 | public void TestDeleteSceneObject() | ||
68 | { | ||
69 | TestScene scene = SceneSetupHelpers.SetupScene(); | ||
70 | SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); | ||
71 | scene.DeleteSceneObject(part.ParentGroup, false); | ||
72 | |||
73 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | ||
74 | Assert.That(retrievedPart, Is.Null); | ||
75 | } | ||
76 | |||
77 | /// <summary> | ||
78 | /// Test deleting an object asynchronously | ||
79 | /// </summary> | ||
80 | [Test] | ||
81 | public void TestDeleteSceneObjectAsync() | ||
82 | { | ||
83 | UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); | ||
84 | |||
85 | TestScene scene = SceneSetupHelpers.SetupScene(); | ||
86 | |||
87 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | ||
88 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | ||
89 | sogd.Enabled = false; | ||
90 | |||
91 | SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); | ||
92 | |||
93 | IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId); | ||
94 | scene.DeRezObject(client, part.LocalId, UUID.Zero, DeRezAction.Delete, UUID.Zero); | ||
95 | |||
96 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | ||
97 | Assert.That(retrievedPart, Is.Not.Null); | ||
98 | |||
99 | sogd.InventoryDeQueueAndDelete(); | ||
100 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); | ||
101 | Assert.That(retrievedPart2, Is.Null); | ||
102 | } | ||
103 | |||
104 | /// <summary> | ||
105 | /// Test deleting an object asynchronously to user inventory. | ||
106 | /// </summary> | ||
107 | [Test] | ||
108 | public void TestDeleteSceneObjectAsyncToUserInventory() | ||
109 | { | ||
110 | //log4net.Config.XmlConfigurator.Configure(); | ||
111 | |||
112 | UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); | ||
113 | string myObjectName = "Fred"; | ||
114 | |||
115 | TestScene scene = SceneSetupHelpers.SetupScene(); | ||
116 | SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene, myObjectName); | ||
117 | |||
118 | Assert.That( | ||
119 | scene.CommsManager.UserAdminService.AddUser( | ||
120 | "Bob", "Hoskins", "test", "test@test.com", 1000, 1000, agentId), | ||
121 | Is.EqualTo(agentId)); | ||
122 | |||
123 | IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId); | ||
124 | |||
125 | CachedUserInfo userInfo = scene.CommsManager.UserProfileCacheService.GetUserDetails(agentId); | ||
126 | Assert.That(userInfo, Is.Not.Null); | ||
127 | Assert.That(userInfo.RootFolder, Is.Not.Null); | ||
128 | |||
129 | SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client); | ||
130 | |||
131 | // Check that we now have the taken part in our inventory | ||
132 | Assert.That(myObjectName, Is.EqualTo(userInfo.RootFolder.FindItemByPath(myObjectName).Name)); | ||
133 | |||
134 | // Check that the taken part has actually disappeared | ||
135 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | ||
136 | Assert.That(retrievedPart, Is.Null); | ||
137 | } | ||
138 | } | ||
139 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Environment/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Environment/Scenes/Tests/SceneObjectLinkingTests.cs deleted file mode 100644 index 30b0987..0000000 --- a/OpenSim/Region/Environment/Scenes/Tests/SceneObjectLinkingTests.cs +++ /dev/null | |||
@@ -1,249 +0,0 @@ | |||
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 OpenSim 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 NUnit.Framework; | ||
30 | using NUnit.Framework.SyntaxHelpers; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Framework.Communications; | ||
34 | using OpenSim.Framework.Communications.Cache; | ||
35 | using OpenSim.Region.Communications.Local; | ||
36 | using OpenSim.Region.Environment.Scenes; | ||
37 | using OpenSim.Tests.Common.Mock; | ||
38 | using OpenSim.Tests.Common.Setup; | ||
39 | |||
40 | namespace OpenSim.Region.Environment.Scenes.Tests | ||
41 | { | ||
42 | /// <summary> | ||
43 | /// Linking tests | ||
44 | /// </summary> | ||
45 | [TestFixture] | ||
46 | public class SceneObjectLinkingTests | ||
47 | { | ||
48 | [Test] | ||
49 | public void TestLinkDelink2SceneObjects() | ||
50 | { | ||
51 | bool debugtest = false; | ||
52 | |||
53 | Scene scene = SceneSetupHelpers.SetupScene(); | ||
54 | SceneObjectPart part1 = SceneSetupHelpers.AddSceneObject(scene); | ||
55 | SceneObjectGroup grp1 = part1.ParentGroup; | ||
56 | SceneObjectPart part2 = SceneSetupHelpers.AddSceneObject(scene); | ||
57 | SceneObjectGroup grp2 = part2.ParentGroup; | ||
58 | |||
59 | grp1.AbsolutePosition = new Vector3(10, 10, 10); | ||
60 | grp2.AbsolutePosition = Vector3.Zero; | ||
61 | |||
62 | // <90,0,0> | ||
63 | grp1.Rotation = (Quaternion.CreateFromEulers(90 * Utils.DEG_TO_RAD, 0, 0)); | ||
64 | |||
65 | // <180,0,0> | ||
66 | grp2.UpdateGroupRotation(Quaternion.CreateFromEulers(180 * Utils.DEG_TO_RAD, 0, 0)); | ||
67 | |||
68 | // Required for linking | ||
69 | grp1.RootPart.UpdateFlag = 0; | ||
70 | grp2.RootPart.UpdateFlag = 0; | ||
71 | |||
72 | // Link grp2 to grp1. part2 becomes child prim to grp1. grp2 is eliminated. | ||
73 | grp1.LinkToGroup(grp2); | ||
74 | |||
75 | // FIXME: Can't do this test yet since group 2 still has its root part! We can't yet null this since | ||
76 | // it might cause SOG.ProcessBackup() to fail due to the race condition. This really needs to be fixed. | ||
77 | Assert.That(grp2.IsDeleted, "SOG 2 was not registered as deleted after link."); | ||
78 | Assert.That(grp2.Children.Count, Is.EqualTo(0), "Group 2 still contained children after delink."); | ||
79 | Assert.That(grp1.Children.Count == 2); | ||
80 | |||
81 | if (debugtest) | ||
82 | { | ||
83 | System.Console.WriteLine("parts: {0}", grp1.Children.Count); | ||
84 | System.Console.WriteLine("Group1: Pos:{0}, Rot:{1}", grp1.AbsolutePosition, grp1.Rotation); | ||
85 | System.Console.WriteLine("Group1: Prim1: OffsetPosition:{0}, OffsetRotation:{1}", part1.OffsetPosition, part1.RotationOffset); | ||
86 | System.Console.WriteLine("Group1: Prim2: OffsetPosition:{0}, OffsetRotation:{1}", part2.OffsetPosition, part2.RotationOffset); | ||
87 | } | ||
88 | |||
89 | // root part should have no offset position or rotation | ||
90 | Assert.That(part1.OffsetPosition == Vector3.Zero && part1.RotationOffset == Quaternion.Identity); | ||
91 | |||
92 | // offset position should be root part position - part2.absolute position. | ||
93 | Assert.That(part2.OffsetPosition == new Vector3(-10, -10, -10)); | ||
94 | |||
95 | float roll = 0; | ||
96 | float pitch = 0; | ||
97 | float yaw = 0; | ||
98 | |||
99 | // There's a euler anomoly at 180, 0, 0 so expect 180 to turn into -180. | ||
100 | part1.RotationOffset.GetEulerAngles(out roll, out pitch, out yaw); | ||
101 | Vector3 rotEuler1 = new Vector3(roll * Utils.RAD_TO_DEG, pitch * Utils.RAD_TO_DEG, yaw * Utils.RAD_TO_DEG); | ||
102 | |||
103 | if (debugtest) | ||
104 | System.Console.WriteLine(rotEuler1); | ||
105 | |||
106 | part2.RotationOffset.GetEulerAngles(out roll, out pitch, out yaw); | ||
107 | Vector3 rotEuler2 = new Vector3(roll * Utils.RAD_TO_DEG, pitch * Utils.RAD_TO_DEG, yaw * Utils.RAD_TO_DEG); | ||
108 | |||
109 | if (debugtest) | ||
110 | System.Console.WriteLine(rotEuler2); | ||
111 | |||
112 | Assert.That(rotEuler2.ApproxEquals(new Vector3(-180, 0, 0), 0.001f) || rotEuler2.ApproxEquals(new Vector3(180, 0, 0), 0.001f)); | ||
113 | |||
114 | // Delink part 2 | ||
115 | grp1.DelinkFromGroup(part2.LocalId); | ||
116 | |||
117 | if (debugtest) | ||
118 | System.Console.WriteLine("Group2: Prim2: OffsetPosition:{0}, OffsetRotation:{1}", part2.AbsolutePosition, part2.RotationOffset); | ||
119 | |||
120 | Assert.That(grp1.Children.Count, Is.EqualTo(1), "Group 1 still contained part2 after delink."); | ||
121 | Assert.That(part2.AbsolutePosition == Vector3.Zero); | ||
122 | } | ||
123 | |||
124 | [Test] | ||
125 | public void TestLinkDelink2groups4SceneObjects() | ||
126 | { | ||
127 | bool debugtest = false; | ||
128 | |||
129 | Scene scene = SceneSetupHelpers.SetupScene(); | ||
130 | SceneObjectPart part1 = SceneSetupHelpers.AddSceneObject(scene); | ||
131 | SceneObjectGroup grp1 = part1.ParentGroup; | ||
132 | SceneObjectPart part2 = SceneSetupHelpers.AddSceneObject(scene); | ||
133 | SceneObjectGroup grp2 = part2.ParentGroup; | ||
134 | SceneObjectPart part3 = SceneSetupHelpers.AddSceneObject(scene); | ||
135 | SceneObjectGroup grp3 = part3.ParentGroup; | ||
136 | SceneObjectPart part4 = SceneSetupHelpers.AddSceneObject(scene); | ||
137 | SceneObjectGroup grp4 = part4.ParentGroup; | ||
138 | |||
139 | grp1.AbsolutePosition = new Vector3(10, 10, 10); | ||
140 | grp2.AbsolutePosition = Vector3.Zero; | ||
141 | grp3.AbsolutePosition = new Vector3(20, 20, 20); | ||
142 | grp4.AbsolutePosition = new Vector3(40, 40, 40); | ||
143 | |||
144 | // <90,0,0> | ||
145 | grp1.Rotation = (Quaternion.CreateFromEulers(90 * Utils.DEG_TO_RAD, 0, 0)); | ||
146 | |||
147 | // <180,0,0> | ||
148 | grp2.UpdateGroupRotation(Quaternion.CreateFromEulers(180 * Utils.DEG_TO_RAD, 0, 0)); | ||
149 | |||
150 | // <270,0,0> | ||
151 | grp3.Rotation = (Quaternion.CreateFromEulers(270 * Utils.DEG_TO_RAD, 0, 0)); | ||
152 | |||
153 | // <0,90,0> | ||
154 | grp4.UpdateGroupRotation(Quaternion.CreateFromEulers(0, 90 * Utils.DEG_TO_RAD, 0)); | ||
155 | |||
156 | // Required for linking | ||
157 | grp1.RootPart.UpdateFlag = 0; | ||
158 | grp2.RootPart.UpdateFlag = 0; | ||
159 | grp3.RootPart.UpdateFlag = 0; | ||
160 | grp4.RootPart.UpdateFlag = 0; | ||
161 | |||
162 | // Link grp2 to grp1. part2 becomes child prim to grp1. grp2 is eliminated. | ||
163 | grp1.LinkToGroup(grp2); | ||
164 | |||
165 | // Link grp4 to grp3. | ||
166 | grp3.LinkToGroup(grp4); | ||
167 | |||
168 | // At this point we should have 4 parts total in two groups. | ||
169 | Assert.That(grp1.Children.Count == 2); | ||
170 | Assert.That(grp2.IsDeleted, "Group 2 was not registered as deleted after link."); | ||
171 | Assert.That(grp2.Children.Count, Is.EqualTo(0), "Group 2 still contained parts after delink."); | ||
172 | Assert.That(grp3.Children.Count == 2); | ||
173 | Assert.That(grp4.IsDeleted, "Group 4 was not registered as deleted after link."); | ||
174 | Assert.That(grp4.Children.Count, Is.EqualTo(0), "Group 4 still contained parts after delink."); | ||
175 | |||
176 | if (debugtest) | ||
177 | { | ||
178 | System.Console.WriteLine("--------After Link-------"); | ||
179 | System.Console.WriteLine("Group1: parts: {0}", grp1.Children.Count); | ||
180 | System.Console.WriteLine("Group1: Pos:{0}, Rot:{1}", grp1.AbsolutePosition, grp1.Rotation); | ||
181 | System.Console.WriteLine("Group1: Prim1: OffsetPosition:{0}, OffsetRotation:{1}", part1.OffsetPosition, part1.RotationOffset); | ||
182 | System.Console.WriteLine("Group1: Prim2: OffsetPosition:{0}, OffsetRotation:{1}", part2.OffsetPosition, part2.RotationOffset); | ||
183 | |||
184 | System.Console.WriteLine("Group3: parts: {0}", grp3.Children.Count); | ||
185 | System.Console.WriteLine("Group3: Pos:{0}, Rot:{1}", grp3.AbsolutePosition, grp3.Rotation); | ||
186 | System.Console.WriteLine("Group3: Prim1: OffsetPosition:{0}, OffsetRotation:{1}", part3.OffsetPosition, part3.RotationOffset); | ||
187 | System.Console.WriteLine("Group3: Prim2: OffsetPosition:{0}, OffsetRotation:{1}", part4.OffsetPosition, part4.RotationOffset); | ||
188 | } | ||
189 | |||
190 | // Required for linking | ||
191 | grp1.RootPart.UpdateFlag = 0; | ||
192 | grp3.RootPart.UpdateFlag = 0; | ||
193 | |||
194 | // root part should have no offset position or rotation | ||
195 | Assert.That(part1.OffsetPosition == Vector3.Zero && part1.RotationOffset == Quaternion.Identity); | ||
196 | |||
197 | // offset position should be root part position - part2.absolute position. | ||
198 | Assert.That(part2.OffsetPosition == new Vector3(-10, -10, -10)); | ||
199 | |||
200 | float roll = 0; | ||
201 | float pitch = 0; | ||
202 | float yaw = 0; | ||
203 | |||
204 | // There's a euler anomoly at 180, 0, 0 so expect 180 to turn into -180. | ||
205 | part1.RotationOffset.GetEulerAngles(out roll, out pitch, out yaw); | ||
206 | Vector3 rotEuler1 = new Vector3(roll * Utils.RAD_TO_DEG, pitch * Utils.RAD_TO_DEG, yaw * Utils.RAD_TO_DEG); | ||
207 | |||
208 | if (debugtest) | ||
209 | System.Console.WriteLine(rotEuler1); | ||
210 | |||
211 | part2.RotationOffset.GetEulerAngles(out roll, out pitch, out yaw); | ||
212 | Vector3 rotEuler2 = new Vector3(roll * Utils.RAD_TO_DEG, pitch * Utils.RAD_TO_DEG, yaw * Utils.RAD_TO_DEG); | ||
213 | |||
214 | if (debugtest) | ||
215 | System.Console.WriteLine(rotEuler2); | ||
216 | |||
217 | Assert.That(rotEuler2.ApproxEquals(new Vector3(-180, 0, 0), 0.001f) || rotEuler2.ApproxEquals(new Vector3(180, 0, 0), 0.001f)); | ||
218 | |||
219 | // Now we're linking the first group to the third group. This will make the first group child parts of the third one. | ||
220 | grp3.LinkToGroup(grp1); | ||
221 | |||
222 | // Delink parts 2 and 3 | ||
223 | grp3.DelinkFromGroup(part2.LocalId); | ||
224 | grp3.DelinkFromGroup(part3.LocalId); | ||
225 | |||
226 | if (debugtest) | ||
227 | { | ||
228 | System.Console.WriteLine("--------After De-Link-------"); | ||
229 | System.Console.WriteLine("Group1: parts: {0}", grp1.Children.Count); | ||
230 | System.Console.WriteLine("Group1: Pos:{0}, Rot:{1}", grp1.AbsolutePosition, grp1.Rotation); | ||
231 | System.Console.WriteLine("Group1: Prim1: OffsetPosition:{0}, OffsetRotation:{1}", part1.OffsetPosition, part1.RotationOffset); | ||
232 | System.Console.WriteLine("NoGroup: Prim2: AbsolutePosition:{0}, OffsetRotation:{1}", part2.AbsolutePosition, part2.RotationOffset); | ||
233 | |||
234 | System.Console.WriteLine("Group3: parts: {0}", grp3.Children.Count); | ||
235 | System.Console.WriteLine("Group3: Pos:{0}, Rot:{1}", grp3.AbsolutePosition, grp3.Rotation); | ||
236 | System.Console.WriteLine("Group3: Prim1: OffsetPosition:{0}, OffsetRotation:{1}", part3.OffsetPosition, part3.RotationOffset); | ||
237 | System.Console.WriteLine("Group3: Prim2: OffsetPosition:{0}, OffsetRotation:{1}", part4.OffsetPosition, part4.RotationOffset); | ||
238 | } | ||
239 | |||
240 | Assert.That(part2.AbsolutePosition == Vector3.Zero); | ||
241 | Assert.That(part4.OffsetPosition == new Vector3(20, 20, 20)); | ||
242 | Quaternion compareQuaternion = new Quaternion(0, 0.7071068f, 0, 0.7071068f); | ||
243 | Assert.That((part4.RotationOffset.X - compareQuaternion.X < 0.00003) | ||
244 | && (part4.RotationOffset.Y - compareQuaternion.Y < 0.00003) | ||
245 | && (part4.RotationOffset.Z - compareQuaternion.Z < 0.00003) | ||
246 | && (part4.RotationOffset.W - compareQuaternion.W < 0.00003)); | ||
247 | } | ||
248 | } | ||
249 | } | ||
diff --git a/OpenSim/Region/Environment/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Environment/Scenes/Tests/ScenePresenceTests.cs deleted file mode 100644 index d66c365..0000000 --- a/OpenSim/Region/Environment/Scenes/Tests/ScenePresenceTests.cs +++ /dev/null | |||
@@ -1,292 +0,0 @@ | |||
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 OpenSim 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 Nini.Config; | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Text; | ||
32 | using NUnit.Framework; | ||
33 | using NUnit.Framework.SyntaxHelpers; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.Communications; | ||
37 | using OpenSim.Region.Environment.Scenes; | ||
38 | using OpenSim.Region.Environment.Interfaces; | ||
39 | using OpenSim.Region.Environment.Modules.Communications.Local; | ||
40 | using OpenSim.Region.Environment.Modules.World.Serialiser; | ||
41 | using OpenSim.Tests.Common.Mock; | ||
42 | using OpenSim.Tests.Common.Setup; | ||
43 | |||
44 | namespace OpenSim.Region.Environment.Scenes.Tests | ||
45 | { | ||
46 | /// <summary> | ||
47 | /// Scene presence tests | ||
48 | /// </summary> | ||
49 | [TestFixture] | ||
50 | public class ScenePresenceTests | ||
51 | { | ||
52 | public Scene scene, scene2, scene3; | ||
53 | public UUID agent1, agent2, agent3; | ||
54 | public static Random random; | ||
55 | public ulong region1,region2,region3; | ||
56 | public CommunicationsManager cm; | ||
57 | public AgentCircuitData acd1; | ||
58 | public SceneObjectGroup sog1, sog2, sog3; | ||
59 | public TestClient testclient; | ||
60 | |||
61 | [TestFixtureSetUp] | ||
62 | public void Init() | ||
63 | { | ||
64 | cm = new TestCommunicationsManager(); | ||
65 | scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000, cm); | ||
66 | scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000, cm); | ||
67 | scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000, cm); | ||
68 | |||
69 | agent1 = UUID.Random(); | ||
70 | agent2 = UUID.Random(); | ||
71 | agent3 = UUID.Random(); | ||
72 | random = new Random(); | ||
73 | sog1 = NewSOG(UUID.Random(), scene, agent1); | ||
74 | sog2 = NewSOG(UUID.Random(), scene, agent1); | ||
75 | sog3 = NewSOG(UUID.Random(), scene, agent1); | ||
76 | |||
77 | //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); | ||
78 | region1 = scene.RegionInfo.RegionHandle; | ||
79 | region2 = scene2.RegionInfo.RegionHandle; | ||
80 | region3 = scene3.RegionInfo.RegionHandle; | ||
81 | } | ||
82 | |||
83 | /// <summary> | ||
84 | /// Test adding a root agent to a scene. Doesn't yet actually complete crossing the agent into the scene. | ||
85 | /// </summary> | ||
86 | [Test] | ||
87 | public void T010_TestAddRootAgent() | ||
88 | { | ||
89 | string firstName = "testfirstname"; | ||
90 | |||
91 | AgentCircuitData agent = new AgentCircuitData(); | ||
92 | agent.AgentID = agent1; | ||
93 | agent.firstname = firstName; | ||
94 | agent.lastname = "testlastname"; | ||
95 | agent.SessionID = UUID.Zero; | ||
96 | agent.SecureSessionID = UUID.Zero; | ||
97 | agent.circuitcode = 123; | ||
98 | agent.BaseFolder = UUID.Zero; | ||
99 | agent.InventoryFolder = UUID.Zero; | ||
100 | agent.startpos = Vector3.Zero; | ||
101 | agent.CapsPath = GetRandomCapsObjectPath(); | ||
102 | |||
103 | scene.NewUserConnection(agent); | ||
104 | testclient = new TestClient(agent, scene); | ||
105 | scene.AddNewClient(testclient); | ||
106 | |||
107 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
108 | |||
109 | Assert.That(presence, Is.Not.Null, "presence is null"); | ||
110 | Assert.That(presence.Firstname, Is.EqualTo(firstName), "First name not same"); | ||
111 | acd1 = agent; | ||
112 | } | ||
113 | |||
114 | /// <summary> | ||
115 | /// Test removing an uncrossed root agent from a scene. | ||
116 | /// </summary> | ||
117 | [Test] | ||
118 | public void T011_TestRemoveRootAgent() | ||
119 | { | ||
120 | scene.RemoveClient(agent1); | ||
121 | |||
122 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
123 | |||
124 | Assert.That(presence, Is.Null, "presence is not null"); | ||
125 | } | ||
126 | |||
127 | [Test] | ||
128 | public void T012_TestAddNeighbourRegion() | ||
129 | { | ||
130 | SceneSetupHelpers.AddRootAgent(scene,agent1); | ||
131 | |||
132 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
133 | |||
134 | string cap = presence.ControllingClient.RequestClientInfo().CapsPath; | ||
135 | |||
136 | presence.AddNeighbourRegion(region2, cap); | ||
137 | presence.AddNeighbourRegion(region3, cap); | ||
138 | |||
139 | List<ulong> neighbours = presence.GetKnownRegionList(); | ||
140 | |||
141 | Assert.That(neighbours.Count, Is.EqualTo(2)); | ||
142 | } | ||
143 | |||
144 | [Test] | ||
145 | public void T013_TestRemoveNeighbourRegion() | ||
146 | { | ||
147 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
148 | presence.RemoveNeighbourRegion(region3); | ||
149 | |||
150 | List<ulong> neighbours = presence.GetKnownRegionList(); | ||
151 | Assert.That(neighbours.Count,Is.EqualTo(1)); | ||
152 | /* | ||
153 | presence.MakeChildAgent; | ||
154 | presence.MakeRootAgent; | ||
155 | CompleteAvatarMovement | ||
156 | */ | ||
157 | } | ||
158 | |||
159 | [Test] | ||
160 | public void T020_TestMakeRootAgent() | ||
161 | { | ||
162 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
163 | Assert.That(presence.IsChildAgent, Is.False, "Starts out as a root agent"); | ||
164 | |||
165 | presence.MakeChildAgent(); | ||
166 | Assert.That(presence.IsChildAgent, Is.True, "Did not change to child agent after MakeChildAgent"); | ||
167 | |||
168 | // Accepts 0 but rejects Constants.RegionSize | ||
169 | Vector3 pos = new Vector3(0,Constants.RegionSize-1,0); | ||
170 | presence.MakeRootAgent(pos,true); | ||
171 | Assert.That(presence.IsChildAgent, Is.False, "Did not go back to root agent"); | ||
172 | Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered"); | ||
173 | } | ||
174 | |||
175 | [Test] | ||
176 | public void T021_TestCrossToNewRegion() | ||
177 | { | ||
178 | // Adding child agent to region 1001 | ||
179 | scene2.NewUserConnection(acd1); | ||
180 | scene2.AddNewClient(testclient); | ||
181 | |||
182 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
183 | ScenePresence presence2 = scene2.GetScenePresence(agent1); | ||
184 | |||
185 | // Adding neighbour region caps info to presence2 | ||
186 | string cap = presence.ControllingClient.RequestClientInfo().CapsPath; | ||
187 | presence2.AddNeighbourRegion(region1, cap); | ||
188 | |||
189 | Assert.That(presence.IsChildAgent, Is.False, "Did not start root in origin region."); | ||
190 | Assert.That(presence2.IsChildAgent, Is.True, "Is not a child on destination region."); | ||
191 | |||
192 | // Cross to x+1 | ||
193 | presence.AbsolutePosition = new Vector3(Constants.RegionSize+1,3,100); | ||
194 | scene.RegisterRegionWithGrid(); | ||
195 | scene2.RegisterRegionWithGrid(); | ||
196 | presence.Update(); | ||
197 | |||
198 | Assert.That(presence.IsChildAgent, Is.True, "Did not complete region cross as expected."); | ||
199 | Assert.That(presence2.IsChildAgent, Is.False, "Did not receive root status after receiving agent."); | ||
200 | |||
201 | // Cross Back | ||
202 | presence2.AbsolutePosition = new Vector3(-1, 3, 100); | ||
203 | presence2.Update(); | ||
204 | |||
205 | Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected."); | ||
206 | Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); | ||
207 | } | ||
208 | |||
209 | [Test] | ||
210 | public void T030_TestAddAttachments() | ||
211 | { | ||
212 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
213 | |||
214 | presence.AddAttachment(sog1); | ||
215 | presence.AddAttachment(sog2); | ||
216 | presence.AddAttachment(sog3); | ||
217 | |||
218 | Assert.That(presence.HasAttachments(), Is.True); | ||
219 | Assert.That(presence.ValidateAttachments(), Is.True); | ||
220 | } | ||
221 | |||
222 | [Test] | ||
223 | public void T031_RemoveAttachments() | ||
224 | { | ||
225 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
226 | presence.RemoveAttachment(sog1); | ||
227 | presence.RemoveAttachment(sog2); | ||
228 | presence.RemoveAttachment(sog3); | ||
229 | Assert.That(presence.HasAttachments(), Is.False); | ||
230 | } | ||
231 | |||
232 | [Test] | ||
233 | public void T032_CrossAttachments() | ||
234 | { | ||
235 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
236 | ScenePresence presence2 = scene2.GetScenePresence(agent1); | ||
237 | presence2.AddAttachment(sog1); | ||
238 | presence2.AddAttachment(sog2); | ||
239 | |||
240 | IRegionModule serialiser = new SerialiserModule(); | ||
241 | SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser); | ||
242 | SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser); | ||
243 | |||
244 | Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); | ||
245 | |||
246 | Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); | ||
247 | Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); | ||
248 | Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); | ||
249 | } | ||
250 | |||
251 | public static string GetRandomCapsObjectPath() | ||
252 | { | ||
253 | UUID caps = UUID.Random(); | ||
254 | string capsPath = caps.ToString(); | ||
255 | capsPath = capsPath.Remove(capsPath.Length - 4, 4); | ||
256 | return capsPath; | ||
257 | } | ||
258 | |||
259 | private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent) | ||
260 | { | ||
261 | SceneObjectPart sop = new SceneObjectPart(); | ||
262 | sop.Name = RandomName(); | ||
263 | sop.Description = RandomName(); | ||
264 | sop.Text = RandomName(); | ||
265 | sop.SitName = RandomName(); | ||
266 | sop.TouchName = RandomName(); | ||
267 | sop.UUID = uuid; | ||
268 | sop.Shape = PrimitiveBaseShape.Default; | ||
269 | sop.Shape.State = 1; | ||
270 | sop.OwnerID = agent; | ||
271 | |||
272 | SceneObjectGroup sog = new SceneObjectGroup(); | ||
273 | sog.SetScene(scene); | ||
274 | sog.SetRootPart(sop); | ||
275 | |||
276 | return sog; | ||
277 | } | ||
278 | |||
279 | private static string RandomName() | ||
280 | { | ||
281 | StringBuilder name = new StringBuilder(); | ||
282 | int size = random.Next(5,12); | ||
283 | char ch ; | ||
284 | for (int i=0; i<size; i++) | ||
285 | { | ||
286 | ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ; | ||
287 | name.Append(ch); | ||
288 | } | ||
289 | return name.ToString(); | ||
290 | } | ||
291 | } | ||
292 | } | ||
diff --git a/OpenSim/Region/Environment/Scenes/Tests/StandaloneTeleportTests.cs b/OpenSim/Region/Environment/Scenes/Tests/StandaloneTeleportTests.cs deleted file mode 100644 index 221d97f..0000000 --- a/OpenSim/Region/Environment/Scenes/Tests/StandaloneTeleportTests.cs +++ /dev/null | |||
@@ -1,105 +0,0 @@ | |||
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 OpenSim 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 Nini.Config; | ||
29 | using NUnit.Framework; | ||
30 | using NUnit.Framework.SyntaxHelpers; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Framework.Communications; | ||
34 | using OpenSim.Region.Environment; | ||
35 | using OpenSim.Region.Environment.Interfaces; | ||
36 | using OpenSim.Region.Environment.Modules.Communications.REST; | ||
37 | using OpenSim.Tests.Common.Mock; | ||
38 | using OpenSim.Tests.Common.Setup; | ||
39 | |||
40 | namespace OpenSim.Region.Environment.Scenes.Tests | ||
41 | { | ||
42 | /// <summary> | ||
43 | /// Teleport tests in a standalone OpenSim | ||
44 | /// </summary> | ||
45 | [TestFixture] | ||
46 | public class StandaloneTeleportTests | ||
47 | { | ||
48 | /// <summary> | ||
49 | /// Test a teleport between two regions that are not neighbours and do not share any neighbours in common. | ||
50 | /// </summary> | ||
51 | /// Does not yet do what is says on the tin. | ||
52 | [Test] | ||
53 | public void TestSimpleNotNeighboursTeleport() | ||
54 | { | ||
55 | //log4net.Config.XmlConfigurator.Configure(); | ||
56 | |||
57 | UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100"); | ||
58 | UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200"); | ||
59 | CommunicationsManager cm = new TestCommunicationsManager(); | ||
60 | |||
61 | // shared module | ||
62 | IRegionModule interregionComms = new RESTInterregionComms(); | ||
63 | |||
64 | Scene sceneA = SceneSetupHelpers.SetupScene("sceneA", sceneAId, 1000, 1000, cm); | ||
65 | SceneSetupHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms); | ||
66 | sceneA.RegisterRegionWithGrid(); | ||
67 | |||
68 | Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010, cm); | ||
69 | SceneSetupHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms); | ||
70 | sceneB.RegisterRegionWithGrid(); | ||
71 | |||
72 | UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000041"); | ||
73 | TestClient client = SceneSetupHelpers.AddRootAgent(sceneA, agentId); | ||
74 | |||
75 | ICapabilitiesModule sceneACapsModule = sceneA.RequestModuleInterface<ICapabilitiesModule>(); | ||
76 | |||
77 | Assert.That( | ||
78 | sceneACapsModule.GetCapsPath(agentId), | ||
79 | Is.EqualTo(client.CapsSeedUrl), | ||
80 | "Incorrect caps object path set up in sceneA"); | ||
81 | |||
82 | // FIXME: This is a hack to get the test working - really the normal OpenSim mechanisms should be used. | ||
83 | client.TeleportTargetScene = sceneB; | ||
84 | client.Teleport(sceneB.RegionInfo.RegionHandle, new Vector3(100, 100, 100), new Vector3(40, 40, 40)); | ||
85 | |||
86 | Assert.That(sceneB.GetScenePresence(agentId), Is.Not.Null, "Client does not have an agent in sceneB"); | ||
87 | Assert.That(sceneA.GetScenePresence(agentId), Is.Null, "Client still had an agent in sceneA"); | ||
88 | |||
89 | ICapabilitiesModule sceneBCapsModule = sceneB.RequestModuleInterface<ICapabilitiesModule>(); | ||
90 | |||
91 | // Temporary assertion - caps url construction should at least be doable through a method. | ||
92 | Assert.That( | ||
93 | "http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort + "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/", | ||
94 | Is.EqualTo(client.CapsSeedUrl), | ||
95 | "Incorrect caps object path set up in sceneB"); | ||
96 | |||
97 | // This assertion will currently fail since we don't remove the caps paths when no longer needed | ||
98 | //Assert.That(sceneACapsModule.GetCapsPath(agentId), Is.Null, "sceneA still had a caps object path"); | ||
99 | |||
100 | // TODO: Check that more of everything is as it should be | ||
101 | |||
102 | // TODO: test what happens if we try to teleport to a region that doesn't exist | ||
103 | } | ||
104 | } | ||
105 | } \ No newline at end of file | ||