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.IO; |
||
31 | using System.Reflection; |
||
32 | using System.Threading; |
||
33 | using Nini.Config; |
||
34 | using NUnit.Framework; |
||
35 | using OpenMetaverse; |
||
36 | using OpenSim.Data; |
||
37 | using OpenSim.Framework; |
||
38 | using OpenSim.Framework.Serialization; |
||
39 | using OpenSim.Framework.Serialization.External; |
||
40 | using OpenSim.Framework.Communications; |
||
41 | using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; |
||
42 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; |
||
43 | using OpenSim.Region.Framework.Scenes; |
||
44 | using OpenSim.Region.Framework.Scenes.Serialization; |
||
45 | using OpenSim.Services.Interfaces; |
||
46 | using OpenSim.Tests.Common; |
||
47 | using OpenSim.Tests.Common.Mock; |
||
48 | |||
49 | namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests |
||
50 | { |
||
51 | [TestFixture] |
||
52 | public class InventoryAccessModuleTests : OpenSimTestCase |
||
53 | { |
||
54 | protected TestScene m_scene; |
||
55 | protected BasicInventoryAccessModule m_iam; |
||
56 | protected UUID m_userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); |
||
57 | protected TestClient m_tc; |
||
58 | |||
59 | [SetUp] |
||
60 | public override void SetUp() |
||
61 | { |
||
62 | base.SetUp(); |
||
63 | |||
64 | m_iam = new BasicInventoryAccessModule(); |
||
65 | |||
66 | IConfigSource config = new IniConfigSource(); |
||
67 | config.AddConfig("Modules"); |
||
68 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); |
||
69 | |||
70 | SceneHelpers sceneHelpers = new SceneHelpers(); |
||
71 | m_scene = sceneHelpers.SetupScene(); |
||
72 | SceneHelpers.SetupSceneModules(m_scene, config, m_iam); |
||
73 | |||
74 | // Create user |
||
75 | string userFirstName = "Jock"; |
||
76 | string userLastName = "Stirrup"; |
||
77 | string userPassword = "troll"; |
||
78 | UserAccountHelpers.CreateUserWithInventory(m_scene, userFirstName, userLastName, m_userId, userPassword); |
||
79 | |||
80 | AgentCircuitData acd = new AgentCircuitData(); |
||
81 | acd.AgentID = m_userId; |
||
82 | m_tc = new TestClient(acd, m_scene); |
||
83 | } |
||
84 | |||
85 | [Test] |
||
86 | public void TestRezCoalescedObject() |
||
87 | { |
||
88 | TestHelpers.InMethod(); |
||
89 | // log4net.Config.XmlConfigurator.Configure(); |
||
90 | |||
91 | // Create asset |
||
92 | SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, m_userId, "Object1", 0x20); |
||
93 | object1.AbsolutePosition = new Vector3(15, 30, 45); |
||
94 | |||
95 | SceneObjectGroup object2 = SceneHelpers.CreateSceneObject(1, m_userId, "Object2", 0x40); |
||
96 | object2.AbsolutePosition = new Vector3(25, 50, 75); |
||
97 | |||
98 | CoalescedSceneObjects coa = new CoalescedSceneObjects(m_userId, object1, object2); |
||
99 | |||
100 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
||
101 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, coa); |
||
102 | m_scene.AssetService.Store(asset1); |
||
103 | |||
104 | // Create item |
||
105 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); |
||
106 | string item1Name = "My Little Dog"; |
||
107 | InventoryItemBase item1 = new InventoryItemBase(); |
||
108 | item1.Name = item1Name; |
||
109 | item1.AssetID = asset1.FullID; |
||
110 | item1.ID = item1Id; |
||
111 | InventoryFolderBase objsFolder |
||
112 | = InventoryArchiveUtils.FindFoldersByPath(m_scene.InventoryService, m_userId, "Objects")[0]; |
||
113 | item1.Folder = objsFolder.ID; |
||
114 | item1.Flags |= (uint)InventoryItemFlags.ObjectHasMultipleItems; |
||
115 | m_scene.AddInventoryItem(item1); |
||
116 | |||
117 | SceneObjectGroup so |
||
118 | = m_iam.RezObject( |
||
119 | m_tc, item1Id, new Vector3(100, 100, 100), Vector3.Zero, UUID.Zero, 1, false, false, false, UUID.Zero, false); |
||
120 | |||
121 | Assert.That(so, Is.Not.Null); |
||
122 | |||
123 | Assert.That(m_scene.SceneGraph.GetTotalObjectsCount(), Is.EqualTo(2)); |
||
124 | |||
125 | SceneObjectPart retrievedObj1Part = m_scene.GetSceneObjectPart(object1.Name); |
||
126 | Assert.That(retrievedObj1Part, Is.Null); |
||
127 | |||
128 | retrievedObj1Part = m_scene.GetSceneObjectPart(item1.Name); |
||
129 | Assert.That(retrievedObj1Part, Is.Not.Null); |
||
130 | Assert.That(retrievedObj1Part.Name, Is.EqualTo(item1.Name)); |
||
131 | |||
132 | // Bottom of coalescence is placed on ground, hence we end up with 100.5 rather than 85 since the bottom |
||
133 | // object is unit square. |
||
134 | Assert.That(retrievedObj1Part.AbsolutePosition, Is.EqualTo(new Vector3(95, 90, 100.5f))); |
||
135 | |||
136 | SceneObjectPart retrievedObj2Part = m_scene.GetSceneObjectPart(object2.Name); |
||
137 | Assert.That(retrievedObj2Part, Is.Not.Null); |
||
138 | Assert.That(retrievedObj2Part.Name, Is.EqualTo(object2.Name)); |
||
139 | Assert.That(retrievedObj2Part.AbsolutePosition, Is.EqualTo(new Vector3(105, 110, 130.5f))); |
||
140 | } |
||
141 | |||
142 | [Test] |
||
143 | public void TestRezObject() |
||
144 | { |
||
145 | TestHelpers.InMethod(); |
||
146 | // log4net.Config.XmlConfigurator.Configure(); |
||
147 | |||
148 | // Create asset |
||
149 | SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, m_userId, "My Little Dog Object", 0x40); |
||
150 | |||
151 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
||
152 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); |
||
153 | m_scene.AssetService.Store(asset1); |
||
154 | |||
155 | // Create item |
||
156 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); |
||
157 | string item1Name = "My Little Dog"; |
||
158 | InventoryItemBase item1 = new InventoryItemBase(); |
||
159 | item1.Name = item1Name; |
||
160 | item1.AssetID = asset1.FullID; |
||
161 | item1.ID = item1Id; |
||
162 | InventoryFolderBase objsFolder |
||
163 | = InventoryArchiveUtils.FindFoldersByPath(m_scene.InventoryService, m_userId, "Objects")[0]; |
||
164 | item1.Folder = objsFolder.ID; |
||
165 | m_scene.AddInventoryItem(item1); |
||
166 | |||
167 | SceneObjectGroup so |
||
168 | = m_iam.RezObject( |
||
169 | m_tc, item1Id, Vector3.Zero, Vector3.Zero, UUID.Zero, 1, false, false, false, UUID.Zero, false); |
||
170 | |||
171 | Assert.That(so, Is.Not.Null); |
||
172 | |||
173 | SceneObjectPart retrievedPart = m_scene.GetSceneObjectPart(so.UUID); |
||
174 | Assert.That(retrievedPart, Is.Not.Null); |
||
175 | } |
||
176 | } |
||
177 | } |