clockwerk-opensim – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 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 Timer=System.Timers.Timer; |
||
35 | using Nini.Config; |
||
36 | using NUnit.Framework; |
||
37 | using OpenMetaverse; |
||
38 | using OpenMetaverse.Assets; |
||
39 | using OpenSim.Framework; |
||
40 | using OpenSim.Framework.Communications; |
||
41 | using OpenSim.Region.Framework.Scenes; |
||
42 | using OpenSim.Region.Framework.Interfaces; |
||
43 | using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; |
||
44 | using OpenSim.Region.CoreModules.World.Serialiser; |
||
45 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
||
46 | using OpenSim.Services.Interfaces; |
||
47 | using OpenSim.Tests.Common; |
||
48 | using OpenSim.Tests.Common.Mock; |
||
49 | |||
50 | namespace OpenSim.Region.Framework.Tests |
||
51 | { |
||
52 | [TestFixture] |
||
53 | public class TaskInventoryTests : OpenSimTestCase |
||
54 | { |
||
55 | [Test] |
||
56 | public void TestAddTaskInventoryItem() |
||
57 | { |
||
58 | TestHelpers.InMethod(); |
||
59 | // log4net.Config.XmlConfigurator.Configure(); |
||
60 | |||
61 | Scene scene = new SceneHelpers().SetupScene(); |
||
62 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); |
||
63 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); |
||
64 | SceneObjectPart sop1 = sog1.RootPart; |
||
65 | |||
66 | // Create an object embedded inside the first |
||
67 | UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); |
||
68 | TaskInventoryHelpers.AddSceneObject(scene, sop1, "tso", taskSceneObjectItemId, user1.PrincipalID); |
||
69 | |||
70 | TaskInventoryItem addedItem = sop1.Inventory.GetInventoryItem(taskSceneObjectItemId); |
||
71 | Assert.That(addedItem.ItemID, Is.EqualTo(taskSceneObjectItemId)); |
||
72 | Assert.That(addedItem.OwnerID, Is.EqualTo(user1.PrincipalID)); |
||
73 | Assert.That(addedItem.ParentID, Is.EqualTo(sop1.UUID)); |
||
74 | Assert.That(addedItem.InvType, Is.EqualTo((int)InventoryType.Object)); |
||
75 | Assert.That(addedItem.Type, Is.EqualTo((int)AssetType.Object)); |
||
76 | } |
||
77 | |||
78 | [Test] |
||
79 | public void TestRezObjectFromInventoryItem() |
||
80 | { |
||
81 | TestHelpers.InMethod(); |
||
82 | // log4net.Config.XmlConfigurator.Configure(); |
||
83 | |||
84 | Scene scene = new SceneHelpers().SetupScene(); |
||
85 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); |
||
86 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); |
||
87 | SceneObjectPart sop1 = sog1.RootPart; |
||
88 | |||
89 | // Create an object embedded inside the first |
||
90 | UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); |
||
91 | TaskInventoryItem taskSceneObjectItem |
||
92 | = TaskInventoryHelpers.AddSceneObject(scene, sop1, "tso", taskSceneObjectItemId, user1.PrincipalID); |
||
93 | |||
94 | scene.AddSceneObject(sog1); |
||
95 | |||
96 | Vector3 rezPos = new Vector3(10, 10, 10); |
||
97 | Quaternion rezRot = new Quaternion(0.5f, 0.5f, 0.5f, 0.5f); |
||
98 | Vector3 rezVel = new Vector3(2, 2, 2); |
||
99 | |||
100 | scene.RezObject(sop1, taskSceneObjectItem, rezPos, rezRot, rezVel, 0); |
||
101 | |||
102 | SceneObjectGroup rezzedObject = scene.GetSceneObjectGroup("tso"); |
||
103 | |||
104 | Assert.That(rezzedObject, Is.Not.Null); |
||
105 | Assert.That(rezzedObject.AbsolutePosition, Is.EqualTo(rezPos)); |
||
106 | |||
107 | // Velocity doesn't get applied, probably because there is no physics in tests (yet) |
||
108 | // Assert.That(rezzedObject.Velocity, Is.EqualTo(rezVel)); |
||
109 | Assert.That(rezzedObject.Velocity, Is.EqualTo(Vector3.Zero)); |
||
110 | |||
111 | // Confusingly, this isn't the rezzedObject.Rotation |
||
112 | Assert.That(rezzedObject.RootPart.RotationOffset, Is.EqualTo(rezRot)); |
||
113 | } |
||
114 | |||
115 | /// <summary> |
||
116 | /// Test MoveTaskInventoryItem from a part inventory to a user inventory where the item has no parent folder assigned. |
||
117 | /// </summary> |
||
118 | /// <remarks> |
||
119 | /// This should place it in the most suitable user folder. |
||
120 | /// </remarks> |
||
121 | [Test] |
||
122 | public void TestMoveTaskInventoryItem() |
||
123 | { |
||
124 | TestHelpers.InMethod(); |
||
125 | // log4net.Config.XmlConfigurator.Configure(); |
||
126 | |||
127 | Scene scene = new SceneHelpers().SetupScene(); |
||
128 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); |
||
129 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); |
||
130 | SceneObjectPart sop1 = sog1.RootPart; |
||
131 | TaskInventoryItem sopItem1 |
||
132 | = TaskInventoryHelpers.AddNotecard( |
||
133 | scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); |
||
134 | |||
135 | InventoryFolderBase folder |
||
136 | = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; |
||
137 | |||
138 | // Perform test |
||
139 | string message; |
||
140 | scene.MoveTaskInventoryItem(user1.PrincipalID, folder.ID, sop1, sopItem1.ItemID, out message); |
||
141 | |||
142 | InventoryItemBase ncUserItem |
||
143 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Objects/ncItem"); |
||
144 | Assert.That(ncUserItem, Is.Not.Null, "Objects/ncItem was not found"); |
||
145 | } |
||
146 | |||
147 | /// <summary> |
||
148 | /// Test MoveTaskInventoryItem from a part inventory to a user inventory where the item has no parent folder assigned. |
||
149 | /// </summary> |
||
150 | /// <remarks> |
||
151 | /// This should place it in the most suitable user folder. |
||
152 | /// </remarks> |
||
153 | [Test] |
||
154 | public void TestMoveTaskInventoryItemNoParent() |
||
155 | { |
||
156 | TestHelpers.InMethod(); |
||
157 | // log4net.Config.XmlConfigurator.Configure(); |
||
158 | |||
159 | Scene scene = new SceneHelpers().SetupScene(); |
||
160 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); |
||
161 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); |
||
162 | |||
163 | SceneObjectPart sop1 = sog1.RootPart; |
||
164 | TaskInventoryItem sopItem1 |
||
165 | = TaskInventoryHelpers.AddNotecard( |
||
166 | scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); |
||
167 | |||
168 | // Perform test |
||
169 | string message; |
||
170 | scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID, out message); |
||
171 | |||
172 | InventoryItemBase ncUserItem |
||
173 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Notecards/ncItem"); |
||
174 | Assert.That(ncUserItem, Is.Not.Null, "Notecards/ncItem was not found"); |
||
175 | } |
||
176 | } |
||
177 | } |