OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
TaskInventoryTests.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;
35 using Nini.Config;
36 using NUnit.Framework;
37 using OpenMetaverse;
38 using OpenMetaverse.Assets;
39 using OpenSim.Framework;
40 using OpenSim.Region.Framework.Scenes;
41 using OpenSim.Region.Framework.Interfaces;
42 using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
43 using OpenSim.Region.CoreModules.World.Serialiser;
44 using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
45 using OpenSim.Services.Interfaces;
46 using OpenSim.Tests.Common;
47 
48 namespace OpenSim.Region.Framework.Tests
49 {
50  [TestFixture]
52  {
53  [Test]
55  {
56  TestHelpers.InMethod();
57 // log4net.Config.XmlConfigurator.Configure();
58 
59  Scene scene = new SceneHelpers().SetupScene();
60  UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
61  SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID);
62  SceneObjectPart sop1 = sog1.RootPart;
63 
64  // Create an object embedded inside the first
65  UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000");
66  TaskInventoryHelpers.AddSceneObject(scene.AssetService, sop1, "tso", taskSceneObjectItemId, user1.PrincipalID);
67 
68  TaskInventoryItem addedItem = sop1.Inventory.GetInventoryItem(taskSceneObjectItemId);
69  Assert.That(addedItem.ItemID, Is.EqualTo(taskSceneObjectItemId));
70  Assert.That(addedItem.OwnerID, Is.EqualTo(user1.PrincipalID));
71  Assert.That(addedItem.ParentID, Is.EqualTo(sop1.UUID));
72  Assert.That(addedItem.InvType, Is.EqualTo((int)InventoryType.Object));
73  Assert.That(addedItem.Type, Is.EqualTo((int)AssetType.Object));
74  }
75 
76  [Test]
78  {
79  TestHelpers.InMethod();
80 // log4net.Config.XmlConfigurator.Configure();
81 
82  Scene scene = new SceneHelpers().SetupScene();
83  UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
84  SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID);
85  SceneObjectPart sop1 = sog1.RootPart;
86 
87  // Create an object embedded inside the first
88  UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000");
89  TaskInventoryItem taskSceneObjectItem
90  = TaskInventoryHelpers.AddSceneObject(scene.AssetService, sop1, "tso", taskSceneObjectItemId, user1.PrincipalID);
91 
92  scene.AddSceneObject(sog1);
93 
94  Vector3 rezPos = new Vector3(10, 10, 10);
95  Quaternion rezRot = new Quaternion(0.5f, 0.5f, 0.5f, 0.5f);
96  Vector3 rezVel = new Vector3(2, 2, 2);
97 
98  scene.RezObject(sop1, taskSceneObjectItem, rezPos, rezRot, rezVel, 0,false);
99 
100  SceneObjectGroup rezzedObject = scene.GetSceneObjectGroup("tso");
101 
102  Assert.That(rezzedObject, Is.Not.Null);
103  Assert.That(rezzedObject.AbsolutePosition, Is.EqualTo(rezPos));
104 
105  // Velocity doesn't get applied, probably because there is no physics in tests (yet)
106 // Assert.That(rezzedObject.Velocity, Is.EqualTo(rezVel));
107  Assert.That(rezzedObject.Velocity, Is.EqualTo(Vector3.Zero));
108 
109  // Confusingly, this isn't the rezzedObject.Rotation
110  Assert.That(rezzedObject.RootPart.RotationOffset, Is.EqualTo(rezRot));
111  }
112 
119  [Test]
121  {
122  TestHelpers.InMethod();
123 // log4net.Config.XmlConfigurator.Configure();
124 
125  Scene scene = new SceneHelpers().SetupScene();
126  UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
127  SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID);
128  SceneObjectPart sop1 = sog1.RootPart;
129  TaskInventoryItem sopItem1
130  = TaskInventoryHelpers.AddNotecard(
131  scene.AssetService, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!");
132 
133  InventoryFolderBase folder
134  = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0];
135 
136  // Perform test
137  string message;
138  scene.MoveTaskInventoryItem(user1.PrincipalID, folder.ID, sop1, sopItem1.ItemID, out message);
139 
140  InventoryItemBase ncUserItem
141  = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Objects/ncItem");
142  Assert.That(ncUserItem, Is.Not.Null, "Objects/ncItem was not found");
143  }
144 
151  [Test]
153  {
154  TestHelpers.InMethod();
155 // log4net.Config.XmlConfigurator.Configure();
156 
157  Scene scene = new SceneHelpers().SetupScene();
158  UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
159  SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID);
160 
161  SceneObjectPart sop1 = sog1.RootPart;
162  TaskInventoryItem sopItem1
163  = TaskInventoryHelpers.AddNotecard(
164  scene.AssetService, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!");
165 
166  // Perform test
167  string message;
168  scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID, out message);
169 
170  InventoryItemBase ncUserItem
171  = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Notecards/ncItem");
172  Assert.That(ncUserItem, Is.Not.Null, "Notecards/ncItem was not found");
173  }
174  }
175 }
void TestMoveTaskInventoryItem()
Test MoveTaskInventoryItem from a part inventory to a user inventory where the item has no parent fol...
System.Timers.Timer Timer
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
static UUID ParseTail(int tail)
Parse tail section into full UUID.
Definition: TestHelpers.cs:140
Inventory Item - contains all the properties associated with an individual inventory piece...
void TestMoveTaskInventoryItemNoParent()
Test MoveTaskInventoryItem from a part inventory to a user inventory where the item has no parent fol...
Helpers for setting up scenes.
Definition: SceneHelpers.cs:60
Interactive OpenSim region server
Definition: OpenSim.cs:55