OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
InventoryAccessModuleTests.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.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.Region.CoreModules.Avatar.Inventory.Archiver;
41 using OpenSim.Region.CoreModules.Framework.InventoryAccess;
42 using OpenSim.Region.Framework.Scenes;
43 using OpenSim.Region.Framework.Scenes.Serialization;
44 using OpenSim.Services.Interfaces;
45 using OpenSim.Tests.Common;
46 
47 namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests
48 {
49  [TestFixture]
51  {
52  protected TestScene m_scene;
54  protected UUID m_userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
55  protected TestClient m_tc;
56 
57  [SetUp]
58  public override void SetUp()
59  {
60  base.SetUp();
61 
62  m_iam = new BasicInventoryAccessModule();
63 
64  IConfigSource config = new IniConfigSource();
65  config.AddConfig("Modules");
66  config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
67 
68  SceneHelpers sceneHelpers = new SceneHelpers();
69  m_scene = sceneHelpers.SetupScene();
70  SceneHelpers.SetupSceneModules(m_scene, config, m_iam);
71 
72  // Create user
73  string userFirstName = "Jock";
74  string userLastName = "Stirrup";
75  string userPassword = "troll";
76  UserAccountHelpers.CreateUserWithInventory(m_scene, userFirstName, userLastName, m_userId, userPassword);
77 
79  acd.AgentID = m_userId;
80  m_tc = new TestClient(acd, m_scene);
81  }
82 
83  [Test]
84  public void TestRezCoalescedObject()
85  {
86 /*
87  TestHelpers.InMethod();
88 // log4net.Config.XmlConfigurator.Configure();
89 
90  // Create asset
91  SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, m_userId, "Object1", 0x20);
92  object1.AbsolutePosition = new Vector3(15, 30, 45);
93 
94  SceneObjectGroup object2 = SceneHelpers.CreateSceneObject(1, m_userId, "Object2", 0x40);
95  object2.AbsolutePosition = new Vector3(25, 50, 75);
96 
97  CoalescedSceneObjects coa = new CoalescedSceneObjects(m_userId, object1, object2);
98 
99  UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
100  AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, coa);
101  m_scene.AssetService.Store(asset1);
102 
103  // Create item
104  UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
105  string item1Name = "My Little Dog";
106  InventoryItemBase item1 = new InventoryItemBase();
107  item1.Name = item1Name;
108  item1.AssetID = asset1.FullID;
109  item1.ID = item1Id;
110  InventoryFolderBase objsFolder
111  = InventoryArchiveUtils.FindFoldersByPath(m_scene.InventoryService, m_userId, "Objects")[0];
112  item1.Folder = objsFolder.ID;
113  item1.Flags |= (uint)InventoryItemFlags.ObjectHasMultipleItems;
114  m_scene.AddInventoryItem(item1);
115 
116  SceneObjectGroup so
117  = m_iam.RezObject(
118  m_tc, item1Id, new Vector3(100, 100, 100), Vector3.Zero, UUID.Zero, 1, false, false, false, UUID.Zero, false);
119 
120  Assert.That(so, Is.Not.Null);
121 
122  Assert.That(m_scene.SceneGraph.GetTotalObjectsCount(), Is.EqualTo(2));
123 
124  SceneObjectPart retrievedObj1Part = m_scene.GetSceneObjectPart(object1.Name);
125  Assert.That(retrievedObj1Part, Is.Null);
126 
127  retrievedObj1Part = m_scene.GetSceneObjectPart(item1.Name);
128  Assert.That(retrievedObj1Part, Is.Not.Null);
129  Assert.That(retrievedObj1Part.Name, Is.EqualTo(item1.Name));
130 
131  // Bottom of coalescence is placed on ground, hence we end up with 100.5 rather than 85 since the bottom
132  // object is unit square.
133  Assert.That(retrievedObj1Part.AbsolutePosition, Is.EqualTo(new Vector3(95, 90, 100.5f)));
134 
135  SceneObjectPart retrievedObj2Part = m_scene.GetSceneObjectPart(object2.Name);
136  Assert.That(retrievedObj2Part, Is.Not.Null);
137  Assert.That(retrievedObj2Part.Name, Is.EqualTo(object2.Name));
138  Assert.That(retrievedObj2Part.AbsolutePosition, Is.EqualTo(new Vector3(105, 110, 130.5f)));
139 */
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 }
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
Asset class. All Assets are reference by this class or a class derived from this class ...
Definition: AssetBase.cs:49
Circuit data for an agent. Connection information shared between regions that accept UDP connections ...
Inventory Item - contains all the properties associated with an individual inventory piece...
Helpers for setting up scenes.
Definition: SceneHelpers.cs:60