aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-06-22 00:39:41 +0100
committerJustin Clark-Casey (justincc)2012-06-22 00:40:04 +0100
commit798846c5b6c05f37c661dde70fb9aaf51306e407 (patch)
tree3b8c40ae72ef9f3d11ddce820b6ed3b751f8e41a
parentAdd regression test for updating attachment position (diff)
downloadopensim-SC_OLD-798846c5b6c05f37c661dde70fb9aaf51306e407.zip
opensim-SC_OLD-798846c5b6c05f37c661dde70fb9aaf51306e407.tar.gz
opensim-SC_OLD-798846c5b6c05f37c661dde70fb9aaf51306e407.tar.bz2
opensim-SC_OLD-798846c5b6c05f37c661dde70fb9aaf51306e407.tar.xz
refactor AttachmentsModule tests to use a common method for standard attachment item setup
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs139
1 files changed, 69 insertions, 70 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 94c0030..8f4a807 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -58,6 +58,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
58 private AttachmentsModule m_attMod; 58 private AttachmentsModule m_attMod;
59 private ScenePresence m_presence; 59 private ScenePresence m_presence;
60 60
61 /// <summary>
62 /// Standard user ID
63 /// </summary>
64 private UUID m_userId = TestHelpers.ParseTail(0x1);
65
66// /// <summary>
67// /// Standard attachment item ID
68// /// </summary>
69// private UUID m_attItemId = TestHelpers.ParseTail(0x10);
70//
71// /// <summary>
72// /// Standard attachment asset ID
73// /// </summary>
74// private UUID m_attAssetId = TestHelpers.ParseTail(0x11);
75
61 [TestFixtureSetUp] 76 [TestFixtureSetUp]
62 public void FixtureInit() 77 public void FixtureInit()
63 { 78 {
@@ -86,13 +101,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
86 } 101 }
87 102
88 /// <summary> 103 /// <summary>
89 /// Add the standard presence for a test. 104 /// Creates an attachment item in the given user's inventory. Does not attach.
90 /// </summary> 105 /// </summary>
91 private void AddPresence() 106 /// <remarks>
107 /// A user with the given ID and an inventory must already exist.
108 /// </remarks>
109 /// <returns>
110 /// The attachment item.
111 /// </returns>
112 /// <param name='userId'></param>
113 /// <param name='attName'></param>
114 /// <param name='rawItemId'></param>
115 /// <param name='rawAssetId'></param>
116 private InventoryItemBase CreateAttachmentItem(UUID userId, string attName, int rawItemId, int rawAssetId)
92 { 117 {
93 UUID userId = TestHelpers.ParseTail(0x1); 118 return UserInventoryHelpers.CreateInventoryItem(
94 UserAccountHelpers.CreateUserWithInventory(scene, userId); 119 scene,
95 m_presence = SceneHelpers.AddScenePresence(scene, userId); 120 attName,
121 TestHelpers.ParseTail(rawItemId),
122 TestHelpers.ParseTail(rawAssetId),
123 userId,
124 InventoryType.Object);
96 } 125 }
97 126
98 [Test] 127 [Test]
@@ -101,7 +130,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
101 TestHelpers.InMethod(); 130 TestHelpers.InMethod();
102// TestHelpers.EnableLogging(); 131// TestHelpers.EnableLogging();
103 132
104 AddPresence(); 133 UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
134 m_presence = SceneHelpers.AddScenePresence(scene, m_userId);
135
105 string attName = "att"; 136 string attName = "att";
106 137
107 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, m_presence.UUID).ParentGroup; 138 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, m_presence.UUID).ParentGroup;
@@ -140,24 +171,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
140 TestHelpers.InMethod(); 171 TestHelpers.InMethod();
141// log4net.Config.XmlConfigurator.Configure(); 172// log4net.Config.XmlConfigurator.Configure();
142 173
143 AddPresence(); 174 UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
144 175 m_presence = SceneHelpers.AddScenePresence(scene, m_userId);
145 UUID attItemId = TestHelpers.ParseTail(0x2);
146 UUID attAssetId = TestHelpers.ParseTail(0x3);
147 string attName = "att";
148 176
149 UserInventoryHelpers.CreateInventoryItem( 177 InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20);
150 scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
151 178
152 m_attMod.RezSingleAttachmentFromInventory( 179 m_attMod.RezSingleAttachmentFromInventory(
153 m_presence, attItemId, (uint)AttachmentPoint.Chest); 180 m_presence, attItem.ID, (uint)AttachmentPoint.Chest);
154 181
155 // Check scene presence status 182 // Check scene presence status
156 Assert.That(m_presence.HasAttachments(), Is.True); 183 Assert.That(m_presence.HasAttachments(), Is.True);
157 List<SceneObjectGroup> attachments = m_presence.GetAttachments(); 184 List<SceneObjectGroup> attachments = m_presence.GetAttachments();
158 Assert.That(attachments.Count, Is.EqualTo(1)); 185 Assert.That(attachments.Count, Is.EqualTo(1));
159 SceneObjectGroup attSo = attachments[0]; 186 SceneObjectGroup attSo = attachments[0];
160 Assert.That(attSo.Name, Is.EqualTo(attName)); 187 Assert.That(attSo.Name, Is.EqualTo(attItem.Name));
161 Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); 188 Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
162 Assert.That(attSo.IsAttachment); 189 Assert.That(attSo.IsAttachment);
163 Assert.That(attSo.UsesPhysics, Is.False); 190 Assert.That(attSo.UsesPhysics, Is.False);
@@ -165,7 +192,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
165 192
166 // Check appearance status 193 // Check appearance status
167 Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(1)); 194 Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(1));
168 Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest)); 195 Assert.That(m_presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
169 } 196 }
170 197
171 [Test] 198 [Test]
@@ -174,17 +201,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
174 TestHelpers.InMethod(); 201 TestHelpers.InMethod();
175// log4net.Config.XmlConfigurator.Configure(); 202// log4net.Config.XmlConfigurator.Configure();
176 203
177 AddPresence(); 204 UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
178 205 m_presence = SceneHelpers.AddScenePresence(scene, m_userId);
179 UUID attItemId = TestHelpers.ParseTail(0x2);
180 UUID attAssetId = TestHelpers.ParseTail(0x3);
181 string attName = "att";
182 206
183 UserInventoryHelpers.CreateInventoryItem( 207 InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20);
184 scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
185 208
186 ISceneEntity so = m_attMod.RezSingleAttachmentFromInventory( 209 ISceneEntity so
187 m_presence, attItemId, (uint)AttachmentPoint.Chest); 210 = m_attMod.RezSingleAttachmentFromInventory(
211 m_presence, attItem.ID, (uint)AttachmentPoint.Chest);
188 m_attMod.DetachSingleAttachmentToGround(m_presence, so.LocalId); 212 m_attMod.DetachSingleAttachmentToGround(m_presence, so.LocalId);
189 213
190 // Check scene presence status 214 // Check scene presence status
@@ -196,7 +220,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
196 Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(0)); 220 Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(0));
197 221
198 // Check item status 222 // Check item status
199 Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItemId)), Is.Null); 223 Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItem.ID)), Is.Null);
200 224
201 // Check object in scene 225 // Check object in scene
202 Assert.That(scene.GetSceneObjectGroup("att"), Is.Not.Null); 226 Assert.That(scene.GetSceneObjectGroup("att"), Is.Not.Null);
@@ -208,18 +232,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
208 TestHelpers.InMethod(); 232 TestHelpers.InMethod();
209// log4net.Config.XmlConfigurator.Configure(); 233// log4net.Config.XmlConfigurator.Configure();
210 234
211 AddPresence(); 235 UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
212 236 m_presence = SceneHelpers.AddScenePresence(scene, m_userId);
213 UUID attItemId = TestHelpers.ParseTail(0x2);
214 UUID attAssetId = TestHelpers.ParseTail(0x3);
215 string attName = "att";
216 237
217 UserInventoryHelpers.CreateInventoryItem( 238 InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20);
218 scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
219 239
220 m_attMod.RezSingleAttachmentFromInventory( 240 m_attMod.RezSingleAttachmentFromInventory(
221 m_presence, attItemId, (uint)AttachmentPoint.Chest); 241 m_presence, attItem.ID, (uint)AttachmentPoint.Chest);
222 m_attMod.DetachSingleAttachmentToInv(m_presence, attItemId); 242 m_attMod.DetachSingleAttachmentToInv(m_presence, attItem.ID);
223 243
224 // Check status on scene presence 244 // Check status on scene presence
225 Assert.That(m_presence.HasAttachments(), Is.False); 245 Assert.That(m_presence.HasAttachments(), Is.False);
@@ -227,7 +247,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
227 Assert.That(attachments.Count, Is.EqualTo(0)); 247 Assert.That(attachments.Count, Is.EqualTo(0));
228 248
229 // Check item status 249 // Check item status
230 Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo(0)); 250 Assert.That(m_presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo(0));
231 } 251 }
232 252
233 /// <summary> 253 /// <summary>
@@ -239,17 +259,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
239 TestHelpers.InMethod(); 259 TestHelpers.InMethod();
240// log4net.Config.XmlConfigurator.Configure(); 260// log4net.Config.XmlConfigurator.Configure();
241 261
242 UUID userId = TestHelpers.ParseTail(0x1); 262 UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
243 UUID attItemId = TestHelpers.ParseTail(0x2); 263 InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20);
244 UUID attAssetId = TestHelpers.ParseTail(0x3);
245 string attName = "att";
246
247 UserAccountHelpers.CreateUserWithInventory(scene, userId);
248 InventoryItemBase attItem
249 = UserInventoryHelpers.CreateInventoryItem(
250 scene, attName, attItemId, attAssetId, userId, InventoryType.Object);
251 264
252 AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); 265 AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId);
253 acd.Appearance = new AvatarAppearance(); 266 acd.Appearance = new AvatarAppearance();
254 acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); 267 acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID);
255 ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); 268 ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd);
@@ -268,17 +281,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
268 TestHelpers.InMethod(); 281 TestHelpers.InMethod();
269// log4net.Config.XmlConfigurator.Configure(); 282// log4net.Config.XmlConfigurator.Configure();
270 283
271 UUID userId = TestHelpers.ParseTail(0x1); 284 UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
272 UUID attItemId = TestHelpers.ParseTail(0x2); 285 InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20);
273 UUID attAssetId = TestHelpers.ParseTail(0x3);
274 string attName = "att";
275
276 UserAccountHelpers.CreateUserWithInventory(scene, userId);
277 InventoryItemBase attItem
278 = UserInventoryHelpers.CreateInventoryItem(
279 scene, attName, attItemId, attAssetId, userId, InventoryType.Object);
280 286
281 AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); 287 AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId);
282 acd.Appearance = new AvatarAppearance(); 288 acd.Appearance = new AvatarAppearance();
283 acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); 289 acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID);
284 ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); 290 ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd);
@@ -288,7 +294,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
288 294
289 Assert.That(attachments.Count, Is.EqualTo(1)); 295 Assert.That(attachments.Count, Is.EqualTo(1));
290 SceneObjectGroup attSo = attachments[0]; 296 SceneObjectGroup attSo = attachments[0];
291 Assert.That(attSo.Name, Is.EqualTo(attName)); 297 Assert.That(attSo.Name, Is.EqualTo(attItem.Name));
292 Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); 298 Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
293 Assert.That(attSo.IsAttachment); 299 Assert.That(attSo.IsAttachment);
294 Assert.That(attSo.UsesPhysics, Is.False); 300 Assert.That(attSo.UsesPhysics, Is.False);
@@ -298,9 +304,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
298 List<AvatarAttachment> retreivedAttachments = presence.Appearance.GetAttachments(); 304 List<AvatarAttachment> retreivedAttachments = presence.Appearance.GetAttachments();
299 Assert.That(retreivedAttachments.Count, Is.EqualTo(1)); 305 Assert.That(retreivedAttachments.Count, Is.EqualTo(1));
300 Assert.That(retreivedAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest)); 306 Assert.That(retreivedAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest));
301 Assert.That(retreivedAttachments[0].ItemID, Is.EqualTo(attItemId)); 307 Assert.That(retreivedAttachments[0].ItemID, Is.EqualTo(attItem.ID));
302 Assert.That(retreivedAttachments[0].AssetID, Is.EqualTo(attAssetId)); 308 Assert.That(retreivedAttachments[0].AssetID, Is.EqualTo(attItem.AssetID));
303 Assert.That(presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest)); 309 Assert.That(presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
304 } 310 }
305 311
306 [Test] 312 [Test]
@@ -308,17 +314,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
308 { 314 {
309 TestHelpers.InMethod(); 315 TestHelpers.InMethod();
310 316
311 UUID userId = TestHelpers.ParseTail(0x1); 317 UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
312 UUID attItemId = TestHelpers.ParseTail(0x2); 318 InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20);
313 UUID attAssetId = TestHelpers.ParseTail(0x3);
314 string attName = "att";
315
316 UserAccountHelpers.CreateUserWithInventory(scene, userId);
317 InventoryItemBase attItem
318 = UserInventoryHelpers.CreateInventoryItem(
319 scene, attName, attItemId, attAssetId, userId, InventoryType.Object);
320 319
321 AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); 320 AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId);
322 acd.Appearance = new AvatarAppearance(); 321 acd.Appearance = new AvatarAppearance();
323 acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); 322 acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID);
324 ScenePresence sp = SceneHelpers.AddScenePresence(scene, acd); 323 ScenePresence sp = SceneHelpers.AddScenePresence(scene, acd);