diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs | 241 |
1 files changed, 241 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs new file mode 100644 index 0000000..5ba754c --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs | |||
@@ -0,0 +1,241 @@ | |||
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 System.Reflection; | ||
31 | using NUnit.Framework; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Communications; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Tests.Common; | ||
37 | |||
38 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// Basic scene object status tests | ||
42 | /// </summary> | ||
43 | [TestFixture] | ||
44 | public class SceneObjectStatusTests : OpenSimTestCase | ||
45 | { | ||
46 | private TestScene m_scene; | ||
47 | private UUID m_ownerId = TestHelpers.ParseTail(0x1); | ||
48 | private SceneObjectGroup m_so1; | ||
49 | private SceneObjectGroup m_so2; | ||
50 | |||
51 | [SetUp] | ||
52 | public void Init() | ||
53 | { | ||
54 | m_scene = new SceneHelpers().SetupScene(); | ||
55 | m_so1 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so1", 0x10); | ||
56 | m_so2 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so2", 0x20); | ||
57 | } | ||
58 | |||
59 | [Test] | ||
60 | public void TestSetTemporary() | ||
61 | { | ||
62 | TestHelpers.InMethod(); | ||
63 | |||
64 | m_scene.AddSceneObject(m_so1); | ||
65 | m_so1.ScriptSetTemporaryStatus(true); | ||
66 | |||
67 | // Is this really the correct flag? | ||
68 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.TemporaryOnRez)); | ||
69 | Assert.That(m_so1.Backup, Is.False); | ||
70 | |||
71 | // Test setting back to non-temporary | ||
72 | m_so1.ScriptSetTemporaryStatus(false); | ||
73 | |||
74 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
75 | Assert.That(m_so1.Backup, Is.True); | ||
76 | } | ||
77 | |||
78 | [Test] | ||
79 | public void TestSetPhantomSinglePrim() | ||
80 | { | ||
81 | TestHelpers.InMethod(); | ||
82 | |||
83 | m_scene.AddSceneObject(m_so1); | ||
84 | |||
85 | SceneObjectPart rootPart = m_so1.RootPart; | ||
86 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
87 | |||
88 | m_so1.ScriptSetPhantomStatus(true); | ||
89 | |||
90 | // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); | ||
91 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom)); | ||
92 | |||
93 | m_so1.ScriptSetPhantomStatus(false); | ||
94 | |||
95 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
96 | } | ||
97 | |||
98 | [Test] | ||
99 | public void TestSetNonPhysicsVolumeDetectSinglePrim() | ||
100 | { | ||
101 | TestHelpers.InMethod(); | ||
102 | |||
103 | m_scene.AddSceneObject(m_so1); | ||
104 | |||
105 | SceneObjectPart rootPart = m_so1.RootPart; | ||
106 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
107 | |||
108 | m_so1.ScriptSetVolumeDetect(true); | ||
109 | |||
110 | // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); | ||
111 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom)); | ||
112 | |||
113 | m_so1.ScriptSetVolumeDetect(false); | ||
114 | |||
115 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
116 | } | ||
117 | |||
118 | [Test] | ||
119 | public void TestSetPhysicsSinglePrim() | ||
120 | { | ||
121 | TestHelpers.InMethod(); | ||
122 | |||
123 | m_scene.AddSceneObject(m_so1); | ||
124 | |||
125 | SceneObjectPart rootPart = m_so1.RootPart; | ||
126 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
127 | |||
128 | m_so1.ScriptSetPhysicsStatus(true); | ||
129 | |||
130 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
131 | |||
132 | m_so1.ScriptSetPhysicsStatus(false); | ||
133 | |||
134 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
135 | } | ||
136 | |||
137 | [Test] | ||
138 | public void TestSetPhysicsVolumeDetectSinglePrim() | ||
139 | { | ||
140 | TestHelpers.InMethod(); | ||
141 | |||
142 | m_scene.AddSceneObject(m_so1); | ||
143 | |||
144 | SceneObjectPart rootPart = m_so1.RootPart; | ||
145 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
146 | |||
147 | m_so1.ScriptSetPhysicsStatus(true); | ||
148 | m_so1.ScriptSetVolumeDetect(true); | ||
149 | |||
150 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom | PrimFlags.Physics)); | ||
151 | |||
152 | m_so1.ScriptSetVolumeDetect(false); | ||
153 | |||
154 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
155 | } | ||
156 | |||
157 | [Test] | ||
158 | public void TestSetPhysicsLinkset() | ||
159 | { | ||
160 | TestHelpers.InMethod(); | ||
161 | |||
162 | m_scene.AddSceneObject(m_so1); | ||
163 | m_scene.AddSceneObject(m_so2); | ||
164 | |||
165 | m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId }); | ||
166 | |||
167 | m_so1.ScriptSetPhysicsStatus(true); | ||
168 | |||
169 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
170 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); | ||
171 | |||
172 | m_so1.ScriptSetPhysicsStatus(false); | ||
173 | |||
174 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
175 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None)); | ||
176 | |||
177 | m_so1.ScriptSetPhysicsStatus(true); | ||
178 | |||
179 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
180 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); | ||
181 | } | ||
182 | |||
183 | /// <summary> | ||
184 | /// Test that linking results in the correct physical status for all linkees. | ||
185 | /// </summary> | ||
186 | [Test] | ||
187 | public void TestLinkPhysicsBothPhysical() | ||
188 | { | ||
189 | TestHelpers.InMethod(); | ||
190 | |||
191 | m_scene.AddSceneObject(m_so1); | ||
192 | m_scene.AddSceneObject(m_so2); | ||
193 | |||
194 | m_so1.ScriptSetPhysicsStatus(true); | ||
195 | m_so2.ScriptSetPhysicsStatus(true); | ||
196 | |||
197 | m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId }); | ||
198 | |||
199 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
200 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); | ||
201 | } | ||
202 | |||
203 | /// <summary> | ||
204 | /// Test that linking results in the correct physical status for all linkees. | ||
205 | /// </summary> | ||
206 | [Test] | ||
207 | public void TestLinkPhysicsRootPhysicalOnly() | ||
208 | { | ||
209 | TestHelpers.InMethod(); | ||
210 | |||
211 | m_scene.AddSceneObject(m_so1); | ||
212 | m_scene.AddSceneObject(m_so2); | ||
213 | |||
214 | m_so1.ScriptSetPhysicsStatus(true); | ||
215 | |||
216 | m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId }); | ||
217 | |||
218 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
219 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); | ||
220 | } | ||
221 | |||
222 | /// <summary> | ||
223 | /// Test that linking results in the correct physical status for all linkees. | ||
224 | /// </summary> | ||
225 | [Test] | ||
226 | public void TestLinkPhysicsChildPhysicalOnly() | ||
227 | { | ||
228 | TestHelpers.InMethod(); | ||
229 | |||
230 | m_scene.AddSceneObject(m_so1); | ||
231 | m_scene.AddSceneObject(m_so2); | ||
232 | |||
233 | m_so2.ScriptSetPhysicsStatus(true); | ||
234 | |||
235 | m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId }); | ||
236 | |||
237 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
238 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None)); | ||
239 | } | ||
240 | } | ||
241 | } \ No newline at end of file | ||