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