OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
SceneObjectStatusTests.cs
Go to the documentation of this file.
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.Region.Framework.Scenes;
35 using OpenSim.Tests.Common;
36 
37 namespace OpenSim.Region.Framework.Scenes.Tests
38 {
42  [TestFixture]
44  {
45  private TestScene m_scene;
46  private UUID m_ownerId = TestHelpers.ParseTail(0x1);
47  private SceneObjectGroup m_so1;
48  private SceneObjectGroup m_so2;
49 
50  [SetUp]
51  public void Init()
52  {
53  m_scene = new SceneHelpers().SetupScene();
54  m_so1 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so1", 0x10);
55  m_so2 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so2", 0x20);
56  }
57 
58  [Test]
59  public void TestSetTemporary()
60  {
61  TestHelpers.InMethod();
62 
63  m_scene.AddSceneObject(m_so1);
64  m_so1.ScriptSetTemporaryStatus(true);
65 
66  // Is this really the correct flag?
67  Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.TemporaryOnRez));
68  Assert.That(m_so1.Backup, Is.False);
69 
70  // Test setting back to non-temporary
71  m_so1.ScriptSetTemporaryStatus(false);
72 
73  Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
74  Assert.That(m_so1.Backup, Is.True);
75  }
76 
77  [Test]
79  {
80  TestHelpers.InMethod();
81 
82  m_scene.AddSceneObject(m_so1);
83 
84  SceneObjectPart rootPart = m_so1.RootPart;
85  Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
86 
87  m_so1.ScriptSetPhantomStatus(true);
88 
89 // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
90  Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom));
91 
92  m_so1.ScriptSetPhantomStatus(false);
93 
94  Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
95  }
96 
97  [Test]
99  {
100  TestHelpers.InMethod();
101 
102  m_scene.AddSceneObject(m_so1);
103 
104  SceneObjectPart rootPart = m_so1.RootPart;
105  Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
106 
107  m_so1.ScriptSetVolumeDetect(true);
108 
109 // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
110  Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom));
111 
112  m_so1.ScriptSetVolumeDetect(false);
113 
114  Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
115  }
116 
117  [Test]
119  {
120  TestHelpers.InMethod();
121 
122  m_scene.AddSceneObject(m_so1);
123 
124  SceneObjectPart rootPart = m_so1.RootPart;
125  Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
126 
127  m_so1.ScriptSetPhysicsStatus(true);
128 
129  Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics));
130 
131  m_so1.ScriptSetPhysicsStatus(false);
132 
133  Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
134  }
135 
136  [Test]
138  {
139  TestHelpers.InMethod();
140 
141  m_scene.AddSceneObject(m_so1);
142 
143  SceneObjectPart rootPart = m_so1.RootPart;
144  Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
145 
146  m_so1.ScriptSetPhysicsStatus(true);
147  m_so1.ScriptSetVolumeDetect(true);
148 
149  Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom | PrimFlags.Physics));
150 
151  m_so1.ScriptSetVolumeDetect(false);
152 
153  Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics));
154  }
155 
156  [Test]
157  public void TestSetPhysicsLinkset()
158  {
159  TestHelpers.InMethod();
160 
161  m_scene.AddSceneObject(m_so1);
162  m_scene.AddSceneObject(m_so2);
163 
164  m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
165 
166  m_so1.ScriptSetPhysicsStatus(true);
167 
168  Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
169  Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
170 
171  m_so1.ScriptSetPhysicsStatus(false);
172 
173  Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
174  Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
175 
176  m_so1.ScriptSetPhysicsStatus(true);
177 
178  Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
179  Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
180  }
181 
185  [Test]
187  {
188  TestHelpers.InMethod();
189 
190  m_scene.AddSceneObject(m_so1);
191  m_scene.AddSceneObject(m_so2);
192 
193  m_so1.ScriptSetPhysicsStatus(true);
194  m_so2.ScriptSetPhysicsStatus(true);
195 
196  m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
197 
198  Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
199  Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
200  }
201 
205  [Test]
207  {
208  TestHelpers.InMethod();
209 
210  m_scene.AddSceneObject(m_so1);
211  m_scene.AddSceneObject(m_so2);
212 
213  m_so1.ScriptSetPhysicsStatus(true);
214 
215  m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
216 
217  Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
218  Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
219  }
220 
224  [Test]
226  {
227  TestHelpers.InMethod();
228 
229  m_scene.AddSceneObject(m_so1);
230  m_scene.AddSceneObject(m_so2);
231 
232  m_so2.ScriptSetPhysicsStatus(true);
233 
234  m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
235 
236  Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
237  Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
238  }
239  }
240 }
void TestLinkPhysicsBothPhysical()
Test that linking results in the correct physical status for all linkees.
void TestLinkPhysicsRootPhysicalOnly()
Test that linking results in the correct physical status for all linkees.
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
Helpers for setting up scenes.
Definition: SceneHelpers.cs:60
void TestLinkPhysicsChildPhysicalOnly()
Test that linking results in the correct physical status for all linkees.