OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
AttachmentsModuleTests.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 System.Text;
32 using System.Threading;
33 using System.Timers;
34 using System.Xml;
36 using Nini.Config;
37 using NUnit.Framework;
38 using OpenMetaverse;
39 using OpenSim.Framework;
40 using OpenSim.Framework.Servers;
41 using OpenSim.Framework.Servers.HttpServer;
42 using OpenSim.Region.CoreModules.Avatar.Attachments;
43 using OpenSim.Region.CoreModules.Framework;
44 using OpenSim.Region.CoreModules.Framework.EntityTransfer;
45 using OpenSim.Region.CoreModules.Framework.InventoryAccess;
46 using OpenSim.Region.CoreModules.Scripting.WorldComm;
47 using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
48 using OpenSim.Region.CoreModules.World.Serialiser;
49 using OpenSim.Region.Framework.Scenes;
50 using OpenSim.Region.Framework.Interfaces;
51 using OpenSim.Region.ScriptEngine.Interfaces;
52 using OpenSim.Region.ScriptEngine.XEngine;
53 using OpenSim.Services.Interfaces;
54 using OpenSim.Tests.Common;
55 
56 namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
57 {
61  [TestFixture]
63  {
64  private AutoResetEvent m_chatEvent = new AutoResetEvent(false);
65 // private OSChatMessage m_osChatMessageReceived;
66 
67  // Used to test whether the operations have fired the attach event. Must be reset after each test.
68  private int m_numberOfAttachEventsFired;
69 
70  [TestFixtureSetUp]
71  public void FixtureInit()
72  {
73  // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
74  Util.FireAndForgetMethod = FireAndForgetMethod.None;
75  }
76 
77  [TestFixtureTearDown]
78  public void TearDown()
79  {
80  // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
81  // threads. Possibly, later tests should be rewritten not to worry about such things.
82  Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
83  }
84 
85  private void OnChatFromWorld(object sender, OSChatMessage oscm)
86  {
87 // Console.WriteLine("Got chat [{0}]", oscm.Message);
88 
89 // m_osChatMessageReceived = oscm;
90  m_chatEvent.Set();
91  }
92 
93  private Scene CreateTestScene()
94  {
95  IConfigSource config = new IniConfigSource();
96  List<object> modules = new List<object>();
97 
98  AddCommonConfig(config, modules);
99 
100  Scene scene
101  = new SceneHelpers().SetupScene(
102  "attachments-test-scene", TestHelpers.ParseTail(999), 1000, 1000, config);
103  SceneHelpers.SetupSceneModules(scene, config, modules.ToArray());
104 
105  scene.EventManager.OnAttach += (localID, itemID, avatarID) => m_numberOfAttachEventsFired++;
106 
107  return scene;
108  }
109 
110  private Scene CreateScriptingEnabledTestScene()
111  {
112  IConfigSource config = new IniConfigSource();
113  List<object> modules = new List<object>();
114 
115  AddCommonConfig(config, modules);
116  AddScriptingConfig(config, modules);
117 
118  Scene scene
119  = new SceneHelpers().SetupScene(
120  "attachments-test-scene", TestHelpers.ParseTail(999), 1000, 1000, config);
121  SceneHelpers.SetupSceneModules(scene, config, modules.ToArray());
122 
123  scene.StartScripts();
124 
125  return scene;
126  }
127 
128  private void AddCommonConfig(IConfigSource config, List<object> modules)
129  {
130  config.AddConfig("Modules");
131  config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
132 
133  AttachmentsModule attMod = new AttachmentsModule();
134  attMod.DebugLevel = 1;
135  modules.Add(attMod);
136  modules.Add(new BasicInventoryAccessModule());
137  }
138 
139  private void AddScriptingConfig(IConfigSource config, List<object> modules)
140  {
141  IConfig startupConfig = config.AddConfig("Startup");
142  startupConfig.Set("DefaultScriptEngine", "XEngine");
143 
144  IConfig xEngineConfig = config.AddConfig("XEngine");
145  xEngineConfig.Set("Enabled", "true");
146  xEngineConfig.Set("StartDelay", "0");
147 
148  // These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call
149  // to AssemblyResolver.OnAssemblyResolve fails.
150  xEngineConfig.Set("AppDomainLoading", "false");
151 
152  modules.Add(new XEngine());
153 
154  // Necessary to stop serialization complaining
155  // FIXME: Stop this being necessary if at all possible
156 // modules.Add(new WorldCommModule());
157  }
158 
173  private InventoryItemBase CreateAttachmentItem(
174  Scene scene, UUID userId, string attName, int rawItemId, int rawAssetId)
175  {
176  return UserInventoryHelpers.CreateInventoryItem(
177  scene,
178  attName,
179  TestHelpers.ParseTail(rawItemId),
180  TestHelpers.ParseTail(rawAssetId),
181  userId,
182  InventoryType.Object);
183  }
184 
185  [Test]
187  {
188  TestHelpers.InMethod();
189 // TestHelpers.EnableLogging();
190 
191  m_numberOfAttachEventsFired = 0;
192 
193  Scene scene = CreateTestScene();
194  UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
195  ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1);
196 
197  string attName = "att";
198 
199  SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID);
200  Assert.That(so.Backup, Is.True);
201 
202  m_numberOfAttachEventsFired = 0;
203  scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false);
204 
205  // Check status on scene presence
206  Assert.That(sp.HasAttachments(), Is.True);
207  List<SceneObjectGroup> attachments = sp.GetAttachments();
208  Assert.That(attachments.Count, Is.EqualTo(1));
209  SceneObjectGroup attSo = attachments[0];
210  Assert.That(attSo.Name, Is.EqualTo(attName));
211  Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
212  Assert.That(attSo.IsAttachment);
213  Assert.That(attSo.UsesPhysics, Is.False);
214  Assert.That(attSo.IsTemporary, Is.False);
215  Assert.That(attSo.Backup, Is.False);
216 
217  // Check item status
218 // Assert.That(
219 // sp.Appearance.GetAttachpoint(attSo.FromItemID),
220 // Is.EqualTo((int)AttachmentPoint.Chest));
221 
222  InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID));
223  Assert.That(attachmentItem, Is.Not.Null);
224  Assert.That(attachmentItem.Name, Is.EqualTo(attName));
225 
226  InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, FolderType.Object);
227  Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID));
228 
229  Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
230 
231  // Check events
232  Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
233  }
234 
235  [Test]
237  {
238  TestHelpers.InMethod();
239 // TestHelpers.EnableLogging();
240 
241  Scene scene = CreateTestScene();
242  UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
243  ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1);
244 
245  SceneObjectGroup so2 = SceneHelpers.AddSceneObject(scene, "att2", sp.UUID);
246 
247  {
248  SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID);
249 
250  m_numberOfAttachEventsFired = 0;
251  scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, true, false);
252 
253  // Check status on scene presence
254  Assert.That(sp.HasAttachments(), Is.True);
255  List<SceneObjectGroup> attachments = sp.GetAttachments();
256  Assert.That(attachments.Count, Is.EqualTo(1));
257  SceneObjectGroup attSo = attachments[0];
258  Assert.That(attSo.Name, Is.EqualTo(so.Name));
259  Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
260  Assert.That(attSo.IsAttachment);
261  Assert.That(attSo.UsesPhysics, Is.False);
262  Assert.That(attSo.IsTemporary, Is.False);
263 
264  // Check item status
265 // Assert.That(
266 // sp.Appearance.GetAttachpoint(attSo.FromItemID),
267 // Is.EqualTo((int)AttachmentPoint.LeftHand));
268 
269  InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID));
270  Assert.That(attachmentItem, Is.Not.Null);
271  Assert.That(attachmentItem.Name, Is.EqualTo(so.Name));
272 
273  InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, FolderType.Object);
274  Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID));
275 
276  Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(2));
277 
278  // Check events
279  Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
280  }
281 
282  // Test wearing a different attachment from the ground.
283  {
284  scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false);
285 
286  // Check status on scene presence
287  Assert.That(sp.HasAttachments(), Is.True);
288  List<SceneObjectGroup> attachments = sp.GetAttachments();
289  Assert.That(attachments.Count, Is.EqualTo(1));
290  SceneObjectGroup attSo = attachments[0];
291  Assert.That(attSo.Name, Is.EqualTo(so2.Name));
292  Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
293  Assert.That(attSo.IsAttachment);
294  Assert.That(attSo.UsesPhysics, Is.False);
295  Assert.That(attSo.IsTemporary, Is.False);
296 
297  // Check item status
298 // Assert.That(
299 // sp.Appearance.GetAttachpoint(attSo.FromItemID),
300 // Is.EqualTo((int)AttachmentPoint.LeftHand));
301 
302  InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID));
303  Assert.That(attachmentItem, Is.Not.Null);
304  Assert.That(attachmentItem.Name, Is.EqualTo(so2.Name));
305 
306  InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, FolderType.Object);
307  Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID));
308 
309  Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
310 
311  // Check events
312  Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3));
313  }
314 
315  // Test rewearing an already worn attachment from ground. Nothing should happen.
316  {
317  scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false);
318 
319  // Check status on scene presence
320  Assert.That(sp.HasAttachments(), Is.True);
321  List<SceneObjectGroup> attachments = sp.GetAttachments();
322  Assert.That(attachments.Count, Is.EqualTo(1));
323  SceneObjectGroup attSo = attachments[0];
324  Assert.That(attSo.Name, Is.EqualTo(so2.Name));
325  Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
326  Assert.That(attSo.IsAttachment);
327  Assert.That(attSo.UsesPhysics, Is.False);
328  Assert.That(attSo.IsTemporary, Is.False);
329 
330  // Check item status
331 // Assert.That(
332 // sp.Appearance.GetAttachpoint(attSo.FromItemID),
333 // Is.EqualTo((int)AttachmentPoint.LeftHand));
334 
335  InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID));
336  Assert.That(attachmentItem, Is.Not.Null);
337  Assert.That(attachmentItem.Name, Is.EqualTo(so2.Name));
338 
339  InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, FolderType.Object);
340  Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID));
341 
342  Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
343 
344  // Check events
345  Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3));
346  }
347  }
348 
352  [Test]
354  {
355  TestHelpers.InMethod();
356 // TestHelpers.EnableLogging();
357 
358  m_numberOfAttachEventsFired = 0;
359 
360  Scene scene = CreateTestScene();
361  UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
362  ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1);
363 
364  string attName = "att";
365 
366  SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID);
367 
368  UserAccount ua2 = UserAccountHelpers.CreateUserWithInventory(scene, 0x2);
369  ScenePresence sp2 = SceneHelpers.AddScenePresence(scene, ua2);
370 
371  // Put avatar within 10m of the prim so that sit doesn't fail.
372  sp2.AbsolutePosition = new Vector3(0, 0, 0);
373  sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero);
374 
375  scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false);
376 
377  Assert.That(sp.HasAttachments(), Is.False);
378  Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
379 
380  // Check events
381  Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0));
382  }
383 
384  [Test]
386  {
387  TestHelpers.InMethod();
388 // TestHelpers.EnableLogging();
389 
390  Scene scene = CreateTestScene();
391  UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
392  ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);
393 
394  InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
395 
396  {
397  scene.AttachmentsModule.RezSingleAttachmentFromInventory(
398  sp, attItem.ID, (uint)AttachmentPoint.Chest);
399 
400  // Check scene presence status
401  Assert.That(sp.HasAttachments(), Is.True);
402  List<SceneObjectGroup> attachments = sp.GetAttachments();
403  Assert.That(attachments.Count, Is.EqualTo(1));
404  SceneObjectGroup attSo = attachments[0];
405  Assert.That(attSo.Name, Is.EqualTo(attItem.Name));
406  Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
407  Assert.That(attSo.IsAttachment);
408  Assert.That(attSo.UsesPhysics, Is.False);
409  Assert.That(attSo.IsTemporary, Is.False);
410  Assert.IsFalse(attSo.Backup);
411 
412  // Check appearance status
413 // Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
414 // Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
415  Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
416 
417  // Check events
418  Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
419  }
420 
421  // Test attaching an already attached attachment
422  {
423  scene.AttachmentsModule.RezSingleAttachmentFromInventory(
424  sp, attItem.ID, (uint)AttachmentPoint.Chest);
425 
426  // Check scene presence status
427  Assert.That(sp.HasAttachments(), Is.True);
428  List<SceneObjectGroup> attachments = sp.GetAttachments();
429  Assert.That(attachments.Count, Is.EqualTo(1));
430  SceneObjectGroup attSo = attachments[0];
431  Assert.That(attSo.Name, Is.EqualTo(attItem.Name));
432  Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
433  Assert.That(attSo.IsAttachment);
434  Assert.That(attSo.UsesPhysics, Is.False);
435  Assert.That(attSo.IsTemporary, Is.False);
436 
437  // Check appearance status
438 // Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
439 // Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
440  Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
441 
442  // Check events
443  Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
444  }
445  }
446 
450  [Test]
452  {
453  TestHelpers.InMethod();
454 // TestHelpers.EnableLogging();
455 
456  Scene scene = CreateTestScene();
457  UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
458  ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);
459 
460  InventoryItemBase attItem1 = CreateAttachmentItem(scene, ua1.PrincipalID, "att1", 0x10, 0x20);
461  InventoryItemBase attItem2 = CreateAttachmentItem(scene, ua1.PrincipalID, "att2", 0x11, 0x21);
462 
463  {
464  m_numberOfAttachEventsFired = 0;
465  scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, attItem1.ID, (uint)AttachmentPoint.Default);
466 
467  // default attachment point is currently the left hand.
468  Assert.That(sp.HasAttachments(), Is.True);
469  List<SceneObjectGroup> attachments = sp.GetAttachments();
470  Assert.That(attachments.Count, Is.EqualTo(1));
471  SceneObjectGroup attSo = attachments[0];
472  Assert.That(attSo.Name, Is.EqualTo(attItem1.Name));
473  Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
474  Assert.That(attSo.IsAttachment);
475 
476  // Check appearance status
477 // Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
478 // Assert.That(sp.Appearance.GetAttachpoint(attItem1.ID), Is.EqualTo((int)AttachmentPoint.LeftHand));
479  Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
480 
481  // Check events
482  Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
483  }
484 
485  // Test wearing a second attachment at the same position
486  // Until multiple attachments at one point is implemented, this will remove the first attachment
487  // This test relies on both attachments having the same default attachment point (in this case LeftHand
488  // since none other has been set).
489  {
490  scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, attItem2.ID, (uint)AttachmentPoint.Default);
491 
492  // default attachment point is currently the left hand.
493  Assert.That(sp.HasAttachments(), Is.True);
494  List<SceneObjectGroup> attachments = sp.GetAttachments();
495  Assert.That(attachments.Count, Is.EqualTo(1));
496  SceneObjectGroup attSo = attachments[0];
497  Assert.That(attSo.Name, Is.EqualTo(attItem2.Name));
498  Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
499  Assert.That(attSo.IsAttachment);
500 
501  // Check appearance status
502 // Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
503 // Assert.That(sp.Appearance.GetAttachpoint(attItem2.ID), Is.EqualTo((int)AttachmentPoint.LeftHand));
504  Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
505 
506  // Check events
507  Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3));
508  }
509 
510  // Test wearing an already attached attachment
511  {
512  scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, attItem2.ID, (uint)AttachmentPoint.Default);
513 
514  // default attachment point is currently the left hand.
515  Assert.That(sp.HasAttachments(), Is.True);
516  List<SceneObjectGroup> attachments = sp.GetAttachments();
517  Assert.That(attachments.Count, Is.EqualTo(1));
518  SceneObjectGroup attSo = attachments[0];
519  Assert.That(attSo.Name, Is.EqualTo(attItem2.Name));
520  Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
521  Assert.That(attSo.IsAttachment);
522 
523  // Check appearance status
524 // Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
525 // Assert.That(sp.Appearance.GetAttachpoint(attItem2.ID), Is.EqualTo((int)AttachmentPoint.LeftHand));
526  Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
527 
528  // Check events
529  Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3));
530  }
531  }
532 
536  [Test]
538  {
539  TestHelpers.InMethod();
540 
541  Scene scene = CreateScriptingEnabledTestScene();
542  UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
543  ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1);
544 
545  SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10);
546  TaskInventoryItem scriptItem
547  = TaskInventoryHelpers.AddScript(
548  scene.AssetService,
549  so.RootPart,
550  "scriptItem",
551  "default { attach(key id) { if (id != NULL_KEY) { llSay(0, \"Hello World\"); } } }");
552 
553  InventoryItemBase userItem = UserInventoryHelpers.AddInventoryItem(scene, so, 0x100, 0x1000);
554 
555  // FIXME: Right now, we have to do a tricksy chat listen to make sure we know when the script is running.
556  // In the future, we need to be able to do this programatically more predicably.
557  scene.EventManager.OnChatFromWorld += OnChatFromWorld;
558 
559  m_chatEvent.Reset();
560  scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest);
561 
562  m_chatEvent.WaitOne(60000);
563 
564  // TODO: Need to have a test that checks the script is actually started but this involves a lot more
565  // plumbing of the script engine and either pausing for events or more infrastructure to turn off various
566  // script engine delays/asychronicity that isn't helpful in an automated regression testing context.
567  SceneObjectGroup attSo = scene.GetSceneObjectGroup(so.Name);
568  Assert.That(attSo.ContainsScripts(), Is.True);
569 
570  TaskInventoryItem reRezzedScriptItem = attSo.RootPart.Inventory.GetInventoryItem(scriptItem.Name);
571  IScriptModule xengine = scene.RequestModuleInterface<IScriptModule>();
572  Assert.That(xengine.GetScriptState(reRezzedScriptItem.ItemID), Is.True);
573  }
574 
575  [Test]
577  {
578  TestHelpers.InMethod();
579 // log4net.Config.XmlConfigurator.Configure();
580 
581  Scene scene = CreateTestScene();
582  UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
583  ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);
584 
585  InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
586 
587  ISceneEntity so
588  = scene.AttachmentsModule.RezSingleAttachmentFromInventory(
589  sp, attItem.ID, (uint)AttachmentPoint.Chest);
590 
591  m_numberOfAttachEventsFired = 0;
592  scene.AttachmentsModule.DetachSingleAttachmentToGround(sp, so.LocalId);
593 
594  // Check scene presence status
595  Assert.That(sp.HasAttachments(), Is.False);
596  List<SceneObjectGroup> attachments = sp.GetAttachments();
597  Assert.That(attachments.Count, Is.EqualTo(0));
598 
599  // Check appearance status
600 // Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(0));
601 
602  // Check item status
603  Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItem.ID)), Is.Null);
604 
605  // Check object in scene
606  SceneObjectGroup soInScene = scene.GetSceneObjectGroup("att");
607  Assert.That(soInScene, Is.Not.Null);
608  Assert.IsTrue(soInScene.Backup);
609 
610  // Check events
611  Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
612  }
613 
614  [Test]
616  {
617  TestHelpers.InMethod();
618 
619  Scene scene = CreateTestScene();
620  UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
621  ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);
622 
623  InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
624 
626  = (SceneObjectGroup)scene.AttachmentsModule.RezSingleAttachmentFromInventory(
627  sp, attItem.ID, (uint)AttachmentPoint.Chest);
628 
629  m_numberOfAttachEventsFired = 0;
630  scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, so);
631 
632  // Check status on scene presence
633  Assert.That(sp.HasAttachments(), Is.False);
634  List<SceneObjectGroup> attachments = sp.GetAttachments();
635  Assert.That(attachments.Count, Is.EqualTo(0));
636 
637  // Check item status
638 // Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo(0));
639 
640  Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(0));
641 
642  // Check events
643  Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
644  }
645 
649  [Test]
651  {
652  TestHelpers.InMethod();
653 // TestHelpers.EnableLogging();
654 
655  Scene scene = CreateScriptingEnabledTestScene();
656  UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
657  ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1);
658 
659  SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10);
660  TaskInventoryItem scriptTaskItem
661  = TaskInventoryHelpers.AddScript(
662  scene.AssetService,
663  so.RootPart,
664  "scriptItem",
665  "default { attach(key id) { if (id != NULL_KEY) { llSay(0, \"Hello World\"); } } }");
666 
667  InventoryItemBase userItem = UserInventoryHelpers.AddInventoryItem(scene, so, 0x100, 0x1000);
668 
669  // FIXME: Right now, we have to do a tricksy chat listen to make sure we know when the script is running.
670  // In the future, we need to be able to do this programatically more predicably.
671  scene.EventManager.OnChatFromWorld += OnChatFromWorld;
672 
673  m_chatEvent.Reset();
674  SceneObjectGroup rezzedSo
675  = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest));
676 
677  // Wait for chat to signal rezzed script has been started.
678  m_chatEvent.WaitOne(60000);
679 
680  scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, rezzedSo);
681 
682  InventoryItemBase userItemUpdated = scene.InventoryService.GetItem(userItem);
683  AssetBase asset = scene.AssetService.Get(userItemUpdated.AssetID.ToString());
684 
685  // TODO: It would probably be better here to check script state via the saving and retrieval of state
686  // information at a higher level, rather than having to inspect the serialization.
687  XmlDocument soXml = new XmlDocument();
688  soXml.LoadXml(Encoding.UTF8.GetString(asset.Data));
689 
690  XmlNodeList scriptStateNodes = soXml.GetElementsByTagName("ScriptState");
691  Assert.That(scriptStateNodes.Count, Is.EqualTo(1));
692 
693  // Re-rez the attachment to check script running state
694  SceneObjectGroup reRezzedSo = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest));
695 
696  // Wait for chat to signal rezzed script has been started.
697  m_chatEvent.WaitOne(60000);
698 
699  TaskInventoryItem reRezzedScriptItem = reRezzedSo.RootPart.Inventory.GetInventoryItem(scriptTaskItem.Name);
700  IScriptModule xengine = scene.RequestModuleInterface<IScriptModule>();
701  Assert.That(xengine.GetScriptState(reRezzedScriptItem.ItemID), Is.True);
702 
703 // Console.WriteLine(soXml.OuterXml);
704  }
705 
709  [Test]
711  {
712  TestHelpers.InMethod();
713 // log4net.Config.XmlConfigurator.Configure();
714 
715  Scene scene = CreateTestScene();
716  UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
717  InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
718 
719  AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID);
720  acd.Appearance = new AvatarAppearance();
721  acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID);
722  ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd);
723 
724  UUID rezzedAttID = presence.GetAttachments()[0].UUID;
725 
726  m_numberOfAttachEventsFired = 0;
727  scene.CloseAgent(presence.UUID, false);
728 
729  // Check that we can't retrieve this attachment from the scene.
730  Assert.That(scene.GetSceneObjectGroup(rezzedAttID), Is.Null);
731 
732  // Check events
733  Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0));
734  }
735 
736  [Test]
738  {
739  TestHelpers.InMethod();
740 // TestHelpers.EnableLogging();
741 
742  Scene scene = CreateTestScene();
743  UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
744  InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
745 
746  AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID);
747  acd.Appearance = new AvatarAppearance();
748  acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID);
749 
750  m_numberOfAttachEventsFired = 0;
751  ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd);
752 
753  Assert.That(presence.HasAttachments(), Is.True);
754  List<SceneObjectGroup> attachments = presence.GetAttachments();
755 
756  Assert.That(attachments.Count, Is.EqualTo(1));
757  SceneObjectGroup attSo = attachments[0];
758  Assert.That(attSo.Name, Is.EqualTo(attItem.Name));
759  Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
760  Assert.That(attSo.IsAttachment);
761  Assert.That(attSo.UsesPhysics, Is.False);
762  Assert.That(attSo.IsTemporary, Is.False);
763  Assert.IsFalse(attSo.Backup);
764 
765  // Check appearance status
766  List<AvatarAttachment> retreivedAttachments = presence.Appearance.GetAttachments();
767  Assert.That(retreivedAttachments.Count, Is.EqualTo(1));
768  Assert.That(retreivedAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest));
769  Assert.That(retreivedAttachments[0].ItemID, Is.EqualTo(attItem.ID));
770  Assert.That(retreivedAttachments[0].AssetID, Is.EqualTo(attItem.AssetID));
771  Assert.That(presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
772 
773  Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
774 
775  // Check events. We expect OnAttach to fire on login.
776  Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
777  }
778 
779  [Test]
781  {
782  TestHelpers.InMethod();
783 
784  Scene scene = CreateTestScene();
785  UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
786  InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
787 
788  AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID);
789  acd.Appearance = new AvatarAppearance();
790  acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID);
791  ScenePresence sp = SceneHelpers.AddScenePresence(scene, acd);
792 
793  SceneObjectGroup attSo = sp.GetAttachments()[0];
794 
795  Vector3 newPosition = new Vector3(1, 2, 4);
796 
797  m_numberOfAttachEventsFired = 0;
798  scene.SceneGraph.UpdatePrimGroupPosition(attSo.LocalId, newPosition, sp.ControllingClient);
799 
800  Assert.That(attSo.AbsolutePosition, Is.EqualTo(sp.AbsolutePosition));
801  Assert.That(attSo.RootPart.AttachedPos, Is.EqualTo(newPosition));
802 
803  // Check events
804  Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0));
805  }
806 
807 /*
808  [Test]
809  public void TestSameSimulatorNeighbouringRegionsTeleportV1()
810  {
811  TestHelpers.InMethod();
812 // TestHelpers.EnableLogging();
813 
814  BaseHttpServer httpServer = new BaseHttpServer(99999);
815  MainServer.AddHttpServer(httpServer);
816  MainServer.Instance = httpServer;
817 
818  AttachmentsModule attModA = new AttachmentsModule();
819  AttachmentsModule attModB = new AttachmentsModule();
820  EntityTransferModule etmA = new EntityTransferModule();
821  EntityTransferModule etmB = new EntityTransferModule();
822  LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
823 
824  IConfigSource config = new IniConfigSource();
825  IConfig modulesConfig = config.AddConfig("Modules");
826  modulesConfig.Set("EntityTransferModule", etmA.Name);
827  modulesConfig.Set("SimulationServices", lscm.Name);
828  IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
829 
830  // In order to run a single threaded regression test we do not want the entity transfer module waiting
831  // for a callback from the destination scene before removing its avatar data.
832  entityTransferConfig.Set("wait_for_callback", false);
833 
834  modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule");
835 
836  SceneHelpers sh = new SceneHelpers();
837  TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
838  TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);
839 
840  SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
841  SceneHelpers.SetupSceneModules(
842  sceneA, config, new CapabilitiesModule(), etmA, attModA, new BasicInventoryAccessModule());
843  SceneHelpers.SetupSceneModules(
844  sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule());
845 
846  // FIXME: Hack - this is here temporarily to revert back to older entity transfer behaviour
847  lscm.ServiceVersion = 0.1f;
848 
849  UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(sceneA, 0x1);
850 
851  AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID);
852  TestClient tc = new TestClient(acd, sceneA);
853  List<TestClient> destinationTestClients = new List<TestClient>();
854  EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
855 
856  ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
857  beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32);
858 
859  InventoryItemBase attItem = CreateAttachmentItem(sceneA, ua1.PrincipalID, "att", 0x10, 0x20);
860 
861  sceneA.AttachmentsModule.RezSingleAttachmentFromInventory(
862  beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest);
863 
864  Vector3 teleportPosition = new Vector3(10, 11, 12);
865  Vector3 teleportLookAt = new Vector3(20, 21, 22);
866 
867  m_numberOfAttachEventsFired = 0;
868  sceneA.RequestTeleportLocation(
869  beforeTeleportSp.ControllingClient,
870  sceneB.RegionInfo.RegionHandle,
871  teleportPosition,
872  teleportLookAt,
873  (uint)TeleportFlags.ViaLocation);
874 
875  destinationTestClients[0].CompleteMovement();
876 
877  // Check attachments have made it into sceneB
878  ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(ua1.PrincipalID);
879 
880  // This is appearance data, as opposed to actually rezzed attachments
881  List<AvatarAttachment> sceneBAttachments = afterTeleportSceneBSp.Appearance.GetAttachments();
882  Assert.That(sceneBAttachments.Count, Is.EqualTo(1));
883  Assert.That(sceneBAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest));
884  Assert.That(sceneBAttachments[0].ItemID, Is.EqualTo(attItem.ID));
885  Assert.That(sceneBAttachments[0].AssetID, Is.EqualTo(attItem.AssetID));
886  Assert.That(afterTeleportSceneBSp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
887 
888  // This is the actual attachment
889  List<SceneObjectGroup> actualSceneBAttachments = afterTeleportSceneBSp.GetAttachments();
890  Assert.That(actualSceneBAttachments.Count, Is.EqualTo(1));
891  SceneObjectGroup actualSceneBAtt = actualSceneBAttachments[0];
892  Assert.That(actualSceneBAtt.Name, Is.EqualTo(attItem.Name));
893  Assert.That(actualSceneBAtt.AttachmentPoint, Is.EqualTo((uint)AttachmentPoint.Chest));
894  Assert.IsFalse(actualSceneBAtt.Backup);
895 
896  Assert.That(sceneB.GetSceneObjectGroups().Count, Is.EqualTo(1));
897 
898  // Check attachments have been removed from sceneA
899  ScenePresence afterTeleportSceneASp = sceneA.GetScenePresence(ua1.PrincipalID);
900 
901  // Since this is appearance data, it is still present on the child avatar!
902  List<AvatarAttachment> sceneAAttachments = afterTeleportSceneASp.Appearance.GetAttachments();
903  Assert.That(sceneAAttachments.Count, Is.EqualTo(1));
904  Assert.That(afterTeleportSceneASp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
905 
906  // This is the actual attachment, which should no longer exist
907  List<SceneObjectGroup> actualSceneAAttachments = afterTeleportSceneASp.GetAttachments();
908  Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0));
909 
910  Assert.That(sceneA.GetSceneObjectGroups().Count, Is.EqualTo(0));
911 
912  // Check events
913  Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0));
914  }
915 */
916 
917  [Test]
919  {
920  TestHelpers.InMethod();
921 // TestHelpers.EnableLogging();
922 
924  MainServer.AddHttpServer(httpServer);
925  MainServer.Instance = httpServer;
926 
927  AttachmentsModule attModA = new AttachmentsModule();
928  AttachmentsModule attModB = new AttachmentsModule();
932 
933  IConfigSource config = new IniConfigSource();
934  IConfig modulesConfig = config.AddConfig("Modules");
935  modulesConfig.Set("EntityTransferModule", etmA.Name);
936  modulesConfig.Set("SimulationServices", lscm.Name);
937 
938  modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule");
939 
940  SceneHelpers sh = new SceneHelpers();
941  TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
942  TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);
943 
944  SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
945  SceneHelpers.SetupSceneModules(
946  sceneA, config, new CapabilitiesModule(), etmA, attModA, new BasicInventoryAccessModule());
947  SceneHelpers.SetupSceneModules(
948  sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule());
949 
950  UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(sceneA, 0x1);
951 
952  AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID);
953  TestClient tc = new TestClient(acd, sceneA);
954  List<TestClient> destinationTestClients = new List<TestClient>();
955  EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
956 
957  ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
958  beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32);
959 
960  Assert.That(destinationTestClients.Count, Is.EqualTo(1));
961  Assert.That(destinationTestClients[0], Is.Not.Null);
962 
963  InventoryItemBase attItem = CreateAttachmentItem(sceneA, ua1.PrincipalID, "att", 0x10, 0x20);
964 
965  sceneA.AttachmentsModule.RezSingleAttachmentFromInventory(
966  beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest);
967 
968  Vector3 teleportPosition = new Vector3(10, 11, 12);
969  Vector3 teleportLookAt = new Vector3(20, 21, 22);
970 
971  // Here, we need to make clientA's receipt of SendRegionTeleport trigger clientB's CompleteMovement(). This
972  // is to operate the teleport V2 mechanism where the EntityTransferModule will first request the client to
973  // CompleteMovement to the region and then call UpdateAgent to the destination region to confirm the receipt
974  // Both these operations will occur on different threads and will wait for each other.
975  // We have to do this via ThreadPool directly since FireAndForget has been switched to sync for the V1
976  // test protocol, where we are trying to avoid unpredictable async operations in regression tests.
977  tc.OnTestClientSendRegionTeleport
978  += (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL)
979  => ThreadPool.UnsafeQueueUserWorkItem(o => destinationTestClients[0].CompleteMovement(), null);
980 
981  m_numberOfAttachEventsFired = 0;
982  sceneA.RequestTeleportLocation(
983  beforeTeleportSp.ControllingClient,
984  sceneB.RegionInfo.RegionHandle,
985  teleportPosition,
986  teleportLookAt,
987  (uint)TeleportFlags.ViaLocation);
988 
989  // Check attachments have made it into sceneB
990  ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(ua1.PrincipalID);
991 
992  // This is appearance data, as opposed to actually rezzed attachments
993  List<AvatarAttachment> sceneBAttachments = afterTeleportSceneBSp.Appearance.GetAttachments();
994  Assert.That(sceneBAttachments.Count, Is.EqualTo(1));
995  Assert.That(sceneBAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest));
996  Assert.That(sceneBAttachments[0].ItemID, Is.EqualTo(attItem.ID));
997  Assert.That(sceneBAttachments[0].AssetID, Is.EqualTo(attItem.AssetID));
998  Assert.That(afterTeleportSceneBSp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
999 
1000  // This is the actual attachment
1001  List<SceneObjectGroup> actualSceneBAttachments = afterTeleportSceneBSp.GetAttachments();
1002  Assert.That(actualSceneBAttachments.Count, Is.EqualTo(1));
1003  SceneObjectGroup actualSceneBAtt = actualSceneBAttachments[0];
1004  Assert.That(actualSceneBAtt.Name, Is.EqualTo(attItem.Name));
1005  Assert.That(actualSceneBAtt.AttachmentPoint, Is.EqualTo((uint)AttachmentPoint.Chest));
1006  Assert.IsFalse(actualSceneBAtt.Backup);
1007 
1008  Assert.That(sceneB.GetSceneObjectGroups().Count, Is.EqualTo(1));
1009 
1010  // Check attachments have been removed from sceneA
1011  ScenePresence afterTeleportSceneASp = sceneA.GetScenePresence(ua1.PrincipalID);
1012 
1013  // Since this is appearance data, it is still present on the child avatar!
1014  List<AvatarAttachment> sceneAAttachments = afterTeleportSceneASp.Appearance.GetAttachments();
1015  Assert.That(sceneAAttachments.Count, Is.EqualTo(1));
1016  Assert.That(afterTeleportSceneASp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
1017 
1018  // This is the actual attachment, which should no longer exist
1019  List<SceneObjectGroup> actualSceneAAttachments = afterTeleportSceneASp.GetAttachments();
1020  Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0));
1021 
1022  Assert.That(sceneA.GetSceneObjectGroups().Count, Is.EqualTo(0));
1023 
1024  // Check events
1025  Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0));
1026  }
1027  }
1028 }
UUID FromItemID
The item ID that this object was rezzed from, if applicable.
OpenSim.Framework.Constants.TeleportFlags TeleportFlags
void TestDetachScriptedAttachmentToInventory()
Test specific conditions associated with detaching a scripted attachment from inventory.
void TestWearAttachmentFromInventory()
Test wearing an attachment from inventory, as opposed to explicit choosing the rez point ...
Contains the Avatar's Appearance and methods to manipulate the appearance.
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
Represents an item in a task inventory
System.Timers.Timer Timer
void TestAddSatOnAttachmentFromGround()
Test that we do not attempt to attach an in-world object that someone else is sitting on...
System.Timers.Timer Timer
Asset class. All Assets are reference by this class or a class derived from this class ...
Definition: AssetBase.cs:49
static UUID ParseTail(int tail)
Parse tail section into full UUID.
Definition: TestHelpers.cs:140
ChatFromViewer Arguments
Circuit data for an agent. Connection information shared between regions that accept UDP connections ...
void TestRezScriptedAttachmentFromInventory()
Test specific conditions associated with rezzing a scripted attachment from inventory.
Inventory Item - contains all the properties associated with an individual inventory piece...
Helpers for setting up scenes.
Definition: SceneHelpers.cs:60
void TestRemoveAttachmentsOnAvatarExit()
Test that attachments don't hang about in the scene when the agent is closed
Interactive OpenSim region server
Definition: OpenSim.cs:55